Add a x perf
command for integrating bootstrap with rustc-perf
by Kobzol · Pull Request #126318 · rust-lang/rust (original) (raw)
This PR adds a new x perf
command to bootstrap. The idea is to let rustc developers profile (profile_local
) and benchmark (bench_local
) a stage1/stage2 compiler directly from within rust
.
Before, if you wanted to use rustc-perf
, you had to clone it, set it up, copy the rustc
sysroot after every change to rust
etc. This is an attempt to automate that.
I opened this PR mostly for discussion. My idea is to offer an interface that looks something like this (a random sample of commands):
x perf --stage 2 profile eprintln x perf --stage1 profile cachegrind x perf benchmark --id baseline x perf benchmark --id after-edit x perf cmp baseline after-edit
In this PR, I'd like to only implement the simplest case (profile_local (eprintln)
), because that only requires a single sysroot (you don't compare anything), and it's relatively easy to set up. Also, I'd like to avoid forcing developers to deal with the rustc-perf UI, so more complex use-cases (like benchmarking two sysroots and comparing the results) should probably wait for rust-lang/rustc-perf#1734 (which is hopefully coming along soon-ish).
I'm not sure if it's better to do this in bootstrap directly, or if I should create some shim tool that will receive a rustc
sysroot, and offer a simplified CLI on top of rustc-perf
.
Why is a separate CLI needed?
We definitely need to add some support to bootstrap to automate preparing rustc-perf
and the rustc
sysroot, but in theory after that we could just let people invoke rustc-perf
manually. While that is definitely possible, you'd need to manually figure out where is your sysroot located, which seems annoying to me. The rustc-perf
CLI is also relatively complex, and for this use-case it makes sense to only use a subset of it. So I thought that it would be better to offer a simplified interface on top of it that would make life easier for contributors. But maybe it's not worth it.
CC @onur-ozkan