From 210e1624d34df185254a560de66a282ae527c020 Mon Sep 17 00:00:00 2001 From: Mattias Petersson Date: Sun, 14 Dec 2025 17:23:23 +0100 Subject: [PATCH] Add example for profiling diff locally Added an example for profiling an external crate diff locally. --- src/profiling/with_rustc_perf.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/profiling/with_rustc_perf.md b/src/profiling/with_rustc_perf.md index c47fed24e..19935d3d2 100644 --- a/src/profiling/with_rustc_perf.md +++ b/src/profiling/with_rustc_perf.md @@ -28,6 +28,24 @@ You can use the following options for the `x perf` command, which mirror the cor - `--profiles`: Select profiles (`Check`, `Debug`, `Opt`, `Doc`) which should be profiled/benchmarked. - `--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. +To start, in the `rustc-perf` repo, build the collector, which runs the Rust compiler benchmarks as follows. +``` +cargo build --release -p collector +``` +After this the collector can be located in `.\target\release\collector`, can be run locally with `bench_local` and 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. `--include` in `x perf` is instead `--exact-match`. 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 `` in the `rust-lang/rust` repository, run the following +``` +./target/release/collector profile_local cachegrind + --rustc2 + --exact-match serde_derive-1.0.136 --profiles Check --scenarios IncrUnchanged +``` + + [samply]: https://github.com/mstange/samply [cachegrind]: https://www.cs.cmu.edu/afs/cs.cmu.edu/project/cmt-40/Nice/RuleRefinement/bin/valgrind-3.2.0/docs/html/cg-manual.html [rustc-perf]: https://github.com/rust-lang/rustc-perf