Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions collector/src/bin/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ impl RuntimeBenchmarkConfig {
struct SharedBenchmarkConfig {
artifact_id: ArtifactId,
toolchain: Toolchain,
record_duration: bool,
job_id: Option<u32>,
}

Expand Down Expand Up @@ -854,7 +853,6 @@ fn main_result() -> anyhow::Result<i32> {
let shared = SharedBenchmarkConfig {
artifact_id,
toolchain,
record_duration: true,
job_id: None,
};
let config = RuntimeBenchmarkConfig::new(
Expand Down Expand Up @@ -998,7 +996,6 @@ fn main_result() -> anyhow::Result<i32> {
let shared = SharedBenchmarkConfig {
toolchain,
artifact_id,
record_duration: true,
job_id: None,
};
let config = CompileBenchmarkConfig {
Expand Down Expand Up @@ -1152,7 +1149,6 @@ fn main_result() -> anyhow::Result<i32> {
let shared = SharedBenchmarkConfig {
artifact_id,
toolchain,
record_duration: true,
job_id: None,
};

Expand Down Expand Up @@ -1672,7 +1668,6 @@ async fn run_benchmark_job(
let shared = SharedBenchmarkConfig {
artifact_id,
toolchain,
record_duration: false,
job_id: Some(job.id()),
};

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -2174,15 +2169,14 @@ async fn run_benchmarks(
&collector,
runtime.filter,
runtime.iterations,
shared.job_id,
)
.await
.context("Runtime benchmarks failed")
} else {
Ok(())
};

if shared.record_duration {
if shared.job_id.is_none() {
let end = start.elapsed();
connection
.record_duration(collector.artifact_row_id, end)
Expand Down Expand Up @@ -2230,7 +2224,6 @@ async fn bench_published_artifact(
let shared = SharedBenchmarkConfig {
artifact_id,
toolchain,
record_duration: true,
job_id: None,
};
run_benchmarks(
Expand Down
50 changes: 38 additions & 12 deletions collector/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,17 @@ pub async fn master_commits() -> anyhow::Result<Vec<MasterCommit>> {
#[derive(Default)]
pub struct CollectorStepBuilder {
steps: Vec<String>,
job_id: Option<u32>,
}

impl CollectorStepBuilder {
pub fn new(job_id: Option<u32>) -> Self {
Self {
steps: vec![],
job_id,
}
}

pub fn record_compile_benchmarks(
mut self,
benchmarks: &[Benchmark],
Expand Down Expand Up @@ -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
};
Expand All @@ -353,6 +363,7 @@ impl CollectorStepBuilder {
CollectorCtx {
artifact_row_id,
measured_compile_test_cases,
job_id: self.job_id,
}
}
}
Expand All @@ -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<CompileTestCase>,
pub job_id: Option<u32>,
}

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.
Expand All @@ -384,14 +404,20 @@ impl CollectorCtx {
group: &BenchmarkGroup,
) -> Option<String> {
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;
}
}
}

Expand Down
3 changes: 1 addition & 2 deletions collector/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ pub async fn bench_runtime(
collector: &CollectorCtx,
filter: RuntimeBenchmarkFilter,
iterations: u32,
job_id: Option<u32>,
) -> anyhow::Result<()> {
let filtered = suite.filtered_benchmark_count(&filter);
println!("Executing {filtered} benchmarks\n");
Expand Down Expand Up @@ -94,7 +93,7 @@ pub async fn bench_runtime(
collector.artifact_row_id,
&step_name,
&format!("{error:?}"),
job_id,
collector.job_id,
)
.await;
};
Expand Down
Loading