-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[indexer-alt] Add benchmark command (#20352)
## Description This PR adds a benchmark command to indexer-alt. It would start the indexer using the provided parameters, start and stop based on the local ingestion data. It then measures the time and TPS. A few structural changes to indexer-alt code: 1. Moved lag and pruner options to a dedicated sequential pipeline config, since these params only make sense in a sequential pipeline setting. 2. Moved all the indexer start logic to a dedicated function, so that I can reuse it in the benchmark. 3. Added option to not bootstrap genesis if not needed. ## Test plan Run locally --- ## 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): - [ ] Indexer: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: - [ ] REST API:
- Loading branch information
Showing
9 changed files
with
290 additions
and
115 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use std::{path::PathBuf, time::Instant}; | ||
|
||
use crate::{ | ||
args::ConsistencyConfig, | ||
db::{reset_database, DbConfig}, | ||
ingestion::IngestionConfig, | ||
pipeline::PipelineConfig, | ||
start_indexer, IndexerConfig, | ||
}; | ||
use sui_synthetic_ingestion::synthetic_ingestion::read_ingestion_data; | ||
|
||
#[derive(clap::Args, Debug, Clone)] | ||
pub struct BenchmarkConfig { | ||
/// Path to the local ingestion directory to read checkpoints data from. | ||
#[arg(long)] | ||
ingestion_path: PathBuf, | ||
|
||
#[command(flatten)] | ||
pipeline_config: PipelineConfig, | ||
|
||
/// Only run the following pipelines. If not provided, all pipelines will be run. | ||
#[arg(long, action = clap::ArgAction::Append)] | ||
pipeline: Vec<String>, | ||
|
||
#[command(flatten)] | ||
consistency_config: ConsistencyConfig, | ||
} | ||
|
||
pub async fn run_benchmark( | ||
benchmark_config: BenchmarkConfig, | ||
db_config: DbConfig, | ||
) -> anyhow::Result<()> { | ||
let BenchmarkConfig { | ||
ingestion_path, | ||
pipeline_config, | ||
pipeline, | ||
consistency_config, | ||
} = benchmark_config; | ||
|
||
let ingestion_data = read_ingestion_data(&ingestion_path).await?; | ||
let first_checkpoint = *ingestion_data.keys().next().unwrap(); | ||
let last_checkpoint = *ingestion_data.keys().last().unwrap(); | ||
let num_transactions: usize = ingestion_data.values().map(|c| c.transactions.len()).sum(); | ||
|
||
reset_database(db_config.clone(), false /* do not skip migrations */).await?; | ||
|
||
let indexer_config = IndexerConfig { | ||
ingestion_config: IngestionConfig { | ||
remote_store_url: None, | ||
local_ingestion_path: Some(ingestion_path), | ||
checkpoint_buffer_size: IngestionConfig::DEFAULT_CHECKPOINT_BUFFER_SIZE, | ||
ingest_concurrency: IngestionConfig::DEFAULT_INGEST_CONCURRENCY, | ||
retry_interval: IngestionConfig::default_retry_interval(), | ||
}, | ||
pipeline_config, | ||
first_checkpoint: Some(first_checkpoint), | ||
last_checkpoint: Some(last_checkpoint), | ||
pipeline, | ||
metrics_address: IndexerConfig::default_metrics_address(), | ||
}; | ||
let cur_time = Instant::now(); | ||
start_indexer(indexer_config, db_config, consistency_config, false).await?; | ||
let elapsed = Instant::now().duration_since(cur_time); | ||
println!("Indexed {} transactions in {:?}", num_transactions, elapsed); | ||
println!("TPS: {}", num_transactions as f64 / elapsed.as_secs_f64()); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.