Skip to content

Commit 7cb728f

Browse files
committed
feedback - renaming and enum creation
1 parent bc68213 commit 7cb728f

File tree

13 files changed

+127
-89
lines changed

13 files changed

+127
-89
lines changed

collector/src/bin/collector.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +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;
38+
use collector::compile::benchmark::target::Target;
3939
use collector::compile::benchmark::profile::Profile;
4040
use collector::compile::benchmark::scenario::Scenario;
4141
use collector::compile::benchmark::{
@@ -100,7 +100,7 @@ struct CompileBenchmarkConfig {
100100
iterations: Option<usize>,
101101
is_self_profile: bool,
102102
bench_rustc: bool,
103-
compiler_targets: Vec<CompilerTarget>,
103+
targets: Vec<Target>,
104104
}
105105

106106
struct RuntimeBenchmarkConfig {
@@ -202,7 +202,7 @@ fn profile_compile(
202202
scenarios: &[Scenario],
203203
backends: &[CodegenBackend],
204204
errors: &mut BenchmarkErrors,
205-
compiler_targets: &[CompilerTarget]
205+
targets: &[Target]
206206
) {
207207
eprintln!("Profiling {} with {:?}", toolchain.id, profiler);
208208
if let Profiler::SelfProfile = profiler {
@@ -223,7 +223,7 @@ fn profile_compile(
223223
backends,
224224
toolchain,
225225
Some(1),
226-
compiler_targets,
226+
targets,
227227
));
228228
eprintln!("Finished benchmark {benchmark_id}");
229229

@@ -914,7 +914,7 @@ fn main_result() -> anyhow::Result<i32> {
914914
iterations: Some(iterations),
915915
is_self_profile: self_profile.self_profile,
916916
bench_rustc: bench_rustc.bench_rustc,
917-
compiler_targets: vec![CompilerTarget::default()],
917+
targets: vec![Target::default()],
918918
};
919919

920920
run_benchmarks(&mut rt, conn, shared, Some(config), None)?;
@@ -1029,7 +1029,7 @@ fn main_result() -> anyhow::Result<i32> {
10291029
iterations: runs.map(|v| v as usize),
10301030
is_self_profile: self_profile.self_profile,
10311031
bench_rustc: bench_rustc.bench_rustc,
1032-
compiler_targets: vec![CompilerTarget::default()],
1032+
targets: vec![Target::default()],
10331033
};
10341034
let runtime_suite = rt.block_on(load_runtime_benchmarks(
10351035
conn.as_mut(),
@@ -1142,7 +1142,7 @@ fn main_result() -> anyhow::Result<i32> {
11421142
scenarios,
11431143
backends,
11441144
&mut errors,
1145-
&[CompilerTarget::default()],
1145+
&[Target::default()],
11461146
);
11471147
Ok(id)
11481148
};
@@ -1741,7 +1741,7 @@ fn bench_published_artifact(
17411741
iterations: Some(3),
17421742
is_self_profile: false,
17431743
bench_rustc: false,
1744-
compiler_targets: vec![CompilerTarget::default()],
1744+
targets: vec![Target::default()],
17451745
}),
17461746
Some(RuntimeBenchmarkConfig::new(
17471747
runtime_suite,
@@ -1842,7 +1842,7 @@ fn bench_compile(
18421842
&config.backends,
18431843
&shared.toolchain,
18441844
config.iterations,
1845-
&config.compiler_targets,
1845+
&config.targets,
18461846
)))
18471847
.with_context(|| anyhow::anyhow!("Cannot compile {}", benchmark.name))
18481848
},

collector/src/compile/benchmark/compiler_target.rs

Lines changed: 0 additions & 8 deletions
This file was deleted.

collector/src/compile/benchmark/mod.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +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;
6+
use crate::compile::benchmark::target::Target;
77
use crate::compile::execute::{CargoProcess, Processor};
88
use crate::toolchain::Toolchain;
99
use crate::utils::wait_for_future;
@@ -21,7 +21,7 @@ pub mod codegen_backend;
2121
pub(crate) mod patch;
2222
pub mod profile;
2323
pub mod scenario;
24-
pub mod compiler_target;
24+
pub mod target;
2525

2626
fn default_runs() -> usize {
2727
3
@@ -182,7 +182,7 @@ impl Benchmark {
182182
cwd: &'a Path,
183183
profile: Profile,
184184
backend: CodegenBackend,
185-
compiler_target: &'a CompilerTarget,
185+
target: Target,
186186
) -> CargoProcess<'a> {
187187
let mut cargo_args = self
188188
.config
@@ -223,7 +223,7 @@ impl Benchmark {
223223
.collect(),
224224
touch_file: self.config.touch_file.clone(),
225225
jobserver: None,
226-
compiler_target,
226+
target,
227227
}
228228
}
229229

@@ -236,7 +236,7 @@ impl Benchmark {
236236
backends: &[CodegenBackend],
237237
toolchain: &Toolchain,
238238
iterations: Option<usize>,
239-
compiler_targets: &[CompilerTarget]
239+
targets: &[Target]
240240
) -> anyhow::Result<()> {
241241
if self.config.disabled {
242242
eprintln!("Skipping {}: disabled", self.name);
@@ -268,11 +268,11 @@ impl Benchmark {
268268
}
269269

270270
eprintln!("Preparing {}", self.name);
271-
let mut target_dirs: Vec<((CodegenBackend, Profile, &CompilerTarget), TempDir)> = vec![];
271+
let mut target_dirs: Vec<((CodegenBackend, Profile, Target), TempDir)> = vec![];
272272
for backend in backends {
273273
for profile in &profiles {
274-
for compiler_target in compiler_targets {
275-
target_dirs.push(((*backend, *profile, &compiler_target), self.make_temp_dir(&self.path)?));
274+
for target in targets {
275+
target_dirs.push(((*backend, *profile, *target), self.make_temp_dir(&self.path)?));
276276
}
277277
}
278278
}
@@ -311,12 +311,12 @@ impl Benchmark {
311311
)
312312
.context("jobserver::new")?;
313313
let mut threads = Vec::with_capacity(target_dirs.len());
314-
for ((backend, profile, compiler_target), prep_dir) in &target_dirs {
314+
for ((backend, profile, target), prep_dir) in &target_dirs {
315315
let server = server.clone();
316316
let thread = s.spawn::<_, anyhow::Result<()>>(move || {
317317
wait_for_future(async move {
318318
let server = server.clone();
319-
self.mk_cargo_process(toolchain, prep_dir.path(), *profile, *backend, compiler_target)
319+
self.mk_cargo_process(toolchain, prep_dir.path(), *profile, *backend, *target)
320320
.jobserver(server)
321321
.run_rustc(false)
322322
.await?;
@@ -350,13 +350,13 @@ impl Benchmark {
350350
let mut timing_dirs: Vec<ManuallyDrop<TempDir>> = vec![];
351351

352352
let benchmark_start = std::time::Instant::now();
353-
for ((backend, profile, compiler_target), prep_dir) in &target_dirs {
353+
for ((backend, profile, target), prep_dir) in &target_dirs {
354354
let backend = *backend;
355355
let profile = *profile;
356-
let compiler_target = *compiler_target;
356+
let target = *target;
357357
eprintln!(
358358
"Running {}: {:?} + {:?} + {:?} + {:?}",
359-
self.name, profile, scenarios, backend, compiler_target,
359+
self.name, profile, scenarios, backend, target,
360360
);
361361

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

379379
// A full non-incremental build.
380380
if scenarios.contains(&Scenario::Full) {
381-
self.mk_cargo_process(toolchain, cwd, profile, backend, &compiler_target)
381+
self.mk_cargo_process(toolchain, cwd, profile, backend, target)
382382
.processor(processor, Scenario::Full, "Full", None)
383383
.run_rustc(true)
384384
.await?;
@@ -389,7 +389,7 @@ impl Benchmark {
389389
// An incremental from scratch (slowest incremental case).
390390
// This is required for any subsequent incremental builds.
391391
if scenarios.iter().any(|s| s.is_incr()) {
392-
self.mk_cargo_process(toolchain, cwd, profile, backend, &compiler_target)
392+
self.mk_cargo_process(toolchain, cwd, profile, backend, target)
393393
.incremental(true)
394394
.processor(processor, Scenario::IncrFull, "IncrFull", None)
395395
.run_rustc(true)
@@ -398,7 +398,7 @@ impl Benchmark {
398398

399399
// An incremental build with no changes (fastest incremental case).
400400
if scenarios.contains(&Scenario::IncrUnchanged) {
401-
self.mk_cargo_process(toolchain, cwd, profile, backend, &compiler_target)
401+
self.mk_cargo_process(toolchain, cwd, profile, backend, target)
402402
.incremental(true)
403403
.processor(processor, Scenario::IncrUnchanged, "IncrUnchanged", None)
404404
.run_rustc(true)
@@ -413,7 +413,7 @@ impl Benchmark {
413413
// An incremental build with some changes (realistic
414414
// incremental case).
415415
let scenario_str = format!("IncrPatched{}", i);
416-
self.mk_cargo_process(toolchain, cwd, profile, backend, &compiler_target)
416+
self.mk_cargo_process(toolchain, cwd, profile, backend, target)
417417
.incremental(true)
418418
.processor(
419419
processor,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, serde::Deserialize)]
2+
pub enum Target {
3+
X86_64UnknownLinuxGnu
4+
}
5+
6+
impl Default for Target {
7+
fn default() -> Self {
8+
Self::X86_64UnknownLinuxGnu
9+
}
10+
}

collector/src/compile/execute/bencher.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +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;
4+
use crate::compile::benchmark::target::Target;
55
use crate::compile::benchmark::BenchmarkName;
66
use crate::compile::execute;
77
use crate::compile::execute::{
@@ -92,14 +92,18 @@ impl<'a> BenchProcessor<'a> {
9292
scenario: database::Scenario,
9393
profile: database::Profile,
9494
backend: CodegenBackend,
95-
compiler_target: &CompilerTarget,
95+
target: Target,
9696
stats: Stats,
9797
) {
9898
let backend = match backend {
9999
CodegenBackend::Llvm => database::CodegenBackend::Llvm,
100100
CodegenBackend::Cranelift => database::CodegenBackend::Cranelift,
101101
};
102102

103+
let target = match target {
104+
Target::X86_64UnknownLinuxGnu => database::Target::X86_64UnknownLinuxGnu
105+
};
106+
103107
let mut buf = FuturesUnordered::new();
104108
for (stat, value) in stats.iter() {
105109
buf.push(self.conn.record_statistic(
@@ -111,7 +115,7 @@ impl<'a> BenchProcessor<'a> {
111115
backend,
112116
stat,
113117
value,
114-
&compiler_target.0,
118+
target,
115119
));
116120
}
117121

@@ -202,7 +206,7 @@ impl Processor for BenchProcessor<'_> {
202206
res.0.stats.retain(|key, _| key.starts_with("size:"));
203207
}
204208

205-
self.insert_stats(collection, scenario, profile, data.backend, data.compiler_target, res.0)
209+
self.insert_stats(collection, scenario, profile, data.backend, data.target, res.0)
206210
.await;
207211

208212
Ok(Retry::No)

collector/src/compile/execute/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +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;
7+
use crate::compile::benchmark::target::Target;
88
use crate::compile::benchmark::BenchmarkName;
99
use crate::toolchain::Toolchain;
1010
use crate::utils::fs::EnsureImmutableFile;
@@ -131,7 +131,7 @@ pub struct CargoProcess<'a> {
131131
pub rustc_args: Vec<String>,
132132
pub touch_file: Option<String>,
133133
pub jobserver: Option<jobserver::Client>,
134-
pub compiler_target: &'a CompilerTarget,
134+
pub target: Target,
135135
}
136136
/// Returns an optional list of Performance CPU cores, if the system has P and E cores.
137137
/// This list *should* be in a format suitable for the `taskset` command.
@@ -276,13 +276,13 @@ impl<'a> CargoProcess<'a> {
276276
// really.
277277
pub async fn run_rustc(&mut self, needs_final: bool) -> anyhow::Result<()> {
278278
log::info!(
279-
"run_rustc with incremental={}, profile={:?}, scenario={:?}, patch={:?}, backend={:?}, compiler_target={:?}, phase={}",
279+
"run_rustc with incremental={}, profile={:?}, scenario={:?}, patch={:?}, backend={:?}, target={:?}, phase={}",
280280
self.incremental,
281281
self.profile,
282282
self.processor_etc.as_ref().map(|v| v.1),
283283
self.processor_etc.as_ref().and_then(|v| v.3),
284284
self.backend,
285-
self.compiler_target,
285+
self.target,
286286
if needs_final { "benchmark" } else { "dependencies" }
287287
);
288288

@@ -424,7 +424,7 @@ impl<'a> CargoProcess<'a> {
424424
scenario_str,
425425
patch,
426426
backend: self.backend,
427-
compiler_target: self.compiler_target,
427+
target: self.target,
428428
};
429429
match processor.process_output(&data, output).await {
430430
Ok(Retry::No) => return Ok(()),
@@ -489,7 +489,7 @@ pub struct ProcessOutputData<'a> {
489489
scenario_str: &'a str,
490490
patch: Option<&'a Patch>,
491491
backend: CodegenBackend,
492-
compiler_target: &'a CompilerTarget,
492+
target: Target,
493493
}
494494

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

database/schema.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ many times in the `pstat` table.
152152

153153
```
154154
sqlite> select * from pstat_series limit 1;
155-
id crate profile scenario backend metric compiler_target
155+
id crate profile scenario backend metric target
156156
---------- ---------- ---------- ---------- ------- ------------ ------------
157157
1 helloworld check full llvm task-clock:u x86_64-linux-unknown-gnu
158158
```

database/src/bin/import-sqlite.rs

Lines changed: 2 additions & 2 deletions
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, ref compiler_target), id) in
48+
for (&(benchmark, profile, scenario, backend, metric, target), id) in
4949
sqlite_idx.compile_statistic_descriptions()
5050
{
5151
if benchmarks.insert(benchmark) {
@@ -76,7 +76,7 @@ async fn main() {
7676
backend,
7777
metric.as_str(),
7878
stat,
79-
&compiler_target,
79+
target,
8080
)
8181
.await;
8282
}

0 commit comments

Comments
 (0)