From 4e4abbb1e6e45933cb6dc837f83b0bd12a09d971 Mon Sep 17 00:00:00 2001 From: Mattias Petersson Date: Sun, 14 Dec 2025 17:23:23 +0100 Subject: [PATCH 1/2] Add example for profiling diff locally Added an example for profiling an external crate diff locally. The original issue also mentions that the debuginfo-level = 1 should be highlighted, but that has been solved by a different commit and as such was not included here. --- 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 c47fed24e6..19935d3d26 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 From cadcc715270380875d5b73e6a7ef734922cd72f1 Mon Sep 17 00:00:00 2001 From: Mattias Petersson Date: Sun, 28 Dec 2025 16:56:17 +0100 Subject: [PATCH 2/2] Fix commit according to PR review Changed so cargo specifies the binary collector, removing the need to link to its local binary. Clarified that the SHAs should be from the rustc-repo, but the command should be ran in the rustc-perf repo. --- src/profiling/with_rustc_perf.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/profiling/with_rustc_perf.md b/src/profiling/with_rustc_perf.md index 19935d3d26..e889b5d9d8 100644 --- a/src/profiling/with_rustc_perf.md +++ b/src/profiling/with_rustc_perf.md @@ -34,15 +34,15 @@ To start, in the `rustc-perf` repo, build the collector, which runs the Rust com ``` 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: +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. `--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 +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, run the following in the `rustc-perf` repo (where the collector was built in the previous step): ``` -./target/release/collector profile_local cachegrind + --rustc2 + --exact-match serde_derive-1.0.136 --profiles Check --scenarios IncrUnchanged +cargo run --release --bin collector profile_local cachegrind + --rustc2 + --exact-match serde_derive-1.0.136 --profiles Check --scenarios IncrUnchanged ```