Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions collector/src/bin/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use collector::artifact_stats::{
use collector::codegen::{codegen_diff, CodegenType};
use collector::compile::benchmark::category::Category;
use collector::compile::benchmark::codegen_backend::CodegenBackend;
use collector::compile::benchmark::compiler_target::CompilerTarget;
use collector::compile::benchmark::profile::Profile;
use collector::compile::benchmark::scenario::Scenario;
use collector::compile::benchmark::{
Expand Down Expand Up @@ -99,6 +100,7 @@ struct CompileBenchmarkConfig {
iterations: Option<usize>,
is_self_profile: bool,
bench_rustc: bool,
compiler_targets: Vec<CompilerTarget>,
}

struct RuntimeBenchmarkConfig {
Expand Down Expand Up @@ -200,6 +202,7 @@ fn profile_compile(
scenarios: &[Scenario],
backends: &[CodegenBackend],
errors: &mut BenchmarkErrors,
compiler_targets: &[CompilerTarget]
) {
eprintln!("Profiling {} with {:?}", toolchain.id, profiler);
if let Profiler::SelfProfile = profiler {
Expand All @@ -220,6 +223,7 @@ fn profile_compile(
backends,
toolchain,
Some(1),
compiler_targets,
));
eprintln!("Finished benchmark {benchmark_id}");

Expand Down Expand Up @@ -910,6 +914,7 @@ fn main_result() -> anyhow::Result<i32> {
iterations: Some(iterations),
is_self_profile: self_profile.self_profile,
bench_rustc: bench_rustc.bench_rustc,
compiler_targets: vec![CompilerTarget::default()],
};

run_benchmarks(&mut rt, conn, shared, Some(config), None)?;
Expand Down Expand Up @@ -1024,6 +1029,7 @@ fn main_result() -> anyhow::Result<i32> {
iterations: runs.map(|v| v as usize),
is_self_profile: self_profile.self_profile,
bench_rustc: bench_rustc.bench_rustc,
compiler_targets: vec![CompilerTarget::default()],
};
let runtime_suite = rt.block_on(load_runtime_benchmarks(
conn.as_mut(),
Expand Down Expand Up @@ -1136,6 +1142,7 @@ fn main_result() -> anyhow::Result<i32> {
scenarios,
backends,
&mut errors,
&[CompilerTarget::default()],
);
Ok(id)
};
Expand Down Expand Up @@ -1734,6 +1741,7 @@ fn bench_published_artifact(
iterations: Some(3),
is_self_profile: false,
bench_rustc: false,
compiler_targets: vec![CompilerTarget::default()],
}),
Some(RuntimeBenchmarkConfig::new(
runtime_suite,
Expand Down Expand Up @@ -1834,6 +1842,7 @@ fn bench_compile(
&config.backends,
&shared.toolchain,
config.iterations,
&config.compiler_targets,
)))
.with_context(|| anyhow::anyhow!("Cannot compile {}", benchmark.name))
},
Expand Down
8 changes: 8 additions & 0 deletions collector/src/compile/benchmark/compiler_target.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#[derive(Clone, Debug, Eq, Hash, PartialEq, serde::Deserialize)]
pub struct CompilerTarget(pub String);

impl Default for CompilerTarget {
fn default() -> Self {
return Self("x86_64-unknown-linux-gnu".to_string())
}
}
30 changes: 19 additions & 11 deletions collector/src/compile/benchmark/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::compile::benchmark::codegen_backend::CodegenBackend;
use crate::compile::benchmark::patch::Patch;
use crate::compile::benchmark::profile::Profile;
use crate::compile::benchmark::scenario::Scenario;
use crate::compile::benchmark::compiler_target::CompilerTarget;
use crate::compile::execute::{CargoProcess, Processor};
use crate::toolchain::Toolchain;
use crate::utils::wait_for_future;
Expand All @@ -20,6 +21,7 @@ pub mod codegen_backend;
pub(crate) mod patch;
pub mod profile;
pub mod scenario;
pub mod compiler_target;

fn default_runs() -> usize {
3
Expand Down Expand Up @@ -180,6 +182,7 @@ impl Benchmark {
cwd: &'a Path,
profile: Profile,
backend: CodegenBackend,
compiler_target: &'a CompilerTarget,
) -> CargoProcess<'a> {
let mut cargo_args = self
.config
Expand Down Expand Up @@ -220,6 +223,7 @@ impl Benchmark {
.collect(),
touch_file: self.config.touch_file.clone(),
jobserver: None,
compiler_target,
}
}

Expand All @@ -232,6 +236,7 @@ impl Benchmark {
backends: &[CodegenBackend],
toolchain: &Toolchain,
iterations: Option<usize>,
compiler_targets: &[CompilerTarget]
) -> anyhow::Result<()> {
if self.config.disabled {
eprintln!("Skipping {}: disabled", self.name);
Expand Down Expand Up @@ -263,10 +268,12 @@ impl Benchmark {
}

eprintln!("Preparing {}", self.name);
let mut target_dirs: Vec<((CodegenBackend, Profile), TempDir)> = vec![];
let mut target_dirs: Vec<((CodegenBackend, Profile, &CompilerTarget), TempDir)> = vec![];
for backend in backends {
for profile in &profiles {
target_dirs.push(((*backend, *profile), self.make_temp_dir(&self.path)?));
for compiler_target in compiler_targets {
target_dirs.push(((*backend, *profile, &compiler_target), self.make_temp_dir(&self.path)?));
}
}
}

Expand Down Expand Up @@ -304,12 +311,12 @@ impl Benchmark {
)
.context("jobserver::new")?;
let mut threads = Vec::with_capacity(target_dirs.len());
for ((backend, profile), prep_dir) in &target_dirs {
for ((backend, profile, compiler_target), prep_dir) in &target_dirs {
let server = server.clone();
let thread = s.spawn::<_, anyhow::Result<()>>(move || {
wait_for_future(async move {
let server = server.clone();
self.mk_cargo_process(toolchain, prep_dir.path(), *profile, *backend)
self.mk_cargo_process(toolchain, prep_dir.path(), *profile, *backend, compiler_target)
.jobserver(server)
.run_rustc(false)
.await?;
Expand Down Expand Up @@ -343,12 +350,13 @@ impl Benchmark {
let mut timing_dirs: Vec<ManuallyDrop<TempDir>> = vec![];

let benchmark_start = std::time::Instant::now();
for ((backend, profile), prep_dir) in &target_dirs {
for ((backend, profile, compiler_target), prep_dir) in &target_dirs {
let backend = *backend;
let profile = *profile;
let compiler_target = *compiler_target;
eprintln!(
"Running {}: {:?} + {:?} + {:?}",
self.name, profile, scenarios, backend
"Running {}: {:?} + {:?} + {:?} + {:?}",
self.name, profile, scenarios, backend, compiler_target,
);

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

// A full non-incremental build.
if scenarios.contains(&Scenario::Full) {
self.mk_cargo_process(toolchain, cwd, profile, backend)
self.mk_cargo_process(toolchain, cwd, profile, backend, &compiler_target)
.processor(processor, Scenario::Full, "Full", None)
.run_rustc(true)
.await?;
Expand All @@ -381,7 +389,7 @@ impl Benchmark {
// An incremental from scratch (slowest incremental case).
// This is required for any subsequent incremental builds.
if scenarios.iter().any(|s| s.is_incr()) {
self.mk_cargo_process(toolchain, cwd, profile, backend)
self.mk_cargo_process(toolchain, cwd, profile, backend, &compiler_target)
.incremental(true)
.processor(processor, Scenario::IncrFull, "IncrFull", None)
.run_rustc(true)
Expand All @@ -390,7 +398,7 @@ impl Benchmark {

// An incremental build with no changes (fastest incremental case).
if scenarios.contains(&Scenario::IncrUnchanged) {
self.mk_cargo_process(toolchain, cwd, profile, backend)
self.mk_cargo_process(toolchain, cwd, profile, backend, &compiler_target)
.incremental(true)
.processor(processor, Scenario::IncrUnchanged, "IncrUnchanged", None)
.run_rustc(true)
Expand All @@ -405,7 +413,7 @@ impl Benchmark {
// An incremental build with some changes (realistic
// incremental case).
let scenario_str = format!("IncrPatched{}", i);
self.mk_cargo_process(toolchain, cwd, profile, backend)
self.mk_cargo_process(toolchain, cwd, profile, backend, &compiler_target)
.incremental(true)
.processor(
processor,
Expand Down
5 changes: 4 additions & 1 deletion collector/src/compile/execute/bencher.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::compile::benchmark::codegen_backend::CodegenBackend;
use crate::compile::benchmark::profile::Profile;
use crate::compile::benchmark::scenario::Scenario;
use crate::compile::benchmark::compiler_target::CompilerTarget;
use crate::compile::benchmark::BenchmarkName;
use crate::compile::execute;
use crate::compile::execute::{
Expand Down Expand Up @@ -91,6 +92,7 @@ impl<'a> BenchProcessor<'a> {
scenario: database::Scenario,
profile: database::Profile,
backend: CodegenBackend,
compiler_target: &CompilerTarget,
stats: Stats,
) {
let backend = match backend {
Expand All @@ -109,6 +111,7 @@ impl<'a> BenchProcessor<'a> {
backend,
stat,
value,
&compiler_target.0,
));
}

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

self.insert_stats(collection, scenario, profile, data.backend, res.0)
self.insert_stats(collection, scenario, profile, data.backend, data.compiler_target, res.0)
.await;

Ok(Retry::No)
Expand Down
8 changes: 7 additions & 1 deletion collector/src/compile/execute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::compile::benchmark::codegen_backend::CodegenBackend;
use crate::compile::benchmark::patch::Patch;
use crate::compile::benchmark::profile::Profile;
use crate::compile::benchmark::scenario::Scenario;
use crate::compile::benchmark::compiler_target::CompilerTarget;
use crate::compile::benchmark::BenchmarkName;
use crate::toolchain::Toolchain;
use crate::utils::fs::EnsureImmutableFile;
Expand All @@ -22,6 +23,7 @@ use std::process::{self, Command};
use std::str;
use std::sync::LazyLock;


pub mod bencher;
mod etw_parser;
pub mod profiler;
Expand Down Expand Up @@ -129,6 +131,7 @@ pub struct CargoProcess<'a> {
pub rustc_args: Vec<String>,
pub touch_file: Option<String>,
pub jobserver: Option<jobserver::Client>,
pub compiler_target: &'a CompilerTarget,
}
/// Returns an optional list of Performance CPU cores, if the system has P and E cores.
/// This list *should* be in a format suitable for the `taskset` command.
Expand Down Expand Up @@ -273,12 +276,13 @@ impl<'a> CargoProcess<'a> {
// really.
pub async fn run_rustc(&mut self, needs_final: bool) -> anyhow::Result<()> {
log::info!(
"run_rustc with incremental={}, profile={:?}, scenario={:?}, patch={:?}, backend={:?}, phase={}",
"run_rustc with incremental={}, profile={:?}, scenario={:?}, patch={:?}, backend={:?}, compiler_target={:?}, phase={}",
self.incremental,
self.profile,
self.processor_etc.as_ref().map(|v| v.1),
self.processor_etc.as_ref().and_then(|v| v.3),
self.backend,
self.compiler_target,
if needs_final { "benchmark" } else { "dependencies" }
);

Expand Down Expand Up @@ -420,6 +424,7 @@ impl<'a> CargoProcess<'a> {
scenario_str,
patch,
backend: self.backend,
compiler_target: self.compiler_target,
};
match processor.process_output(&data, output).await {
Ok(Retry::No) => return Ok(()),
Expand Down Expand Up @@ -484,6 +489,7 @@ pub struct ProcessOutputData<'a> {
scenario_str: &'a str,
patch: Option<&'a Patch>,
backend: CodegenBackend,
compiler_target: &'a CompilerTarget,
}

/// Trait used by `Benchmark::measure()` to provide different kinds of
Expand Down
7 changes: 4 additions & 3 deletions database/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Here is the diagram for compile-time benchmarks:
│ scenario │ │ cid │ │
│ backend │ │ value ├───┘
│ metric │ └──────────┘
│ compiler_tar..│
└───────────────┘
```

Expand Down Expand Up @@ -151,9 +152,9 @@ many times in the `pstat` table.

```
sqlite> select * from pstat_series limit 1;
id crate profile scenario backend metric
---------- ---------- ---------- ---------- ------- ------------
1 helloworld check full llvm task-clock:u
id crate profile scenario backend metric compiler_target
---------- ---------- ---------- ---------- ------- ------------ ------------
1 helloworld check full llvm task-clock:u x86_64-linux-unknown-gnu
```

### pstat
Expand Down
3 changes: 2 additions & 1 deletion database/src/bin/import-sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async fn main() {
let sqlite_aid = sqlite_conn.artifact_id(&aid).await;
let postgres_aid = postgres_conn.artifact_id(&aid).await;

for (&(benchmark, profile, scenario, backend, metric), id) in
for (&(benchmark, profile, scenario, backend, metric, ref compiler_target), id) in
sqlite_idx.compile_statistic_descriptions()
{
if benchmarks.insert(benchmark) {
Expand Down Expand Up @@ -76,6 +76,7 @@ async fn main() {
backend,
metric.as_str(),
stat,
&compiler_target,
)
.await;
}
Expand Down
12 changes: 7 additions & 5 deletions database/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ pub struct Index {
artifacts: Indexed<Box<str>>,
/// Id lookup of compile stat description ids
/// For legacy reasons called `pstat_series` in the database, and so the name is kept here.
pstat_series: Indexed<(Benchmark, Profile, Scenario, CodegenBackend, Metric)>,
pstat_series: Indexed<(Benchmark, Profile, Scenario, CodegenBackend, Metric, String)>,
/// Id lookup of runtime stat description ids
runtime_pstat_series: Indexed<(Benchmark, Metric)>,
}
Expand Down Expand Up @@ -586,14 +586,15 @@ mod index_serde {
}
}

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub enum DbLabel {
StatisticDescription {
benchmark: Benchmark,
profile: Profile,
scenario: Scenario,
backend: CodegenBackend,
metric: Metric,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please also keep the target before metric here, to keep metric at the end?

compiler_target: String,
},
}

Expand All @@ -612,9 +613,10 @@ impl Lookup for DbLabel {
scenario,
backend,
metric,
compiler_target,
} => index
.pstat_series
.get(&(*benchmark, *profile, *scenario, *backend, *metric)),
.get(&(*benchmark, *profile, *scenario, *backend, *metric, compiler_target.to_string())),
}
}
}
Expand Down Expand Up @@ -664,7 +666,7 @@ impl Index {
self.pstat_series
.map
.keys()
.map(|(_, _, _, _, metric)| metric)
.map(|(_, _, _, _, metric, _)| metric)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.map(|(_, _, _, _, metric, _)| metric)
.map(|(_, _, _, _, _, metric)| metric)

Otherwise it would actually select the target.

.collect::<std::collections::HashSet<_>>()
.into_iter()
.map(|s| s.to_string())
Expand All @@ -690,7 +692,7 @@ impl Index {
&self,
) -> impl Iterator<
Item = (
&(Benchmark, Profile, Scenario, CodegenBackend, Metric),
&(Benchmark, Profile, Scenario, CodegenBackend, Metric, String),
StatisticalDescriptionId,
),
> + '_ {
Expand Down
1 change: 1 addition & 0 deletions database/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub trait Connection: Send + Sync {
backend: CodegenBackend,
metric: &str,
value: f64,
compiler_target: &str,
);
async fn record_runtime_statistic(
&self,
Expand Down
Loading
Loading