diff --git a/bin/reth-bench-compare/src/cli.rs b/bin/reth-bench-compare/src/cli.rs index 89d3d874cd..460d536e3a 100644 --- a/bin/reth-bench-compare/src/cli.rs +++ b/bin/reth-bench-compare/src/cli.rs @@ -506,8 +506,8 @@ async fn run_warmup_phase( // Build additional args with conditional --debug.startup-sync-state-idle flag let additional_args = args.build_additional_args("warmup", args.baseline_args.as_ref()); - // Start reth node for warmup - let mut node_process = + // Start reth node for warmup (command is not stored for warmup phase) + let (mut node_process, _warmup_command) = node_manager.start_node(&binary_path, warmup_ref, "warmup", &additional_args).await?; // Wait for node to be ready and get its current tip @@ -607,8 +607,8 @@ async fn run_benchmark_workflow( // Build additional args with conditional --debug.startup-sync-state-idle flag let additional_args = args.build_additional_args(ref_type, base_args_str); - // Start reth node - let mut node_process = + // Start reth node and capture the command for reporting + let (mut node_process, reth_command) = node_manager.start_node(&binary_path, git_ref, ref_type, &additional_args).await?; // Wait for node to be ready and get its current tip (wherever it is) @@ -645,8 +645,9 @@ async fn run_benchmark_workflow( // Store results for comparison comparison_generator.add_ref_results(ref_type, &output_dir)?; - // Set the benchmark run timestamps + // Set the benchmark run timestamps and reth command comparison_generator.set_ref_timestamps(ref_type, benchmark_start, benchmark_end)?; + comparison_generator.set_ref_command(ref_type, reth_command)?; info!("Completed {} reference benchmark", ref_type); } diff --git a/bin/reth-bench-compare/src/comparison.rs b/bin/reth-bench-compare/src/comparison.rs index 544d17dd84..087ccaf3ce 100644 --- a/bin/reth-bench-compare/src/comparison.rs +++ b/bin/reth-bench-compare/src/comparison.rs @@ -21,6 +21,8 @@ pub(crate) struct ComparisonGenerator { feature_ref_name: String, baseline_results: Option, feature_results: Option, + baseline_command: Option, + feature_command: Option, } /// Represents the results from a single benchmark run @@ -89,6 +91,7 @@ pub(crate) struct RefInfo { pub summary: BenchmarkSummary, pub start_timestamp: Option>, pub end_timestamp: Option>, + pub reth_command: Option, } /// Summary of the comparison between references. @@ -142,6 +145,8 @@ impl ComparisonGenerator { feature_ref_name: args.feature_ref.clone(), baseline_results: None, feature_results: None, + baseline_command: None, + feature_command: None, } } @@ -206,6 +211,21 @@ impl ComparisonGenerator { Ok(()) } + /// Set the reth command for a reference + pub(crate) fn set_ref_command(&mut self, ref_type: &str, command: String) -> Result<()> { + match ref_type { + "baseline" => { + self.baseline_command = Some(command); + } + "feature" => { + self.feature_command = Some(command); + } + _ => return Err(eyre!("Unknown reference type: {}", ref_type)), + } + + Ok(()) + } + /// Generate the final comparison report pub(crate) async fn generate_comparison_report(&self) -> Result<()> { info!("Generating comparison report..."); @@ -230,12 +250,14 @@ impl ComparisonGenerator { summary: baseline.summary.clone(), start_timestamp: baseline.start_timestamp, end_timestamp: baseline.end_timestamp, + reth_command: self.baseline_command.clone(), }, feature: RefInfo { ref_name: feature.ref_name.clone(), summary: feature.summary.clone(), start_timestamp: feature.start_timestamp, end_timestamp: feature.end_timestamp, + reth_command: self.feature_command.clone(), }, comparison_summary, per_block_comparisons, @@ -599,6 +621,9 @@ impl ComparisonGenerator { end.format("%Y-%m-%d %H:%M:%S UTC") ); } + if let Some(ref cmd) = report.baseline.reth_command { + println!(" Command: {}", cmd); + } println!(); println!("Feature Summary:"); @@ -628,6 +653,9 @@ impl ComparisonGenerator { end.format("%Y-%m-%d %H:%M:%S UTC") ); } + if let Some(ref cmd) = report.feature.reth_command { + println!(" Command: {}", cmd); + } println!(); } } diff --git a/bin/reth-bench-compare/src/node.rs b/bin/reth-bench-compare/src/node.rs index fab3e20db5..4de48eebf4 100644 --- a/bin/reth-bench-compare/src/node.rs +++ b/bin/reth-bench-compare/src/node.rs @@ -240,19 +240,24 @@ impl NodeManager { } /// Start a reth node using the specified binary path and return the process handle + /// along with the formatted reth command string for reporting. pub(crate) async fn start_node( &mut self, binary_path: &std::path::Path, _git_ref: &str, ref_type: &str, additional_args: &[String], - ) -> Result { + ) -> Result<(tokio::process::Child, String)> { // Store the binary path for later use (e.g., in unwind_to_block) self.binary_path = Some(binary_path.to_path_buf()); let binary_path_str = binary_path.to_string_lossy(); let (reth_args, _) = self.build_reth_args(&binary_path_str, additional_args, ref_type); + // Format the reth command string for reporting + let reth_command = shlex::try_join(reth_args.iter().map(|s| s.as_str())) + .wrap_err("Failed to format reth command string")?; + // Log additional arguments if any if !self.additional_reth_args.is_empty() { info!("Using common additional reth arguments: {:?}", self.additional_reth_args); @@ -346,7 +351,7 @@ impl NodeManager { // Give the node a moment to start up sleep(Duration::from_secs(5)).await; - Ok(child) + Ok((child, reth_command)) } /// Wait for the node to be ready and return its current tip