Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpc benchmark init: directly read DB based on schema #20378

Merged
merged 10 commits into from
Feb 18, 2025

Conversation

gegaowp
Copy link
Contributor

@gegaowp gegaowp commented Nov 21, 2024

Description

main things in this pr

  • generate template queries based on tables in the DB, excluding __diesel_schema_migrations
  • enrich the template with values read from DB and execute queries in parallel
  • configs of concurrency and duration time
  • metrics collection and reports

Test plan

  • local run with a local DB populated with latest sui-indexer-alt-schema
cargo run --bin sui-rpc-benchmark -- direct \
    --db-url "postgres://postgres:postgres@localhost/gegao" \
    --concurrency 10 \
    --duration-secs 10

report with local DB


Total queries: 211772
Total errors: 0
Average latency: 0.46ms

Per-table statistics:
  obj_info                       queries: 33526    errors: 0        avg latency: 0.49ms
  ev_struct_inst                 queries: 31598    errors: 0        avg latency: 0.47ms
  tx_calls                       queries: 28752    errors: 0        avg latency: 0.45ms
  ev_emit_mod                    queries: 18321    errors: 0        avg latency: 0.44ms
  tx_affected_objects            queries: 11495    errors: 0        avg latency: 0.43ms
  tx_affected_addresses          queries: 11472    errors: 0        avg latency: 0.43ms
  sum_packages                   queries: 10759    errors: 0        avg latency: 0.55ms
  tx_kinds                       queries: 8140     errors: 0        avg latency: 0.43ms
  coin_balance_buckets           queries: 7542     errors: 0        avg latency: 0.45ms
  obj_versions                   queries: 7485     errors: 0        avg latency: 0.43ms
  kv_epoch_ends                  queries: 3750     errors: 0        avg latency: 0.45ms
  watermarks                     queries: 3742     errors: 0        avg latency: 0.44ms
  tx_digests                     queries: 3690     errors: 0        avg latency: 0.42ms
  tx_balance_changes             queries: 3662     errors: 0        avg latency: 0.42ms
  kv_checkpoints                 queries: 3619     errors: 0        avg latency: 0.43ms
  cp_sequence_numbers            queries: 3590     errors: 0        avg latency: 0.42ms
  kv_transactions                queries: 3463     errors: 0        avg latency: 0.43ms
  kv_protocol_configs            queries: 3451     errors: 0        avg latency: 0.44ms
  kv_epoch_starts                queries: 3448     errors: 0        avg latency: 0.71ms
  kv_genesis                     queries: 3424     errors: 0        avg latency: 0.42ms
  kv_objects                     queries: 3422     errors: 0        avg latency: 0.42ms
  kv_feature_flags               queries: 3421     errors: 0        avg latency: 0.42ms

Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • gRPC:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:

Copy link

vercel bot commented Nov 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 18, 2025 6:44pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Feb 18, 2025 6:44pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Feb 18, 2025 6:44pm
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Feb 18, 2025 6:44pm

@gegaowp gegaowp temporarily deployed to sui-typescript-aws-kms-test-env November 21, 2024 23:00 — with GitHub Actions Inactive
@gegaowp gegaowp temporarily deployed to sui-typescript-aws-kms-test-env November 21, 2024 23:08 — with GitHub Actions Inactive
@gegaowp gegaowp temporarily deployed to sui-typescript-aws-kms-test-env November 21, 2024 23:10 — with GitHub Actions Inactive
@gegaowp gegaowp temporarily deployed to sui-typescript-aws-kms-test-env November 21, 2024 23:12 — with GitHub Actions Inactive
@gegaowp gegaowp changed the title rpc benchmark init: direct reading DB based on schema rpc benchmark init: directly read DB based on schema Nov 21, 2024
@lxfind
Copy link
Contributor

lxfind commented Nov 25, 2024

generate template queries based on schema, specifically table primary key and indexes

What is the rational behind these generated queries? Would they be representative to what we are interested in?

@gegaowp
Copy link
Contributor Author

gegaowp commented Nov 25, 2024

@lxfind the generated queries now are basically "all supported queries based on primary key and indices" and does not consider the representativeness, I plan make it configurable for example taking in a file of weights to make it representative as a followup.

Copy link
Contributor

@amnn amnn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

long,
default_value = "postgres://postgres:postgres@localhost:5432/sui"
)]
db_url: String,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to use Url as the field type here so that clap will handle the parsing validation errors for you -- you can still supply a default value using default_value_t, I think.

) -> Result<Vec<EnrichedBenchmarkQuery>> {
let mut enriched_queries = Vec::new();
for query in queries {
let enriched = self.enrich_query(&query).await?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do this concurrently?

while Instant::now() < deadline {
let enriched = enriched_queries
.choose(&mut query_rng)
.ok_or_else(|| anyhow::anyhow!("No queries available"))?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.ok_or_else(|| anyhow::anyhow!("No queries available"))?;
.context("No queries available")?;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's an option so no original Result to add additional context to?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Context works on Option too (to convert it into an anyhow::Result).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I saw your PR and will amend this change to the latest commit, TIL, thanks!

@gegaowp gegaowp temporarily deployed to sui-typescript-aws-kms-test-env February 18, 2025 18:42 — with GitHub Actions Inactive
@gegaowp gegaowp merged commit 7aaab9c into MystenLabs:main Feb 18, 2025
43 checks passed
@gegaowp gegaowp deleted the rpc-benchmark-init branch February 18, 2025 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants