@@ -29,7 +29,7 @@ They mostly consist of real-world crates.
2929- ** html5ever-0.26.0** : An HTML parser. Stresses macro parsing code.
3030- ** hyper-0.14.18** : A fairly large crate. Utilizes async/await, and used by
3131 many Rust programs. The crate uses cargo features to enable large portions of its
32- structure and is built with ` --features client,http1,http2,server,stream ` .
32+ structure and is built with ` --features= client,http1,http2,server,stream ` .
3333- ** image-0.24.1** : Basic image processing functions and methods for
3434 converting to and from various image formats. Used often in graphics
3535 programming.
@@ -39,7 +39,7 @@ They mostly consist of real-world crates.
3939 Rust programs.
4040- ** stm32f4-0.14.0** : A crate that has many thousands of blanket impl blocks.
4141 It uses cargo features to enable large portions of its structure and is
42- built with ` --features stm32f410 ` to have faster benchmarking times.
42+ built with ` --features= stm32f410 ` to have faster benchmarking times.
4343- ** syn-1.0.89** : A library for parsing Rust code. An important part of the Rust
4444 ecosystem.
4545- ** unicode-normalization-0.1.19** : Unicode character composition and decomposition
@@ -121,7 +121,7 @@ compiler in interesting ways.
121121 [ Stresses] ( https://github.com/rust-lang/rust/issues/58178 ) the borrow
122122 checker's implementation of NLL.
123123
124- ** Stable**
124+ ## Stable
125125
126126These are benchmarks used in the
127127[ dashboard] ( https://perf.rust-lang.org/dashboard.html ) . They provide the
@@ -143,7 +143,96 @@ Rust code being written today.
143143- ** regex** : See above. This is an older version of the crate.
144144- ** piston-image** : See above. This is an older version of the ` image ` crate.
145145- ** style-servo** : An old version of Servo's ` style ` crate. A large crate, and
146- one used by old versions of Firefox.
146+ one used by old versions of Firefox. Built with ` --features=gecko ` .
147147- ** syn** : See above. This is an older version (0.11.11) of the crate.
148148- ** tokio-webpush-simple** : A simple web server built with a very old version
149149 of tokio. Uses futures a lot, but doesn't use ` async ` /` await ` .
150+
151+ # How to update/add/remove benchmarks
152+
153+ ## Add a new benchmark
154+
155+ - Decide on which category it belongs to. Probably primary if it's a real-world
156+ crate, and secondary if it's a stress test or intended to catch specific
157+ regressions.
158+ - If it's a third-party crate:
159+ - If you are keen: talk with a maintainer of the crate to see if there is
160+ anything we should be aware of when using this crate as a compile-time
161+ benchmark.
162+ - Look at [ crates.io] ( https://crates.io ) to find the latest (non-prerelease) version.
163+ - Download it with ` collector download -c $CATEGORY crate $NAME $VERSION ` .
164+ The ` $CATEGORY ` is probably ` primary ` .
165+ - It makes it easier for reviewers if you split things into two commits.
166+ - In the first commit, just add the code for the entire benchmark.
167+ - Do this by doing ` git add ` on the new directory.
168+ - There is no need to remove seemingly unnecessary files such as
169+ documentation or CI configuration.
170+ - In the second commit, do everything else.
171+ - Add ` [workspace] ` to the very bottom of the benchmark's ` Cargo.toml ` , if
172+ doesn't already have a ` [workspace] ` section. This means commands like
173+ ` cargo build ` will work within the benchmark directory.
174+ - Add any necessary stuff to the ` perf-config.json ` file.
175+ - If the benchmark is a sub-crate within a top-level crate, you'll need a
176+ ` "cargo_toml" ` entry.
177+ - If you get a "non-wrapped rustc" error when running it, you'll need a
178+ ` "touch_file" ` entry.
179+ - Consider adding one or more ` N-*.patch ` files for the ` IncrPatched `
180+ scenario.
181+ - If it's a primary benchmark, you should definitely do this.
182+ - These usually consist of a patch that adds a single
183+ ` println!("testing"); ` statement somewhere.
184+ - Creating the patch against what you've committed so far might be useful.
185+ Use ` git diff ` from the repository root, or ` git diff --relative ` within
186+ the benchmark directory. Copy the output into the ` N-*.patch ` file.
187+ - Do a test run with an ` IncrPatched ` scenario to make sure the patch
188+ applies correctly, e.g. `target/release/collector bench_local +nightly
189+ --id Test --profiles=Check --scenarios=IncrPatched
190+ --include=$NEW_BENCHMARK`
191+ - ` git grep ` for occurrences of the old benchmark name (e.g. in
192+ ` .github/workflows/ci.yml ` or ` ci/check-*.sh ` ) and see if anything similar
193+ needs doing for the new benchmark... usually not.
194+ - Add the new entry to ` collector/benchmarks/README.md ` . Don't remove the
195+ entry for the old benchmark yet.
196+ - Compare benchmarking time for the old and new versions of the benchmark.
197+ (It's useful to know if the new one is a lot slower than the old one.)
198+ - First, measure the entire compilation time with something like this, by
199+ doing this within the benchmark directory is good:
200+ ```
201+ CARGO_INCREMENTAL=0 cargo check ; cargo clean
202+ CARGO_INCREMENTAL=0 cargo build ; cargo clean
203+ CARGO_INCREMENTAL=0 cargo build --release ; cargo clean
204+ ```
205+ - Second, compare the final crate time with these commands:
206+ ```
207+ target/release/collector bench_local +nightly --id Test \
208+ --profiles=Check,Debug,Opt --scenarios=Full --include=$OLD,$NEW,helloworld
209+ target/release/site results.db
210+ ```
211+ Then switch to wall-times, compare `Test` against itself, and toggle the
212+ "Show non-relevant results"/"Display raw data" check boxes to make sure it
213+ hasn't changed drastically.
214+ - E.g. `futures` was changed so it's just a facade for a bunch of
215+ sub-crates, and the final crate time became very similar to `helloworld`,
216+ which wasn't interesting.
217+ - File a PR, including the two sets of timing measurements in the description.
218+
219+ ## Remove a benchmark
220+
221+ - It makes it easier for reviewers if you split things into two commits.
222+ - In the first commit just remove the old code.
223+ - Do this with `git rm -r` on the directory.
224+ - In the second commit do everything else.
225+ - Remove the entry from `collector/benchmarks/README.md`.
226+ - `git grep` for occurrences of the old benchmark name (e.g. in
227+ `.github/workflows/ci.yml` or `ci/check-*.sh`) and see if anything needs
228+ changing... usually not.
229+ - File a PR.
230+
231+ ## Update a benchmark
232+
233+ - Do this in two steps. First add the new version of the benchmark. Once the PR
234+ is merged, make sure it's running correctly. Second, remove the old version
235+ of the benchmark. Doing it in two steps ensures we have continuity of
236+ profiling coverage in the case where something goes wrong.
237+ - When adding the new version, for `perf-config.json` and the `N-*.patch`
238+ files, use the corresponding files for the old version as a starting point.
0 commit comments