Skip to content

Commit

Permalink
Auto merge of #128868 - s7tya:port-rustc-perf-cmp-command, r=Kobzol
Browse files Browse the repository at this point in the history
Port rustc perf cmp command

I've integrated bench_cmp and bench_local into the bootstrap.

r​? `@Kobzol`
  • Loading branch information
bors committed Aug 13, 2024
2 parents db5704f + ce1d7d1 commit e9e27ab
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/tools/rustc-perf
Submodule rustc-perf updated 65 files
+70 −47 .github/workflows/ci.yml
+8 −7 .github/workflows/nightly.yml
+300 −101 Cargo.lock
+73 −0 LICENSES/Apache-2.0.txt
+15 −0 LICENSES/LLVM-exception.txt
+9 −0 LICENSES/MIT.txt
+355 −0 LICENSES/MPL-2.0.txt
+37 −0 LICENSES/Unicode-DFS-2016.txt
+24 −0 LICENSES/Unlicense.txt
+4 −0 README.md
+35 −0 REUSE.toml
+1 −1 collector/Cargo.toml
+0 −25 collector/LICENSE
+0 −21 collector/compile-benchmarks/LICENSE.md
+7 −0 collector/compile-benchmarks/README.md
+290 −0 collector/compile-benchmarks/REUSE.toml
+1 −1 collector/compile-benchmarks/deeply-nested-multi/src/lib.rs
+1 −1 collector/compile-benchmarks/issue-46449/Cargo.lock
+1 −1 collector/compile-benchmarks/issue-46449/Cargo.toml
+1 −1 collector/src/artifact_stats.rs
+21 −2 collector/src/bin/collector.rs
+126 −0 collector/src/compare.rs
+1 −0 collector/src/lib.rs
+1 −1 collector/src/runtime/mod.rs
+1 −1 collector/src/utils/fs.rs
+2 −5 collector/src/utils/read2.rs
+2 −1 database/Cargo.toml
+1 −1 database/src/interpolate.rs
+34 −27 database/src/lib.rs
+113 −0 database/src/metric.rs
+30 −8 database/src/pool/postgres.rs
+5 −3 database/src/pool/sqlite.rs
+406 −0 database/src/selector.rs
+3 −3 site/Cargo.toml
+0 −21 site/LICENSE.md
+39 −0 site/frontend/src/pages/compare/benchmark-detail.scss
+4 −0 site/frontend/src/pages/compare/compile/table/benchmark-detail-graph.vue
+1 −39 site/frontend/src/pages/compare/compile/table/benchmark-detail.vue
+4 −0 site/frontend/src/pages/compare/runtime/benchmark-detail-graph.vue
+46 −6 site/frontend/src/pages/dashboard.ts
+28 −11 site/frontend/templates/pages/dashboard.html
+3 −3 site/src/api.rs
+4 −4 site/src/average.rs
+10 −114 site/src/comparison.rs
+0 −61 site/src/db.rs
+2 −2 site/src/github.rs
+12 −5 site/src/github/comparison_summary.rs
+0 −2 site/src/lib.rs
+12 −9 site/src/load.rs
+1 −1 site/src/request_handlers/bootstrap.rs
+37 −8 site/src/request_handlers/dashboard.rs
+2 −2 site/src/request_handlers/github.rs
+19 −8 site/src/request_handlers/graph.rs
+3 −4 site/src/request_handlers/self_profile.rs
+2 −1 site/src/request_handlers/status_page.rs
+11 −373 site/src/selector.rs
+3 −2 site/src/server.rs
+193 −0 triage/2024-06-18.md
+179 −0 triage/2024-06-23.md
+314 −0 triage/2024-07-02.md
+170 −0 triage/2024-07-09.md
+107 −0 triage/2024-07-16.md
+63 −0 triage/2024-07-21.md
+251 −0 triage/2024-07-30.md
+207 −0 triage/2024-08-06.md
116 changes: 81 additions & 35 deletions src/tools/rustc-perf-wrapper/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::fs::create_dir_all;
use std::path::PathBuf;
use std::process::Command;

Expand All @@ -17,9 +18,6 @@ pub struct Args {
#[clap(subcommand)]
cmd: PerfCommand,

#[clap(flatten)]
opts: SharedOpts,

#[clap(flatten)]
ctx: BuildContext,
}
Expand All @@ -28,22 +26,37 @@ pub struct Args {
enum PerfCommand {
/// Run `profile_local eprintln`.
/// This executes the compiler on the given benchmarks and stores its stderr output.
Eprintln,
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,
Samply {
#[clap(flatten)]
opts: SharedOpts,
},
/// Run `profile_local cachegrind`.
/// This executes the compiler on the given benchmarks under `Cachegrind`.
Cachegrind,
}

impl PerfCommand {
fn is_profiling(&self) -> bool {
match self {
PerfCommand::Eprintln | PerfCommand::Samply | PerfCommand::Cachegrind => true,
}
}
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)]
Expand All @@ -52,6 +65,11 @@ struct SharedOpts {
/// 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,
Expand Down Expand Up @@ -87,35 +105,67 @@ fn main() {

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 => {
cmd.arg("profile_local").arg("eprintln");
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::Samply => {
cmd.arg("profile_local").arg("samply");
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::Cachegrind => {
cmd.arg("profile_local").arg("cachegrind");
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");
}
}
if args.cmd.is_profiling() {
cmd.arg("--out-dir").arg(&args.ctx.results_dir);
}
}

if !args.opts.include.is_empty() {
cmd.arg("--include").arg(args.opts.include.join(","));
fn apply_shared_opts(cmd: &mut Command, opts: &SharedOpts) {
if !opts.include.is_empty() {
cmd.arg("--include").arg(opts.include.join(","));
}
if !args.opts.profiles.is_empty() {
if !opts.exclude.is_empty() {
cmd.arg("--exclude").arg(opts.exclude.join(","));
}
if !opts.profiles.is_empty() {
cmd.arg("--profiles")
.arg(args.opts.profiles.iter().map(|p| p.to_string()).collect::<Vec<_>>().join(","));
.arg(opts.profiles.iter().map(|p| p.to_string()).collect::<Vec<_>>().join(","));
}
if !args.opts.scenarios.is_empty() {
if !opts.scenarios.is_empty() {
cmd.arg("--scenarios")
.arg(args.opts.scenarios.iter().map(|p| p.to_string()).collect::<Vec<_>>().join(","));
.arg(opts.scenarios.iter().map(|p| p.to_string()).collect::<Vec<_>>().join(","));
}
cmd.arg(&args.ctx.compiler);
}

println!("Running `rustc-perf` using `{}`", args.ctx.compiler.display());
fn execute_benchmark(cmd: &mut Command, compiler: &PathBuf) {
cmd.arg(compiler);
println!("Running `rustc-perf` using `{}`", compiler.display());

const MANIFEST_DIR: &str = env!("CARGO_MANIFEST_DIR");

Expand All @@ -125,8 +175,4 @@ fn run(args: Args) {
// with compile-time benchmarks.
let cmd = cmd.current_dir(rustc_perf_dir);
cmd.status().expect("error while running rustc-perf collector");

if args.cmd.is_profiling() {
println!("You can find the results at `{}`", args.ctx.results_dir.display());
}
}

0 comments on commit e9e27ab

Please sign in to comment.