From 5620ed249222f3fbd8ab06e38b3653c00f9fead7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Thu, 24 Apr 2025 16:21:31 +0200 Subject: [PATCH] Add support for selecting workspace package It can be useful for local benchmarking of workspace crates. --- collector/src/compile/benchmark/mod.rs | 5 +++++ collector/src/compile/execute/mod.rs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/collector/src/compile/benchmark/mod.rs b/collector/src/compile/benchmark/mod.rs index 7fb671dc3..80cc1c5d3 100644 --- a/collector/src/compile/benchmark/mod.rs +++ b/collector/src/compile/benchmark/mod.rs @@ -78,6 +78,10 @@ pub struct BenchmarkConfig { excluded_scenarios: HashSet, artifact: ArtifactType, + + /// Which package from a workspace should be compiled + #[serde(default)] + package: Option, } impl BenchmarkConfig { @@ -224,6 +228,7 @@ impl Benchmark { touch_file: self.config.touch_file.clone(), jobserver: None, target, + workspace_package: self.config.package.clone(), } } diff --git a/collector/src/compile/execute/mod.rs b/collector/src/compile/execute/mod.rs index 9a20dd7cd..55e48c3a9 100644 --- a/collector/src/compile/execute/mod.rs +++ b/collector/src/compile/execute/mod.rs @@ -131,6 +131,7 @@ pub struct CargoProcess<'a> { pub touch_file: Option, pub jobserver: Option, pub target: Target, + pub workspace_package: Option, } /// 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. @@ -258,6 +259,10 @@ impl<'a> CargoProcess<'a> { fn get_pkgid(&self, cwd: &Path) -> anyhow::Result { let mut pkgid_cmd = self.base_command(cwd, "pkgid"); + if let Some(package) = &self.workspace_package { + pkgid_cmd.arg("-p").arg(package); + } + let out = command_output(&mut pkgid_cmd) .with_context(|| format!("failed to obtain pkgid in '{:?}'", cwd))? .stdout;