From 328942672da88fecfdc04b488307d39ac2b5baf4 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Mon, 12 Jan 2026 22:15:18 +0200 Subject: [PATCH] sembr src/profiling/with_rustc_perf.md --- .../src/profiling/with_rustc_perf.md | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/profiling/with_rustc_perf.md b/src/doc/rustc-dev-guide/src/profiling/with_rustc_perf.md index 7c7639a1ac3d..de4cb9eae930 100644 --- a/src/doc/rustc-dev-guide/src/profiling/with_rustc_perf.md +++ b/src/doc/rustc-dev-guide/src/profiling/with_rustc_perf.md @@ -1,9 +1,11 @@ # Profiling with rustc-perf The [Rust benchmark suite][rustc-perf] provides a comprehensive way of profiling and benchmarking -the Rust compiler. You can find instructions on how to use the suite in its [manual][rustc-perf-readme]. +the Rust compiler. +You can find instructions on how to use the suite in its [manual][rustc-perf-readme]. -However, using the suite manually can be a bit cumbersome. To make this easier for `rustc` contributors, +However, using the suite manually can be a bit cumbersome. +To make this easier for `rustc` contributors, the compiler build system (`bootstrap`) also provides built-in integration with the benchmarking suite, which will download and build the suite for you, build a local compiler toolchain and let you profile it using a simplified command-line interface. @@ -14,8 +16,9 @@ You can use normal bootstrap flags for this command, such as `--stage 1` or `--s `x perf` currently supports the following commands: - `benchmark `: Benchmark the compiler and store the results under the passed `id`. - `compare `: Compare the benchmark results of two compilers with the two passed `id`s. -- `eprintln`: Just run the compiler and capture its `stderr` output. Note that the compiler normally does not print - anything to `stderr`, you might want to add some `eprintln!` calls to get any output. +- `eprintln`: Just run the compiler and capture its `stderr` output. + Note that the compiler normally does not print + anything to `stderr`, you might want to add some `eprintln!` calls to get any output. - `samply`: Profile the compiler using the [samply][samply] sampling profiler. - `cachegrind`: Use [Cachegrind][cachegrind] to generate a detailed simulated trace of the compiler's execution. @@ -29,15 +32,18 @@ You can use the following options for the `x perf` command, which mirror the cor - `--scenarios`: Select scenarios (`Full`, `IncrFull`, `IncrPatched`, `IncrUnchanged`) which should be profiled/benchmarked. ## Example profiling diff for external crates -It can be of interest to generate a local diff for two commits of the compiler for external crates. +It can be of interest to generate a local diff for two commits of the compiler for external crates. To start, in the `rustc-perf` repo, build the collector, which runs the Rust compiler benchmarks as follows. ``` cargo build --release -p collector ``` -The collector can then be run using cargo, specifying the collector binary. It expects the following arguments: -- ``: Profiler selection for how performance should be measured. For this example we will use Cachegrind. +The collector can then be run using cargo, specifying the collector binary. +It expects the following arguments: +- ``: Profiler selection for how performance should be measured. + For this example we will use Cachegrind. - ``: The Rust compiler revision to benchmark, specified as a commit SHA from `rust-lang/rust`. -Optional arguments allow running profiles and scenarios as described above. More information regarding the mandatory and +Optional arguments allow running profiles and scenarios as described above. +More information regarding the mandatory and optional arguments can be found in the [rustc-perf-readme-profilers]. Then, for the case of generating a profile diff for the crate `serve_derive-1.0.136`, for two commits `` and `` from the `rust-lang/rust` repository,