Skip to content

Commit 936acb7

Browse files
committed
Store already computed compile test cases
1 parent ae6786c commit 936acb7

File tree

5 files changed

+32
-10
lines changed

5 files changed

+32
-10
lines changed

Cargo.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

collector/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ anyhow = { workspace = true }
1111
chrono = { workspace = true, features = ["serde"] }
1212
clap = { workspace = true, features = ["derive"] }
1313
env_logger = { workspace = true }
14+
hashbrown = { workspace = true }
1415
log = { workspace = true }
1516
reqwest = { workspace = true, features = ["blocking", "json"] }
1617
serde = { workspace = true, features = ["derive"] }

collector/src/bin/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1819,7 +1819,7 @@ async fn bench_compile(
18191819
tx.conn(),
18201820
benchmark_name,
18211821
&shared.artifact_id,
1822-
collector.artifact_row_id,
1822+
collector,
18231823
config.is_self_profile,
18241824
);
18251825
let result = measure(&mut processor).await;

collector/src/compile/execute/bencher.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use crate::compile::execute::{
1010
};
1111
use crate::toolchain::Toolchain;
1212
use crate::utils::git::get_rustc_perf_commit;
13+
use crate::CollectorCtx;
1314
use anyhow::Context;
1415
use database::CollectionId;
1516
use futures::stream::FuturesUnordered;
@@ -42,7 +43,7 @@ pub struct BenchProcessor<'a> {
4243
benchmark: &'a BenchmarkName,
4344
conn: &'a mut dyn database::Connection,
4445
artifact: &'a database::ArtifactId,
45-
artifact_row_id: database::ArtifactIdNumber,
46+
collector_ctx: &'a CollectorCtx,
4647
is_first_collection: bool,
4748
is_self_profile: bool,
4849
tries: u8,
@@ -54,7 +55,7 @@ impl<'a> BenchProcessor<'a> {
5455
conn: &'a mut dyn database::Connection,
5556
benchmark: &'a BenchmarkName,
5657
artifact: &'a database::ArtifactId,
57-
artifact_row_id: database::ArtifactIdNumber,
58+
collector_ctx: &'a CollectorCtx,
5859
is_self_profile: bool,
5960
) -> Self {
6061
// Check we have `perf` or (`xperf.exe` and `tracelog.exe`) available.
@@ -78,7 +79,7 @@ impl<'a> BenchProcessor<'a> {
7879
conn,
7980
benchmark,
8081
artifact,
81-
artifact_row_id,
82+
collector_ctx,
8283
is_first_collection: true,
8384
is_self_profile,
8485
tries: 0,
@@ -108,7 +109,7 @@ impl<'a> BenchProcessor<'a> {
108109
for (stat, value) in stats.iter() {
109110
buf.push(self.conn.record_statistic(
110111
collection,
111-
self.artifact_row_id,
112+
self.collector_ctx.artifact_row_id,
112113
self.benchmark.0.as_str(),
113114
profile,
114115
scenario,
@@ -123,7 +124,13 @@ impl<'a> BenchProcessor<'a> {
123124
}
124125

125126
pub async fn measure_rustc(&mut self, toolchain: &Toolchain) -> anyhow::Result<()> {
126-
rustc::measure(self.conn, toolchain, self.artifact, self.artifact_row_id).await
127+
rustc::measure(
128+
self.conn,
129+
toolchain,
130+
self.artifact,
131+
self.collector_ctx.artifact_row_id,
132+
)
133+
.await
127134
}
128135
}
129136

@@ -252,7 +259,7 @@ impl Processor for BenchProcessor<'_> {
252259
.map(|profile| {
253260
self.conn.record_raw_self_profile(
254261
profile.collection,
255-
self.artifact_row_id,
262+
self.collector_ctx.artifact_row_id,
256263
self.benchmark.0.as_str(),
257264
profile.profile,
258265
profile.scenario,
@@ -270,7 +277,7 @@ impl Processor for BenchProcessor<'_> {
270277

271278
// FIXME: Record codegen backend in the self profile name
272279
let prefix = PathBuf::from("self-profile")
273-
.join(self.artifact_row_id.0.to_string())
280+
.join(self.collector_ctx.artifact_row_id.0.to_string())
274281
.join(self.benchmark.0.as_str())
275282
.join(profile.profile.to_string())
276283
.join(profile.scenario.to_id());

collector/src/lib.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ pub mod utils;
1717

1818
use crate::compile::benchmark::{Benchmark, BenchmarkName};
1919
use crate::runtime::{BenchmarkGroup, BenchmarkSuite};
20+
use database::selector::CompileTestCase;
2021
use database::{ArtifactId, ArtifactIdNumber, Connection};
22+
use hashbrown::HashSet;
2123
use process::Stdio;
2224
use std::time::{Duration, Instant};
2325

@@ -330,13 +332,24 @@ impl CollectorStepBuilder {
330332
tx.commit().await.unwrap();
331333
artifact_row_id
332334
};
333-
CollectorCtx { artifact_row_id }
335+
// Find out which tests cases were already computed
336+
let measured_compile_test_cases = conn
337+
.get_compile_test_cases_with_measurements(&artifact_row_id)
338+
.await
339+
.expect("cannot fetch measured compile test cases from DB");
340+
341+
CollectorCtx {
342+
artifact_row_id,
343+
measured_compile_test_cases,
344+
}
334345
}
335346
}
336347

337348
/// Represents an in-progress run for a given artifact.
338349
pub struct CollectorCtx {
339350
pub artifact_row_id: ArtifactIdNumber,
351+
/// Which tests cases were already computed **before** this collection began?
352+
pub measured_compile_test_cases: HashSet<CompileTestCase>,
340353
}
341354

342355
impl CollectorCtx {

0 commit comments

Comments
 (0)