Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(opt-dist): new flag --benchmark-cargo-config #125930

Merged
merged 2 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions src/tools/opt-dist/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ pub struct Environment {
host_llvm_dir: Utf8PathBuf,
/// List of test paths that should be skipped when testing the optimized artifacts.
skipped_tests: Vec<String>,
/// Arguments passed to `rustc-perf --cargo-config <value>` when running benchmarks.
#[builder(default)]
benchmark_cargo_config: Vec<String>,
/// Directory containing a pre-built rustc-perf checkout.
#[builder(default)]
prebuilt_rustc_perf: Option<Utf8PathBuf>,
Expand Down Expand Up @@ -94,6 +97,10 @@ impl Environment {
pub fn skipped_tests(&self) -> &[String] {
&self.skipped_tests
}

pub fn benchmark_cargo_config(&self) -> &[String] {
&self.benchmark_cargo_config
}
}

/// What is the extension of binary executables on this platform?
Expand Down
6 changes: 6 additions & 0 deletions src/tools/opt-dist/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ enum EnvironmentCmd {

#[clap(flatten)]
shared: SharedArgs,

/// Arguments passed to `rustc-perf --cargo-config <value>` when running benchmarks.
#[arg(long)]
benchmark_cargo_config: Vec<String>,
},
/// Perform an optimized build on Linux CI, from inside Docker.
LinuxCi {
Expand Down Expand Up @@ -119,6 +123,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
llvm_shared,
use_bolt,
skipped_tests,
benchmark_cargo_config,
shared,
} => {
let env = EnvironmentBuilder::default()
Expand All @@ -132,6 +137,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
.shared_llvm(llvm_shared)
.use_bolt(use_bolt)
.skipped_tests(skipped_tests)
.benchmark_cargo_config(benchmark_cargo_config)
.build()?;

(env, shared.build_args)
Expand Down
14 changes: 12 additions & 2 deletions src/tools/opt-dist/src/training.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn init_compiler_benchmarks(
// Run rustc-perf benchmarks
// Benchmark using profile_local with eprintln, which essentially just means
// don't actually benchmark -- just make sure we run rustc a bunch of times.
cmd(&[
let mut cmd = cmd(&[
env.cargo_stage_0().as_str(),
"run",
"-p",
Expand All @@ -61,7 +61,17 @@ fn init_compiler_benchmarks(
.env("RUST_LOG", "collector=debug")
.env("RUSTC", env.rustc_stage_0().as_str())
.env("RUSTC_BOOTSTRAP", "1")
.workdir(&env.rustc_perf_dir())
.workdir(&env.rustc_perf_dir());

// This propagates cargo configs to `rustc-perf --cargo-config`,
// which is particularly useful when the environment is air-gapped,
// and you want to use the default set of training crates vendored
// in the rustc-src tarball.
for config in env.benchmark_cargo_config() {
cmd = cmd.arg("--cargo-config").arg(config);
}

cmd
}

/// Describes which `llvm-profdata` binary should be used for merging PGO profiles.
Expand Down
Loading