From c73ed895c700bd646af5bfbd111268fcaca9fda0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 4 Feb 2025 11:14:00 +0100 Subject: [PATCH] Remove the `rustc-perf-wrapper` tool --- Cargo.lock | 7 - Cargo.toml | 1 - src/bootstrap/src/core/build_steps/tool.rs | 1 - src/tools/rustc-perf-wrapper/Cargo.toml | 7 - src/tools/rustc-perf-wrapper/README.md | 3 - src/tools/rustc-perf-wrapper/src/config.rs | 45 ------ src/tools/rustc-perf-wrapper/src/main.rs | 178 --------------------- triagebot.toml | 1 - 8 files changed, 243 deletions(-) delete mode 100644 src/tools/rustc-perf-wrapper/Cargo.toml delete mode 100644 src/tools/rustc-perf-wrapper/README.md delete mode 100644 src/tools/rustc-perf-wrapper/src/config.rs delete mode 100644 src/tools/rustc-perf-wrapper/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 7c8f06a02396..ba7090baa672 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3287,13 +3287,6 @@ dependencies = [ "tikv-jemalloc-sys", ] -[[package]] -name = "rustc-perf-wrapper" -version = "0.1.0" -dependencies = [ - "clap", -] - [[package]] name = "rustc-rayon" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index 68d142ebe926..97e782d0df02 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,6 @@ members = [ "src/tools/rustdoc-gui-test", "src/tools/opt-dist", "src/tools/coverage-dump", - "src/tools/rustc-perf-wrapper", "src/tools/wasm-component-ld", "src/tools/features-status-dump", ] diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index 75fac88252b1..734ade8bfed1 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -362,7 +362,6 @@ bootstrap_tool!( GenerateWindowsSys, "src/tools/generate-windows-sys", "generate-windows-sys"; RustdocGUITest, "src/tools/rustdoc-gui-test", "rustdoc-gui-test", is_unstable_tool = true, allow_features = "test"; CoverageDump, "src/tools/coverage-dump", "coverage-dump"; - RustcPerfWrapper, "src/tools/rustc-perf-wrapper", "rustc-perf-wrapper"; WasmComponentLd, "src/tools/wasm-component-ld", "wasm-component-ld", is_unstable_tool = true, allow_features = "min_specialization"; UnicodeTableGenerator, "src/tools/unicode-table-generator", "unicode-table-generator"; FeaturesStatusDump, "src/tools/features-status-dump", "features-status-dump"; diff --git a/src/tools/rustc-perf-wrapper/Cargo.toml b/src/tools/rustc-perf-wrapper/Cargo.toml deleted file mode 100644 index 416bfef41d7f..000000000000 --- a/src/tools/rustc-perf-wrapper/Cargo.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -name = "rustc-perf-wrapper" -version = "0.1.0" -edition = "2021" - -[dependencies] -clap = { version = "4.5.7", features = ["derive", "env"] } diff --git a/src/tools/rustc-perf-wrapper/README.md b/src/tools/rustc-perf-wrapper/README.md deleted file mode 100644 index d7655459a2fe..000000000000 --- a/src/tools/rustc-perf-wrapper/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# rustc-perf wrapper -Utility tool for invoking [`rustc-perf`](https://github.com/rust-lang/rustc-perf) for benchmarking/profiling -a stage1/2 compiler built by bootstrap using `x perf -- `. diff --git a/src/tools/rustc-perf-wrapper/src/config.rs b/src/tools/rustc-perf-wrapper/src/config.rs deleted file mode 100644 index a88abfe47237..000000000000 --- a/src/tools/rustc-perf-wrapper/src/config.rs +++ /dev/null @@ -1,45 +0,0 @@ -use std::fmt::{Display, Formatter}; - -#[derive(Clone, Copy, Debug, clap::ValueEnum)] -#[value(rename_all = "PascalCase")] -pub enum Profile { - Check, - Debug, - Doc, - Opt, - Clippy, -} - -impl Display for Profile { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - let name = match self { - Profile::Check => "Check", - Profile::Debug => "Debug", - Profile::Doc => "Doc", - Profile::Opt => "Opt", - Profile::Clippy => "Clippy", - }; - f.write_str(name) - } -} - -#[derive(Clone, Copy, Debug, clap::ValueEnum)] -#[value(rename_all = "PascalCase")] -pub enum Scenario { - Full, - IncrFull, - IncrUnchanged, - IncrPatched, -} - -impl Display for Scenario { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - let name = match self { - Scenario::Full => "Full", - Scenario::IncrFull => "IncrFull", - Scenario::IncrUnchanged => "IncrUnchanged", - Scenario::IncrPatched => "IncrPatched", - }; - f.write_str(name) - } -} diff --git a/src/tools/rustc-perf-wrapper/src/main.rs b/src/tools/rustc-perf-wrapper/src/main.rs deleted file mode 100644 index e6c885e23dee..000000000000 --- a/src/tools/rustc-perf-wrapper/src/main.rs +++ /dev/null @@ -1,178 +0,0 @@ -use std::fs::create_dir_all; -use std::path::{Path, PathBuf}; -use std::process::Command; - -use clap::Parser; - -use crate::config::{Profile, Scenario}; - -mod config; - -/// Performs profiling or benchmarking with [`rustc-perf`](https://github.com/rust-lang/rustc-perf) -/// using a locally built compiler. -#[derive(Debug, clap::Parser)] -// Hide arguments from BuildContext in the default usage string. -// Clap does not seem to have a way of disabling the usage of these arguments. -#[clap(override_usage = "rustc-perf-wrapper [OPTIONS] ")] -pub struct Args { - #[clap(subcommand)] - cmd: PerfCommand, - - #[clap(flatten)] - ctx: BuildContext, -} - -#[derive(Debug, clap::Parser)] -enum PerfCommand { - /// Run `profile_local eprintln`. - /// This executes the compiler on the given benchmarks and stores its stderr output. - Eprintln { - #[clap(flatten)] - opts: SharedOpts, - }, - /// Run `profile_local samply` - /// This executes the compiler on the given benchmarks and profiles it with `samply`. - /// You need to install `samply`, e.g. using `cargo install samply`. - Samply { - #[clap(flatten)] - opts: SharedOpts, - }, - /// Run `profile_local cachegrind`. - /// This executes the compiler on the given benchmarks under `Cachegrind`. - Cachegrind { - #[clap(flatten)] - opts: SharedOpts, - }, - Benchmark { - /// Identifier to associate benchmark results with - id: String, - - #[clap(flatten)] - opts: SharedOpts, - }, - Compare { - /// The name of the base artifact to be compared. - base: String, - - /// The name of the modified artifact to be compared. - modified: String, - }, -} - -#[derive(Debug, clap::Parser)] -struct SharedOpts { - /// Select the benchmarks that you want to run (separated by commas). - /// If unspecified, all benchmarks will be executed. - #[clap(long, global = true, value_delimiter = ',')] - include: Vec, - - /// Select the benchmarks matching a prefix in this comma-separated list that you don't want to run. - #[clap(long, global = true, value_delimiter = ',')] - exclude: Vec, - - /// Select the scenarios that should be benchmarked. - #[clap( - long, - global = true, - value_delimiter = ',', - default_value = "Full,IncrFull,IncrUnchanged,IncrPatched" - )] - scenarios: Vec, - /// Select the profiles that should be benchmarked. - #[clap(long, global = true, value_delimiter = ',', default_value = "Check,Debug,Opt")] - profiles: Vec, -} - -/// These arguments are mostly designed to be passed from bootstrap, not by users -/// directly. -#[derive(Debug, clap::Parser)] -struct BuildContext { - /// Compiler binary that will be benchmarked/profiled. - #[clap(long, hide = true, env = "RUSTC_REAL")] - compiler: PathBuf, - /// rustc-perf collector binary that will be used for running benchmarks/profilers. - #[clap(long, hide = true, env = "PERF_COLLECTOR")] - collector: PathBuf, - /// Directory where to store results. - #[clap(long, hide = true, env = "PERF_RESULT_DIR")] - results_dir: PathBuf, -} - -fn main() { - let args = Args::parse(); - run(args); -} - -fn run(args: Args) { - let mut cmd = Command::new(args.ctx.collector); - let db_path = args.ctx.results_dir.join("results.db"); - - match &args.cmd { - PerfCommand::Eprintln { opts } - | PerfCommand::Samply { opts } - | PerfCommand::Cachegrind { opts } => { - cmd.arg("profile_local"); - cmd.arg(match &args.cmd { - PerfCommand::Eprintln { .. } => "eprintln", - PerfCommand::Samply { .. } => "samply", - PerfCommand::Cachegrind { .. } => "cachegrind", - _ => unreachable!(), - }); - - cmd.arg("--out-dir").arg(&args.ctx.results_dir); - - apply_shared_opts(&mut cmd, opts); - execute_benchmark(&mut cmd, &args.ctx.compiler); - - println!("You can find the results at `{}`", args.ctx.results_dir.display()); - } - PerfCommand::Benchmark { id, opts } => { - cmd.arg("bench_local"); - cmd.arg("--db").arg(&db_path); - cmd.arg("--id").arg(id); - - apply_shared_opts(&mut cmd, opts); - create_dir_all(&args.ctx.results_dir).unwrap(); - execute_benchmark(&mut cmd, &args.ctx.compiler); - } - PerfCommand::Compare { base, modified } => { - cmd.arg("bench_cmp"); - cmd.arg("--db").arg(&db_path); - cmd.arg(base).arg(modified); - - create_dir_all(&args.ctx.results_dir).unwrap(); - cmd.status().expect("error while running rustc-perf bench_cmp"); - } - } -} - -fn apply_shared_opts(cmd: &mut Command, opts: &SharedOpts) { - if !opts.include.is_empty() { - cmd.arg("--include").arg(opts.include.join(",")); - } - if !opts.exclude.is_empty() { - cmd.arg("--exclude").arg(opts.exclude.join(",")); - } - if !opts.profiles.is_empty() { - cmd.arg("--profiles") - .arg(opts.profiles.iter().map(|p| p.to_string()).collect::>().join(",")); - } - if !opts.scenarios.is_empty() { - cmd.arg("--scenarios") - .arg(opts.scenarios.iter().map(|p| p.to_string()).collect::>().join(",")); - } -} - -fn execute_benchmark(cmd: &mut Command, compiler: &Path) { - cmd.arg(compiler); - println!("Running `rustc-perf` using `{}`", compiler.display()); - - const MANIFEST_DIR: &str = env!("CARGO_MANIFEST_DIR"); - - let rustc_perf_dir = Path::new(MANIFEST_DIR).join("../rustc-perf"); - - // We need to set the working directory to `src/tools/perf`, so that it can find the directory - // with compile-time benchmarks. - let cmd = cmd.current_dir(rustc_perf_dir); - cmd.status().expect("error while running rustc-perf collector"); -} diff --git a/triagebot.toml b/triagebot.toml index 49cf1213987a..61f85e84dc78 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -385,7 +385,6 @@ trigger_files = [ "src/tools/tidy", "src/tools/rustdoc-gui-test", "src/tools/libcxx-version", - "src/tools/rustc-perf-wrapper", "x.py", "x", "x.ps1"