diff --git a/collector/src/bin/collector.rs b/collector/src/bin/collector.rs index 8c59da293..c8e838a23 100644 --- a/collector/src/bin/collector.rs +++ b/collector/src/bin/collector.rs @@ -136,7 +136,6 @@ impl RuntimeBenchmarkConfig { struct SharedBenchmarkConfig { artifact_id: ArtifactId, toolchain: Toolchain, - record_duration: bool, job_id: Option, } @@ -854,7 +853,6 @@ fn main_result() -> anyhow::Result { let shared = SharedBenchmarkConfig { artifact_id, toolchain, - record_duration: true, job_id: None, }; let config = RuntimeBenchmarkConfig::new( @@ -998,7 +996,6 @@ fn main_result() -> anyhow::Result { let shared = SharedBenchmarkConfig { toolchain, artifact_id, - record_duration: true, job_id: None, }; let config = CompileBenchmarkConfig { @@ -1152,7 +1149,6 @@ fn main_result() -> anyhow::Result { let shared = SharedBenchmarkConfig { artifact_id, toolchain, - record_duration: true, job_id: None, }; @@ -1672,7 +1668,6 @@ async fn run_benchmark_job( let shared = SharedBenchmarkConfig { artifact_id, toolchain, - record_duration: false, job_id: Some(job.id()), }; @@ -2131,7 +2126,7 @@ async fn init_collection( runtime: Option<&RuntimeBenchmarkConfig>, ) -> CollectorCtx { assert!(runtime.is_some() || compile.is_some()); - let mut builder = CollectorStepBuilder::default(); + let mut builder = CollectorStepBuilder::new(shared.job_id); if let Some(compile) = compile { builder = builder.record_compile_benchmarks(&compile.benchmarks, compile.bench_rustc); } @@ -2174,7 +2169,6 @@ async fn run_benchmarks( &collector, runtime.filter, runtime.iterations, - shared.job_id, ) .await .context("Runtime benchmarks failed") @@ -2182,7 +2176,7 @@ async fn run_benchmarks( Ok(()) }; - if shared.record_duration { + if shared.job_id.is_none() { let end = start.elapsed(); connection .record_duration(collector.artifact_row_id, end) @@ -2230,7 +2224,6 @@ async fn bench_published_artifact( let shared = SharedBenchmarkConfig { artifact_id, toolchain, - record_duration: true, job_id: None, }; run_benchmarks( diff --git a/collector/src/lib.rs b/collector/src/lib.rs index b2feac39a..dbee618a5 100644 --- a/collector/src/lib.rs +++ b/collector/src/lib.rs @@ -302,9 +302,17 @@ pub async fn master_commits() -> anyhow::Result> { #[derive(Default)] pub struct CollectorStepBuilder { steps: Vec, + job_id: Option, } impl CollectorStepBuilder { + pub fn new(job_id: Option) -> Self { + Self { + steps: vec![], + job_id, + } + } + pub fn record_compile_benchmarks( mut self, benchmarks: &[Benchmark], @@ -338,9 +346,11 @@ impl CollectorStepBuilder { let artifact_row_id = { let mut tx = conn.transaction().await; let artifact_row_id = tx.conn().artifact_id(artifact_id).await; - tx.conn() - .collector_start(artifact_row_id, &self.steps) - .await; + if self.job_id.is_none() { + tx.conn() + .collector_start(artifact_row_id, &self.steps) + .await; + } tx.commit().await.unwrap(); artifact_row_id }; @@ -353,6 +363,7 @@ impl CollectorStepBuilder { CollectorCtx { artifact_row_id, measured_compile_test_cases, + job_id: self.job_id, } } } @@ -362,17 +373,26 @@ pub struct CollectorCtx { pub artifact_row_id: ArtifactIdNumber, /// Which tests cases were already computed **before** this collection began? pub measured_compile_test_cases: HashSet, + pub job_id: Option, } impl CollectorCtx { + pub fn is_from_job_queue(&self) -> bool { + self.job_id.is_some() + } + pub async fn start_compile_step(&self, conn: &dyn Connection, benchmark_name: &BenchmarkName) { - conn.collector_start_step(self.artifact_row_id, &benchmark_name.0) - .await; + if !self.is_from_job_queue() { + conn.collector_start_step(self.artifact_row_id, &benchmark_name.0) + .await; + } } pub async fn end_compile_step(&self, conn: &dyn Connection, benchmark_name: &BenchmarkName) { - conn.collector_end_step(self.artifact_row_id, &benchmark_name.0) - .await + if !self.is_from_job_queue() { + conn.collector_end_step(self.artifact_row_id, &benchmark_name.0) + .await; + } } /// Starts a new runtime benchmark collector step. @@ -384,14 +404,20 @@ impl CollectorCtx { group: &BenchmarkGroup, ) -> Option { let step_name = runtime_group_step_name(&group.name); - conn.collector_start_step(self.artifact_row_id, &step_name) - .await - .then_some(step_name) + if self.is_from_job_queue() { + Some(step_name) + } else { + conn.collector_start_step(self.artifact_row_id, &step_name) + .await + .then_some(step_name) + } } pub async fn end_runtime_step(&self, conn: &dyn Connection, group: &BenchmarkGroup) { - conn.collector_end_step(self.artifact_row_id, &runtime_group_step_name(&group.name)) - .await + if !self.is_from_job_queue() { + conn.collector_end_step(self.artifact_row_id, &runtime_group_step_name(&group.name)) + .await; + } } } diff --git a/collector/src/runtime/mod.rs b/collector/src/runtime/mod.rs index d08d3a8ac..94b4a7335 100644 --- a/collector/src/runtime/mod.rs +++ b/collector/src/runtime/mod.rs @@ -35,7 +35,6 @@ pub async fn bench_runtime( collector: &CollectorCtx, filter: RuntimeBenchmarkFilter, iterations: u32, - job_id: Option, ) -> anyhow::Result<()> { let filtered = suite.filtered_benchmark_count(&filter); println!("Executing {filtered} benchmarks\n"); @@ -94,7 +93,7 @@ pub async fn bench_runtime( collector.artifact_row_id, &step_name, &format!("{error:?}"), - job_id, + collector.job_id, ) .await; };