diff --git a/bin/reth-bench/src/bench/gas_limit_ramp.rs b/bin/reth-bench/src/bench/gas_limit_ramp.rs index 5be391bf7f..d960e9cf68 100644 --- a/bin/reth-bench/src/bench/gas_limit_ramp.rs +++ b/bin/reth-bench/src/bench/gas_limit_ramp.rs @@ -192,6 +192,15 @@ impl Command { parent_header = block.header; parent_hash = block_hash; blocks_processed += 1; + + let progress = match mode { + RampMode::Blocks(total) => format!("{blocks_processed}/{total}"), + RampMode::TargetGasLimit(target) => { + let pct = (parent_header.gas_limit as f64 / target as f64 * 100.0).min(100.0); + format!("{pct:.1}%") + } + }; + info!(target: "reth-bench", progress, block_number = parent_header.number, gas_limit = parent_header.gas_limit, "Block processed"); } let final_gas_limit = parent_header.gas_limit; diff --git a/bin/reth-bench/src/bench/new_payload_fcu.rs b/bin/reth-bench/src/bench/new_payload_fcu.rs index fa10034b70..202fe12874 100644 --- a/bin/reth-bench/src/bench/new_payload_fcu.rs +++ b/bin/reth-bench/src/bench/new_payload_fcu.rs @@ -153,6 +153,7 @@ impl Command { .. } = BenchContext::new(&self.benchmark, self.rpc_url).await?; + let total_blocks = benchmark_mode.total_blocks(); let buffer_size = self.rpc_block_buffer_size; // Use a oneshot channel to propagate errors from the spawned task @@ -206,6 +207,7 @@ impl Command { }); let mut results = Vec::new(); + let mut blocks_processed = 0u64; let total_benchmark_duration = Instant::now(); let mut total_wait_time = Duration::ZERO; @@ -249,8 +251,13 @@ impl Command { // Exclude time spent waiting on the block prefetch channel from the benchmark duration. // We want to measure engine throughput, not RPC fetch latency. + blocks_processed += 1; let current_duration = total_benchmark_duration.elapsed() - total_wait_time; - info!(target: "reth-bench", %combined_result); + let progress = match total_blocks { + Some(total) => format!("{blocks_processed}/{total}"), + None => format!("{blocks_processed}"), + }; + info!(target: "reth-bench", progress, %combined_result); if let Some(w) = &mut waiter { w.on_block(block_number).await?; diff --git a/bin/reth-bench/src/bench/new_payload_only.rs b/bin/reth-bench/src/bench/new_payload_only.rs index e27321702a..fd5cf86281 100644 --- a/bin/reth-bench/src/bench/new_payload_only.rs +++ b/bin/reth-bench/src/bench/new_payload_only.rs @@ -52,6 +52,7 @@ impl Command { .. } = BenchContext::new(&self.benchmark, self.rpc_url).await?; + let total_blocks = benchmark_mode.total_blocks(); let buffer_size = self.rpc_block_buffer_size; // Use a oneshot channel to propagate errors from the spawned task @@ -82,8 +83,8 @@ impl Command { } }); - // put results in a summary vec so they can be printed at the end let mut results = Vec::new(); + let mut blocks_processed = 0u64; let total_benchmark_duration = Instant::now(); let mut total_wait_time = Duration::ZERO; @@ -105,7 +106,12 @@ impl Command { call_new_payload(&auth_provider, version, params).await?; let new_payload_result = NewPayloadResult { gas_used, latency: start.elapsed() }; - info!(target: "reth-bench", %new_payload_result); + blocks_processed += 1; + let progress = match total_blocks { + Some(total) => format!("{blocks_processed}/{total}"), + None => format!("{blocks_processed}"), + }; + info!(target: "reth-bench", progress, %new_payload_result); // current duration since the start of the benchmark minus the time // waiting for blocks diff --git a/bin/reth-bench/src/bench/replay_payloads.rs b/bin/reth-bench/src/bench/replay_payloads.rs index 4f50441088..df55bef498 100644 --- a/bin/reth-bench/src/bench/replay_payloads.rs +++ b/bin/reth-bench/src/bench/replay_payloads.rs @@ -341,7 +341,8 @@ impl Command { }; let current_duration = total_benchmark_duration.elapsed(); - info!(target: "reth-bench", %combined_result); + let progress = format!("{}/{}", i + 1, payloads.len()); + info!(target: "reth-bench", progress, %combined_result); if let Some(w) = &mut waiter { w.on_block(block_number).await?; diff --git a/bin/reth-bench/src/bench_mode.rs b/bin/reth-bench/src/bench_mode.rs index 06343415e2..f4ee31e0f0 100644 --- a/bin/reth-bench/src/bench_mode.rs +++ b/bin/reth-bench/src/bench_mode.rs @@ -20,6 +20,19 @@ impl BenchMode { } } + /// Returns the total number of blocks in the benchmark, if known. + /// + /// For [`BenchMode::Range`] this is the length of the range. + /// For [`BenchMode::Continuous`] the total is unbounded, so `None` is returned. + pub const fn total_blocks(&self) -> Option { + match self { + Self::Continuous(_) => None, + Self::Range(range) => { + Some(range.end().saturating_sub(*range.start()).saturating_add(1)) + } + } + } + /// Create a [`BenchMode`] from optional `from` and `to` fields. pub fn new(from: Option, to: Option, latest_block: u64) -> Result { // If neither `--from` nor `--to` are provided, we will run the benchmark continuously,