@@ -29,7 +29,7 @@ They mostly consist of real-world crates.
29
29
- ** html5ever-0.26.0** : An HTML parser. Stresses macro parsing code.
30
30
- ** hyper-0.14.18** : A fairly large crate. Utilizes async/await, and used by
31
31
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 ` .
33
33
- ** image-0.24.1** : Basic image processing functions and methods for
34
34
converting to and from various image formats. Used often in graphics
35
35
programming.
@@ -39,7 +39,7 @@ They mostly consist of real-world crates.
39
39
Rust programs.
40
40
- ** stm32f4-0.14.0** : A crate that has many thousands of blanket impl blocks.
41
41
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.
43
43
- ** syn-1.0.89** : A library for parsing Rust code. An important part of the Rust
44
44
ecosystem.
45
45
- ** unicode-normalization-0.1.19** : Unicode character composition and decomposition
@@ -121,7 +121,7 @@ compiler in interesting ways.
121
121
[ Stresses] ( https://github.com/rust-lang/rust/issues/58178 ) the borrow
122
122
checker's implementation of NLL.
123
123
124
- ** Stable**
124
+ ## Stable
125
125
126
126
These are benchmarks used in the
127
127
[ dashboard] ( https://perf.rust-lang.org/dashboard.html ) . They provide the
@@ -143,7 +143,96 @@ Rust code being written today.
143
143
- ** regex** : See above. This is an older version of the crate.
144
144
- ** piston-image** : See above. This is an older version of the ` image ` crate.
145
145
- ** 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 ` .
147
147
- ** syn** : See above. This is an older version (0.11.11) of the crate.
148
148
- ** tokio-webpush-simple** : A simple web server built with a very old version
149
149
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