Remove the rustc-perf-wrapper
tool
This commit is contained in:
parent
22e44919c5
commit
c73ed895c7
8 changed files with 0 additions and 243 deletions
|
@ -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"
|
||||
|
|
|
@ -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",
|
||||
]
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
[package]
|
||||
name = "rustc-perf-wrapper"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.5.7", features = ["derive", "env"] }
|
|
@ -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 -- <command>`.
|
|
@ -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)
|
||||
}
|
||||
}
|
|
@ -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] <COMMAND>")]
|
||||
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<String>,
|
||||
|
||||
/// 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<String>,
|
||||
|
||||
/// Select the scenarios that should be benchmarked.
|
||||
#[clap(
|
||||
long,
|
||||
global = true,
|
||||
value_delimiter = ',',
|
||||
default_value = "Full,IncrFull,IncrUnchanged,IncrPatched"
|
||||
)]
|
||||
scenarios: Vec<Scenario>,
|
||||
/// Select the profiles that should be benchmarked.
|
||||
#[clap(long, global = true, value_delimiter = ',', default_value = "Check,Debug,Opt")]
|
||||
profiles: Vec<Profile>,
|
||||
}
|
||||
|
||||
/// 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::<Vec<_>>().join(","));
|
||||
}
|
||||
if !opts.scenarios.is_empty() {
|
||||
cmd.arg("--scenarios")
|
||||
.arg(opts.scenarios.iter().map(|p| p.to_string()).collect::<Vec<_>>().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");
|
||||
}
|
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue