Skip to content

Commit ff3b010

Browse files
committed
Compile runtime benchmarks with debuginfo for profiling
1 parent 3c1ae19 commit ff3b010

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

collector/src/bin/collector.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use collector::compile::benchmark::scenario::Scenario;
1010
use collector::compile::benchmark::{
1111
compile_benchmark_dir, get_compile_benchmarks, ArtifactType, Benchmark, BenchmarkName,
1212
};
13-
use collector::{runtime, utils, CollectorCtx, CollectorStepBuilder};
13+
use collector::{utils, CollectorCtx, CollectorStepBuilder};
1414
use database::{ArtifactId, ArtifactIdNumber, Commit, CommitType, Connection, Pool};
1515
use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator};
1616
use std::cmp::Ordering;
@@ -30,12 +30,12 @@ use tokio::runtime::Runtime;
3030

3131
use collector::compile::execute::bencher::BenchProcessor;
3232
use collector::compile::execute::profiler::{ProfileProcessor, Profiler};
33-
use collector::runtime::profile_runtime;
3433
use collector::runtime::{
3534
bench_runtime, prepare_runtime_benchmark_suite, runtime_benchmark_dir, BenchmarkFilter,
3635
BenchmarkSuite, BenchmarkSuiteCompilation, CargoIsolationMode, RuntimeProfiler,
3736
DEFAULT_RUNTIME_ITERATIONS,
3837
};
38+
use collector::runtime::{profile_runtime, RuntimeCompilationOpts};
3939
use collector::toolchain::{
4040
create_toolchain_from_published_version, get_local_toolchain, Sysroot, Toolchain,
4141
};
@@ -704,6 +704,7 @@ fn main_result() -> anyhow::Result<i32> {
704704
&toolchain,
705705
&runtime_benchmark_dir,
706706
CargoIsolationMode::Cached,
707+
RuntimeCompilationOpts::default().debug_info("1"),
707708
)?
708709
.suite;
709710
profile_runtime(profiler, suite, &benchmark)?;
@@ -1050,7 +1051,12 @@ async fn load_runtime_benchmarks(
10501051
let BenchmarkSuiteCompilation {
10511052
suite,
10521053
failed_to_compile,
1053-
} = runtime::prepare_runtime_benchmark_suite(toolchain, benchmark_dir, isolation_mode)?;
1054+
} = prepare_runtime_benchmark_suite(
1055+
toolchain,
1056+
benchmark_dir,
1057+
isolation_mode,
1058+
RuntimeCompilationOpts::default(),
1059+
)?;
10541060

10551061
record_runtime_compilation_errors(conn, artifact_id, failed_to_compile).await;
10561062
Ok(suite)

collector/src/runtime/benchmark.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ pub struct BenchmarkSuiteCompilation {
106106
pub failed_to_compile: HashMap<String, String>,
107107
}
108108

109+
#[derive(Default)]
110+
pub struct RuntimeCompilationOpts {
111+
debug_info: Option<String>,
112+
}
113+
114+
impl RuntimeCompilationOpts {
115+
pub fn debug_info(mut self, debug_info: &str) -> Self {
116+
self.debug_info = Some(debug_info.to_string());
117+
self
118+
}
119+
}
120+
109121
/// Find all runtime benchmark crates in `benchmark_dir` and compile them.
110122
/// We assume that each binary defines a benchmark suite using `benchlib`.
111123
/// We then execute each benchmark suite with the `list-benchmarks` command to find out its
@@ -114,6 +126,7 @@ pub fn prepare_runtime_benchmark_suite(
114126
toolchain: &Toolchain,
115127
benchmark_dir: &Path,
116128
isolation_mode: CargoIsolationMode,
129+
opts: RuntimeCompilationOpts,
117130
) -> anyhow::Result<BenchmarkSuiteCompilation> {
118131
let benchmark_crates = get_runtime_benchmark_groups(benchmark_dir)?;
119132

@@ -146,7 +159,7 @@ pub fn prepare_runtime_benchmark_suite(
146159

147160
let target_dir = temp_dir.as_ref().map(|d| d.path());
148161

149-
let result = start_cargo_build(toolchain, &benchmark_crate.path, target_dir)
162+
let result = start_cargo_build(toolchain, &benchmark_crate.path, target_dir, &opts)
150163
.with_context(|| {
151164
anyhow::anyhow!("Cannot start compilation of {}", benchmark_crate.name)
152165
})
@@ -276,6 +289,7 @@ fn start_cargo_build(
276289
toolchain: &Toolchain,
277290
benchmark_dir: &Path,
278291
target_dir: Option<&Path>,
292+
opts: &RuntimeCompilationOpts,
279293
) -> anyhow::Result<Child> {
280294
let mut command = Command::new(&toolchain.components.cargo);
281295
command
@@ -289,6 +303,10 @@ fn start_cargo_build(
289303
.stdout(Stdio::piped())
290304
.stderr(Stdio::null());
291305

306+
if let Some(ref debug_info) = opts.debug_info {
307+
command.env("CARGO_PROFILE_RELEASE_DEBUG", debug_info);
308+
}
309+
292310
if let Some(target_dir) = target_dir {
293311
command.arg("--target-dir");
294312
command.arg(target_dir);

collector/src/runtime/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use crate::{run_command_with_output, CollectorCtx};
1919
mod benchmark;
2020
mod profile;
2121

22+
pub use benchmark::RuntimeCompilationOpts;
2223
pub use profile::{profile_runtime, RuntimeProfiler};
2324

2425
pub const DEFAULT_RUNTIME_ITERATIONS: u32 = 5;

0 commit comments

Comments
 (0)