Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
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::target::Target;
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,
targets: Vec<Target>,
}

struct RuntimeBenchmarkConfig {
Expand Down Expand Up @@ -200,6 +202,7 @@ fn profile_compile(
scenarios: &[Scenario],
backends: &[CodegenBackend],
errors: &mut BenchmarkErrors,
targets: &[Target]
) {
eprintln!("Profiling {} with {:?}", toolchain.id, profiler);
if let Profiler::SelfProfile = profiler {
Expand All @@ -220,6 +223,7 @@ fn profile_compile(
backends,
toolchain,
Some(1),
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,
targets: vec![Target::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,
targets: vec![Target::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,
&[Target::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,
targets: vec![Target::default()],
}),
Some(RuntimeBenchmarkConfig::new(
runtime_suite,
Expand Down Expand Up @@ -1834,6 +1842,7 @@ fn bench_compile(
&config.backends,
&shared.toolchain,
config.iterations,
&config.targets,
)))
.with_context(|| anyhow::anyhow!("Cannot compile {}", benchmark.name))
},
Expand Down
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::target::Target;
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 target;

fn default_runs() -> usize {
3
Expand Down Expand Up @@ -180,6 +182,7 @@ impl Benchmark {
cwd: &'a Path,
profile: Profile,
backend: CodegenBackend,
target: Target,
) -> 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,
target,
}
}

Expand All @@ -232,6 +236,7 @@ impl Benchmark {
backends: &[CodegenBackend],
toolchain: &Toolchain,
iterations: Option<usize>,
targets: &[Target]
) -> 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, Target), TempDir)> = vec![];
for backend in backends {
for profile in &profiles {
target_dirs.push(((*backend, *profile), self.make_temp_dir(&self.path)?));
for target in targets {
target_dirs.push(((*backend, *profile, *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, 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, *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, target), prep_dir) in &target_dirs {
let backend = *backend;
let profile = *profile;
let target = *target;
eprintln!(
"Running {}: {:?} + {:?} + {:?}",
self.name, profile, scenarios, backend
"Running {}: {:?} + {:?} + {:?} + {:?}",
self.name, profile, scenarios, backend, 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, 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, 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, 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, target)
.incremental(true)
.processor(
processor,
Expand Down
16 changes: 16 additions & 0 deletions collector/src/compile/benchmark/target.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/// Target representing an Rust target tripple, for a full list of targets and
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
/// Target representing an Rust target tripple, for a full list of targets and
/// Target representing an Rust target triple, for a full list of targets and

/// their support see;
/// https://doc.rust-lang.org/nightly/rustc/platform-support.html
///
/// Presently we only support x86_64
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, serde::Deserialize)]
pub enum Target {
/// `x86_64-unknown-linux-gnu`
X86_64UnknownLinuxGnu
}

impl Default for Target {
fn default() -> Self {
Self::X86_64UnknownLinuxGnu
}
}
9 changes: 8 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::target::Target;
use crate::compile::benchmark::BenchmarkName;
use crate::compile::execute;
use crate::compile::execute::{
Expand Down Expand Up @@ -91,13 +92,18 @@ impl<'a> BenchProcessor<'a> {
scenario: database::Scenario,
profile: database::Profile,
backend: CodegenBackend,
target: Target,
stats: Stats,
) {
let backend = match backend {
CodegenBackend::Llvm => database::CodegenBackend::Llvm,
CodegenBackend::Cranelift => database::CodegenBackend::Cranelift,
};

let target = match target {
Target::X86_64UnknownLinuxGnu => database::Target::X86_64UnknownLinuxGnu
};

let mut buf = FuturesUnordered::new();
for (stat, value) in stats.iter() {
buf.push(self.conn.record_statistic(
Expand All @@ -107,6 +113,7 @@ impl<'a> BenchProcessor<'a> {
profile,
scenario,
backend,
target,
stat,
value,
));
Expand Down Expand Up @@ -199,7 +206,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.target, res.0)
.await;

Ok(Retry::No)
Expand Down
7 changes: 6 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::target::Target;
use crate::compile::benchmark::BenchmarkName;
use crate::toolchain::Toolchain;
use crate::utils::fs::EnsureImmutableFile;
Expand Down Expand Up @@ -129,6 +130,7 @@ pub struct CargoProcess<'a> {
pub rustc_args: Vec<String>,
pub touch_file: Option<String>,
pub jobserver: Option<jobserver::Client>,
pub target: Target,
}
/// 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 +275,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={:?}, 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.target,
if needs_final { "benchmark" } else { "dependencies" }
);

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

/// 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 │ └──────────┘
│ target │
└───────────────┘
```

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 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, target, metric), id) in
sqlite_idx.compile_statistic_descriptions()
{
if benchmarks.insert(benchmark) {
Expand Down Expand Up @@ -74,6 +74,7 @@ async fn main() {
profile,
scenario,
backend,
target,
metric.as_str(),
stat,
)
Expand Down
5 changes: 3 additions & 2 deletions database/src/bin/postgres-to-sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,11 @@ impl Table for PstatSeries {
}

fn postgres_select_statement(&self, _since_weeks_ago: Option<u32>) -> String {
"select id, crate, profile, scenario, backend, metric from ".to_string() + self.name()
"select id, crate, profile, scenario, backend, target, metric from ".to_string() + self.name()
}

fn sqlite_insert_statement(&self) -> &'static str {
"insert into pstat_series (id, crate, profile, scenario, backend, metric) VALUES (?, ?, ?, ?, ?, ?)"
"insert into pstat_series (id, crate, profile, scenario, backend, target, metric) VALUES (?, ?, ?, ?, ?, ?, ?)"
}

fn sqlite_execute_insert(&self, statement: &mut rusqlite::Statement, row: tokio_postgres::Row) {
Expand All @@ -262,6 +262,7 @@ impl Table for PstatSeries {
row.get::<_, &str>(3),
row.get::<_, &str>(4),
row.get::<_, &str>(5),
row.get::<_, &str>(6),
])
.unwrap();
}
Expand Down
8 changes: 5 additions & 3 deletions database/src/bin/sqlite-to-postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ struct PstatSeriesRow<'a> {
profile: &'a str,
scenario: &'a str,
backend: &'a str,
target: &'a str,
metric: &'a str,
}

Expand All @@ -331,11 +332,11 @@ impl Table for PstatSeries {
}

fn sqlite_attributes() -> &'static str {
"id, crate, profile, scenario, backend, metric"
"id, crate, profile, scenario, backend, target, metric"
}

fn postgres_attributes() -> &'static str {
"id, crate, profile, scenario, backend, metric"
"id, crate, profile, scenario, backend, target, metric"
}

fn postgres_generated_id_attribute() -> Option<&'static str> {
Expand All @@ -350,7 +351,8 @@ impl Table for PstatSeries {
profile: row.get_ref(2).unwrap().as_str().unwrap(),
scenario: row.get_ref(3).unwrap().as_str().unwrap(),
backend: row.get_ref(4).unwrap().as_str().unwrap(),
metric: row.get_ref(5).unwrap().as_str().unwrap(),
target: row.get_ref(5).unwrap().as_str().unwrap(),
metric: row.get_ref(6).unwrap().as_str().unwrap(),
})
.unwrap();
}
Expand Down
Loading
Loading