Skip to content

Commit bc68213

Browse files
committed
Add compiler_target column, defaulting to x86_64-unknown-linux-gnu
1 parent f9123e1 commit bc68213

File tree

12 files changed

+109
-37
lines changed

12 files changed

+109
-37
lines changed

collector/src/bin/collector.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use collector::artifact_stats::{
3535
use collector::codegen::{codegen_diff, CodegenType};
3636
use collector::compile::benchmark::category::Category;
3737
use collector::compile::benchmark::codegen_backend::CodegenBackend;
38+
use collector::compile::benchmark::compiler_target::CompilerTarget;
3839
use collector::compile::benchmark::profile::Profile;
3940
use collector::compile::benchmark::scenario::Scenario;
4041
use collector::compile::benchmark::{
@@ -99,6 +100,7 @@ struct CompileBenchmarkConfig {
99100
iterations: Option<usize>,
100101
is_self_profile: bool,
101102
bench_rustc: bool,
103+
compiler_targets: Vec<CompilerTarget>,
102104
}
103105

104106
struct RuntimeBenchmarkConfig {
@@ -200,6 +202,7 @@ fn profile_compile(
200202
scenarios: &[Scenario],
201203
backends: &[CodegenBackend],
202204
errors: &mut BenchmarkErrors,
205+
compiler_targets: &[CompilerTarget]
203206
) {
204207
eprintln!("Profiling {} with {:?}", toolchain.id, profiler);
205208
if let Profiler::SelfProfile = profiler {
@@ -220,6 +223,7 @@ fn profile_compile(
220223
backends,
221224
toolchain,
222225
Some(1),
226+
compiler_targets,
223227
));
224228
eprintln!("Finished benchmark {benchmark_id}");
225229

@@ -910,6 +914,7 @@ fn main_result() -> anyhow::Result<i32> {
910914
iterations: Some(iterations),
911915
is_self_profile: self_profile.self_profile,
912916
bench_rustc: bench_rustc.bench_rustc,
917+
compiler_targets: vec![CompilerTarget::default()],
913918
};
914919

915920
run_benchmarks(&mut rt, conn, shared, Some(config), None)?;
@@ -1024,6 +1029,7 @@ fn main_result() -> anyhow::Result<i32> {
10241029
iterations: runs.map(|v| v as usize),
10251030
is_self_profile: self_profile.self_profile,
10261031
bench_rustc: bench_rustc.bench_rustc,
1032+
compiler_targets: vec![CompilerTarget::default()],
10271033
};
10281034
let runtime_suite = rt.block_on(load_runtime_benchmarks(
10291035
conn.as_mut(),
@@ -1136,6 +1142,7 @@ fn main_result() -> anyhow::Result<i32> {
11361142
scenarios,
11371143
backends,
11381144
&mut errors,
1145+
&[CompilerTarget::default()],
11391146
);
11401147
Ok(id)
11411148
};
@@ -1734,6 +1741,7 @@ fn bench_published_artifact(
17341741
iterations: Some(3),
17351742
is_self_profile: false,
17361743
bench_rustc: false,
1744+
compiler_targets: vec![CompilerTarget::default()],
17371745
}),
17381746
Some(RuntimeBenchmarkConfig::new(
17391747
runtime_suite,
@@ -1834,6 +1842,7 @@ fn bench_compile(
18341842
&config.backends,
18351843
&shared.toolchain,
18361844
config.iterations,
1845+
&config.compiler_targets,
18371846
)))
18381847
.with_context(|| anyhow::anyhow!("Cannot compile {}", benchmark.name))
18391848
},
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#[derive(Clone, Debug, Eq, Hash, PartialEq, serde::Deserialize)]
2+
pub struct CompilerTarget(pub String);
3+
4+
impl Default for CompilerTarget {
5+
fn default() -> Self {
6+
return Self("x86_64-unknown-linux-gnu".to_string())
7+
}
8+
}

collector/src/compile/benchmark/mod.rs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::compile::benchmark::codegen_backend::CodegenBackend;
33
use crate::compile::benchmark::patch::Patch;
44
use crate::compile::benchmark::profile::Profile;
55
use crate::compile::benchmark::scenario::Scenario;
6+
use crate::compile::benchmark::compiler_target::CompilerTarget;
67
use crate::compile::execute::{CargoProcess, Processor};
78
use crate::toolchain::Toolchain;
89
use crate::utils::wait_for_future;
@@ -20,6 +21,7 @@ pub mod codegen_backend;
2021
pub(crate) mod patch;
2122
pub mod profile;
2223
pub mod scenario;
24+
pub mod compiler_target;
2325

2426
fn default_runs() -> usize {
2527
3
@@ -180,6 +182,7 @@ impl Benchmark {
180182
cwd: &'a Path,
181183
profile: Profile,
182184
backend: CodegenBackend,
185+
compiler_target: &'a CompilerTarget,
183186
) -> CargoProcess<'a> {
184187
let mut cargo_args = self
185188
.config
@@ -220,6 +223,7 @@ impl Benchmark {
220223
.collect(),
221224
touch_file: self.config.touch_file.clone(),
222225
jobserver: None,
226+
compiler_target,
223227
}
224228
}
225229

@@ -232,6 +236,7 @@ impl Benchmark {
232236
backends: &[CodegenBackend],
233237
toolchain: &Toolchain,
234238
iterations: Option<usize>,
239+
compiler_targets: &[CompilerTarget]
235240
) -> anyhow::Result<()> {
236241
if self.config.disabled {
237242
eprintln!("Skipping {}: disabled", self.name);
@@ -263,10 +268,12 @@ impl Benchmark {
263268
}
264269

265270
eprintln!("Preparing {}", self.name);
266-
let mut target_dirs: Vec<((CodegenBackend, Profile), TempDir)> = vec![];
271+
let mut target_dirs: Vec<((CodegenBackend, Profile, &CompilerTarget), TempDir)> = vec![];
267272
for backend in backends {
268273
for profile in &profiles {
269-
target_dirs.push(((*backend, *profile), self.make_temp_dir(&self.path)?));
274+
for compiler_target in compiler_targets {
275+
target_dirs.push(((*backend, *profile, &compiler_target), self.make_temp_dir(&self.path)?));
276+
}
270277
}
271278
}
272279

@@ -304,12 +311,12 @@ impl Benchmark {
304311
)
305312
.context("jobserver::new")?;
306313
let mut threads = Vec::with_capacity(target_dirs.len());
307-
for ((backend, profile), prep_dir) in &target_dirs {
314+
for ((backend, profile, compiler_target), prep_dir) in &target_dirs {
308315
let server = server.clone();
309316
let thread = s.spawn::<_, anyhow::Result<()>>(move || {
310317
wait_for_future(async move {
311318
let server = server.clone();
312-
self.mk_cargo_process(toolchain, prep_dir.path(), *profile, *backend)
319+
self.mk_cargo_process(toolchain, prep_dir.path(), *profile, *backend, compiler_target)
313320
.jobserver(server)
314321
.run_rustc(false)
315322
.await?;
@@ -343,12 +350,13 @@ impl Benchmark {
343350
let mut timing_dirs: Vec<ManuallyDrop<TempDir>> = vec![];
344351

345352
let benchmark_start = std::time::Instant::now();
346-
for ((backend, profile), prep_dir) in &target_dirs {
353+
for ((backend, profile, compiler_target), prep_dir) in &target_dirs {
347354
let backend = *backend;
348355
let profile = *profile;
356+
let compiler_target = *compiler_target;
349357
eprintln!(
350-
"Running {}: {:?} + {:?} + {:?}",
351-
self.name, profile, scenarios, backend
358+
"Running {}: {:?} + {:?} + {:?} + {:?}",
359+
self.name, profile, scenarios, backend, compiler_target,
352360
);
353361

354362
// We want at least two runs for all benchmarks (since we run
@@ -370,7 +378,7 @@ impl Benchmark {
370378

371379
// A full non-incremental build.
372380
if scenarios.contains(&Scenario::Full) {
373-
self.mk_cargo_process(toolchain, cwd, profile, backend)
381+
self.mk_cargo_process(toolchain, cwd, profile, backend, &compiler_target)
374382
.processor(processor, Scenario::Full, "Full", None)
375383
.run_rustc(true)
376384
.await?;
@@ -381,7 +389,7 @@ impl Benchmark {
381389
// An incremental from scratch (slowest incremental case).
382390
// This is required for any subsequent incremental builds.
383391
if scenarios.iter().any(|s| s.is_incr()) {
384-
self.mk_cargo_process(toolchain, cwd, profile, backend)
392+
self.mk_cargo_process(toolchain, cwd, profile, backend, &compiler_target)
385393
.incremental(true)
386394
.processor(processor, Scenario::IncrFull, "IncrFull", None)
387395
.run_rustc(true)
@@ -390,7 +398,7 @@ impl Benchmark {
390398

391399
// An incremental build with no changes (fastest incremental case).
392400
if scenarios.contains(&Scenario::IncrUnchanged) {
393-
self.mk_cargo_process(toolchain, cwd, profile, backend)
401+
self.mk_cargo_process(toolchain, cwd, profile, backend, &compiler_target)
394402
.incremental(true)
395403
.processor(processor, Scenario::IncrUnchanged, "IncrUnchanged", None)
396404
.run_rustc(true)
@@ -405,7 +413,7 @@ impl Benchmark {
405413
// An incremental build with some changes (realistic
406414
// incremental case).
407415
let scenario_str = format!("IncrPatched{}", i);
408-
self.mk_cargo_process(toolchain, cwd, profile, backend)
416+
self.mk_cargo_process(toolchain, cwd, profile, backend, &compiler_target)
409417
.incremental(true)
410418
.processor(
411419
processor,

collector/src/compile/execute/bencher.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::compile::benchmark::codegen_backend::CodegenBackend;
22
use crate::compile::benchmark::profile::Profile;
33
use crate::compile::benchmark::scenario::Scenario;
4+
use crate::compile::benchmark::compiler_target::CompilerTarget;
45
use crate::compile::benchmark::BenchmarkName;
56
use crate::compile::execute;
67
use crate::compile::execute::{
@@ -91,6 +92,7 @@ impl<'a> BenchProcessor<'a> {
9192
scenario: database::Scenario,
9293
profile: database::Profile,
9394
backend: CodegenBackend,
95+
compiler_target: &CompilerTarget,
9496
stats: Stats,
9597
) {
9698
let backend = match backend {
@@ -109,6 +111,7 @@ impl<'a> BenchProcessor<'a> {
109111
backend,
110112
stat,
111113
value,
114+
&compiler_target.0,
112115
));
113116
}
114117

@@ -199,7 +202,7 @@ impl Processor for BenchProcessor<'_> {
199202
res.0.stats.retain(|key, _| key.starts_with("size:"));
200203
}
201204

202-
self.insert_stats(collection, scenario, profile, data.backend, res.0)
205+
self.insert_stats(collection, scenario, profile, data.backend, data.compiler_target, res.0)
203206
.await;
204207

205208
Ok(Retry::No)

collector/src/compile/execute/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::compile::benchmark::codegen_backend::CodegenBackend;
44
use crate::compile::benchmark::patch::Patch;
55
use crate::compile::benchmark::profile::Profile;
66
use crate::compile::benchmark::scenario::Scenario;
7+
use crate::compile::benchmark::compiler_target::CompilerTarget;
78
use crate::compile::benchmark::BenchmarkName;
89
use crate::toolchain::Toolchain;
910
use crate::utils::fs::EnsureImmutableFile;
@@ -22,6 +23,7 @@ use std::process::{self, Command};
2223
use std::str;
2324
use std::sync::LazyLock;
2425

26+
2527
pub mod bencher;
2628
mod etw_parser;
2729
pub mod profiler;
@@ -129,6 +131,7 @@ pub struct CargoProcess<'a> {
129131
pub rustc_args: Vec<String>,
130132
pub touch_file: Option<String>,
131133
pub jobserver: Option<jobserver::Client>,
134+
pub compiler_target: &'a CompilerTarget,
132135
}
133136
/// Returns an optional list of Performance CPU cores, if the system has P and E cores.
134137
/// This list *should* be in a format suitable for the `taskset` command.
@@ -273,12 +276,13 @@ impl<'a> CargoProcess<'a> {
273276
// really.
274277
pub async fn run_rustc(&mut self, needs_final: bool) -> anyhow::Result<()> {
275278
log::info!(
276-
"run_rustc with incremental={}, profile={:?}, scenario={:?}, patch={:?}, backend={:?}, phase={}",
279+
"run_rustc with incremental={}, profile={:?}, scenario={:?}, patch={:?}, backend={:?}, compiler_target={:?}, phase={}",
277280
self.incremental,
278281
self.profile,
279282
self.processor_etc.as_ref().map(|v| v.1),
280283
self.processor_etc.as_ref().and_then(|v| v.3),
281284
self.backend,
285+
self.compiler_target,
282286
if needs_final { "benchmark" } else { "dependencies" }
283287
);
284288

@@ -420,6 +424,7 @@ impl<'a> CargoProcess<'a> {
420424
scenario_str,
421425
patch,
422426
backend: self.backend,
427+
compiler_target: self.compiler_target,
423428
};
424429
match processor.process_output(&data, output).await {
425430
Ok(Retry::No) => return Ok(()),
@@ -484,6 +489,7 @@ pub struct ProcessOutputData<'a> {
484489
scenario_str: &'a str,
485490
patch: Option<&'a Patch>,
486491
backend: CodegenBackend,
492+
compiler_target: &'a CompilerTarget,
487493
}
488494

489495
/// Trait used by `Benchmark::measure()` to provide different kinds of

database/schema.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Here is the diagram for compile-time benchmarks:
3535
│ scenario │ │ cid │ │
3636
│ backend │ │ value ├───┘
3737
│ metric │ └──────────┘
38+
│ compiler_tar..│
3839
└───────────────┘
3940
```
4041

@@ -151,9 +152,9 @@ many times in the `pstat` table.
151152

152153
```
153154
sqlite> select * from pstat_series limit 1;
154-
id crate profile scenario backend metric
155-
---------- ---------- ---------- ---------- ------- ------------
156-
1 helloworld check full llvm task-clock:u
155+
id crate profile scenario backend metric compiler_target
156+
---------- ---------- ---------- ---------- ------- ------------ ------------
157+
1 helloworld check full llvm task-clock:u x86_64-linux-unknown-gnu
157158
```
158159

159160
### pstat

database/src/bin/import-sqlite.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async fn main() {
4545
let sqlite_aid = sqlite_conn.artifact_id(&aid).await;
4646
let postgres_aid = postgres_conn.artifact_id(&aid).await;
4747

48-
for (&(benchmark, profile, scenario, backend, metric), id) in
48+
for (&(benchmark, profile, scenario, backend, metric, ref compiler_target), id) in
4949
sqlite_idx.compile_statistic_descriptions()
5050
{
5151
if benchmarks.insert(benchmark) {
@@ -76,6 +76,7 @@ async fn main() {
7676
backend,
7777
metric.as_str(),
7878
stat,
79+
&compiler_target,
7980
)
8081
.await;
8182
}

database/src/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ pub struct Index {
472472
artifacts: Indexed<Box<str>>,
473473
/// Id lookup of compile stat description ids
474474
/// For legacy reasons called `pstat_series` in the database, and so the name is kept here.
475-
pstat_series: Indexed<(Benchmark, Profile, Scenario, CodegenBackend, Metric)>,
475+
pstat_series: Indexed<(Benchmark, Profile, Scenario, CodegenBackend, Metric, String)>,
476476
/// Id lookup of runtime stat description ids
477477
runtime_pstat_series: Indexed<(Benchmark, Metric)>,
478478
}
@@ -586,14 +586,15 @@ mod index_serde {
586586
}
587587
}
588588

589-
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
589+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
590590
pub enum DbLabel {
591591
StatisticDescription {
592592
benchmark: Benchmark,
593593
profile: Profile,
594594
scenario: Scenario,
595595
backend: CodegenBackend,
596596
metric: Metric,
597+
compiler_target: String,
597598
},
598599
}
599600

@@ -612,9 +613,10 @@ impl Lookup for DbLabel {
612613
scenario,
613614
backend,
614615
metric,
616+
compiler_target,
615617
} => index
616618
.pstat_series
617-
.get(&(*benchmark, *profile, *scenario, *backend, *metric)),
619+
.get(&(*benchmark, *profile, *scenario, *backend, *metric, compiler_target.to_string())),
618620
}
619621
}
620622
}
@@ -664,7 +666,7 @@ impl Index {
664666
self.pstat_series
665667
.map
666668
.keys()
667-
.map(|(_, _, _, _, metric)| metric)
669+
.map(|(_, _, _, _, metric, _)| metric)
668670
.collect::<std::collections::HashSet<_>>()
669671
.into_iter()
670672
.map(|s| s.to_string())
@@ -690,7 +692,7 @@ impl Index {
690692
&self,
691693
) -> impl Iterator<
692694
Item = (
693-
&(Benchmark, Profile, Scenario, CodegenBackend, Metric),
695+
&(Benchmark, Profile, Scenario, CodegenBackend, Metric, String),
694696
StatisticalDescriptionId,
695697
),
696698
> + '_ {

database/src/pool.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pub trait Connection: Send + Sync {
4747
backend: CodegenBackend,
4848
metric: &str,
4949
value: f64,
50+
compiler_target: &str,
5051
);
5152
async fn record_runtime_statistic(
5253
&self,

0 commit comments

Comments
 (0)