Skip to content

Commit e9355ca

Browse files
authored
feat(reth-bench-compare): add reth command to summary output (#20089)
1 parent fdd9d5b commit e9355ca

File tree

3 files changed

+41
-7
lines changed

3 files changed

+41
-7
lines changed

bin/reth-bench-compare/src/cli.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,8 @@ async fn run_warmup_phase(
506506
// Build additional args with conditional --debug.startup-sync-state-idle flag
507507
let additional_args = args.build_additional_args("warmup", args.baseline_args.as_ref());
508508

509-
// Start reth node for warmup
510-
let mut node_process =
509+
// Start reth node for warmup (command is not stored for warmup phase)
510+
let (mut node_process, _warmup_command) =
511511
node_manager.start_node(&binary_path, warmup_ref, "warmup", &additional_args).await?;
512512

513513
// Wait for node to be ready and get its current tip
@@ -607,8 +607,8 @@ async fn run_benchmark_workflow(
607607
// Build additional args with conditional --debug.startup-sync-state-idle flag
608608
let additional_args = args.build_additional_args(ref_type, base_args_str);
609609

610-
// Start reth node
611-
let mut node_process =
610+
// Start reth node and capture the command for reporting
611+
let (mut node_process, reth_command) =
612612
node_manager.start_node(&binary_path, git_ref, ref_type, &additional_args).await?;
613613

614614
// Wait for node to be ready and get its current tip (wherever it is)
@@ -645,8 +645,9 @@ async fn run_benchmark_workflow(
645645
// Store results for comparison
646646
comparison_generator.add_ref_results(ref_type, &output_dir)?;
647647

648-
// Set the benchmark run timestamps
648+
// Set the benchmark run timestamps and reth command
649649
comparison_generator.set_ref_timestamps(ref_type, benchmark_start, benchmark_end)?;
650+
comparison_generator.set_ref_command(ref_type, reth_command)?;
650651

651652
info!("Completed {} reference benchmark", ref_type);
652653
}

bin/reth-bench-compare/src/comparison.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ pub(crate) struct ComparisonGenerator {
2121
feature_ref_name: String,
2222
baseline_results: Option<BenchmarkResults>,
2323
feature_results: Option<BenchmarkResults>,
24+
baseline_command: Option<String>,
25+
feature_command: Option<String>,
2426
}
2527

2628
/// Represents the results from a single benchmark run
@@ -89,6 +91,7 @@ pub(crate) struct RefInfo {
8991
pub summary: BenchmarkSummary,
9092
pub start_timestamp: Option<DateTime<Utc>>,
9193
pub end_timestamp: Option<DateTime<Utc>>,
94+
pub reth_command: Option<String>,
9295
}
9396

9497
/// Summary of the comparison between references.
@@ -142,6 +145,8 @@ impl ComparisonGenerator {
142145
feature_ref_name: args.feature_ref.clone(),
143146
baseline_results: None,
144147
feature_results: None,
148+
baseline_command: None,
149+
feature_command: None,
145150
}
146151
}
147152

@@ -206,6 +211,21 @@ impl ComparisonGenerator {
206211
Ok(())
207212
}
208213

214+
/// Set the reth command for a reference
215+
pub(crate) fn set_ref_command(&mut self, ref_type: &str, command: String) -> Result<()> {
216+
match ref_type {
217+
"baseline" => {
218+
self.baseline_command = Some(command);
219+
}
220+
"feature" => {
221+
self.feature_command = Some(command);
222+
}
223+
_ => return Err(eyre!("Unknown reference type: {}", ref_type)),
224+
}
225+
226+
Ok(())
227+
}
228+
209229
/// Generate the final comparison report
210230
pub(crate) async fn generate_comparison_report(&self) -> Result<()> {
211231
info!("Generating comparison report...");
@@ -230,12 +250,14 @@ impl ComparisonGenerator {
230250
summary: baseline.summary.clone(),
231251
start_timestamp: baseline.start_timestamp,
232252
end_timestamp: baseline.end_timestamp,
253+
reth_command: self.baseline_command.clone(),
233254
},
234255
feature: RefInfo {
235256
ref_name: feature.ref_name.clone(),
236257
summary: feature.summary.clone(),
237258
start_timestamp: feature.start_timestamp,
238259
end_timestamp: feature.end_timestamp,
260+
reth_command: self.feature_command.clone(),
239261
},
240262
comparison_summary,
241263
per_block_comparisons,
@@ -599,6 +621,9 @@ impl ComparisonGenerator {
599621
end.format("%Y-%m-%d %H:%M:%S UTC")
600622
);
601623
}
624+
if let Some(ref cmd) = report.baseline.reth_command {
625+
println!(" Command: {}", cmd);
626+
}
602627
println!();
603628

604629
println!("Feature Summary:");
@@ -628,6 +653,9 @@ impl ComparisonGenerator {
628653
end.format("%Y-%m-%d %H:%M:%S UTC")
629654
);
630655
}
656+
if let Some(ref cmd) = report.feature.reth_command {
657+
println!(" Command: {}", cmd);
658+
}
631659
println!();
632660
}
633661
}

bin/reth-bench-compare/src/node.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,19 +240,24 @@ impl NodeManager {
240240
}
241241

242242
/// Start a reth node using the specified binary path and return the process handle
243+
/// along with the formatted reth command string for reporting.
243244
pub(crate) async fn start_node(
244245
&mut self,
245246
binary_path: &std::path::Path,
246247
_git_ref: &str,
247248
ref_type: &str,
248249
additional_args: &[String],
249-
) -> Result<tokio::process::Child> {
250+
) -> Result<(tokio::process::Child, String)> {
250251
// Store the binary path for later use (e.g., in unwind_to_block)
251252
self.binary_path = Some(binary_path.to_path_buf());
252253

253254
let binary_path_str = binary_path.to_string_lossy();
254255
let (reth_args, _) = self.build_reth_args(&binary_path_str, additional_args, ref_type);
255256

257+
// Format the reth command string for reporting
258+
let reth_command = shlex::try_join(reth_args.iter().map(|s| s.as_str()))
259+
.wrap_err("Failed to format reth command string")?;
260+
256261
// Log additional arguments if any
257262
if !self.additional_reth_args.is_empty() {
258263
info!("Using common additional reth arguments: {:?}", self.additional_reth_args);
@@ -346,7 +351,7 @@ impl NodeManager {
346351
// Give the node a moment to start up
347352
sleep(Duration::from_secs(5)).await;
348353

349-
Ok(child)
354+
Ok((child, reth_command))
350355
}
351356

352357
/// Wait for the node to be ready and return its current tip

0 commit comments

Comments
 (0)