Skip to content

Commit 210e162

Browse files
Add example for profiling diff locally
Added an example for profiling an external crate diff locally.
1 parent e381c7a commit 210e162

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/profiling/with_rustc_perf.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,24 @@ You can use the following options for the `x perf` command, which mirror the cor
2828
- `--profiles`: Select profiles (`Check`, `Debug`, `Opt`, `Doc`) which should be profiled/benchmarked.
2929
- `--scenarios`: Select scenarios (`Full`, `IncrFull`, `IncrPatched`, `IncrUnchanged`) which should be profiled/benchmarked.
3030

31+
## Example profiling diff for external crates
32+
It can be of interest to generate a local diff for two commits of the compiler for external crates.
33+
To start, in the `rustc-perf` repo, build the collector, which runs the Rust compiler benchmarks as follows.
34+
```
35+
cargo build --release -p collector
36+
```
37+
After this the collector can be located in `.\target\release\collector`, can be run locally with `bench_local` and expects the following arguments:
38+
- `<PROFILE>`: Profiler selection for how performance should be measured. For this example we will use Cachegrind.
39+
- `<RUSTC>`: The Rust compiler revision to benchmark, specified as a commit SHA from `rust-lang/rust`.
40+
Optional arguments allow running profiles and scenarios as described above. `--include` in `x perf` is instead `--exact-match`. More information regarding the mandatory and
41+
optional arguments can be found in the [rustc-perf-readme-profilers].
42+
43+
Then, for the case of generating a profile diff for the crate `serve_derive-1.0.136`, for two commits `<SHA1>` and `<SHA2>` in the `rust-lang/rust` repository, run the following
44+
```
45+
./target/release/collector profile_local cachegrind +<SHA1> --rustc2 +<SHA2> --exact-match serde_derive-1.0.136 --profiles Check --scenarios IncrUnchanged
46+
```
47+
48+
3149
[samply]: https://github.com/mstange/samply
3250
[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
3351
[rustc-perf]: https://github.com/rust-lang/rustc-perf

0 commit comments

Comments
 (0)