@@ -152,7 +152,9 @@ Rust code being written today.
152
152
153
153
## Add a new benchmark
154
154
155
- - Decide on which category it belongs to.
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.
156
158
- If it's a third-party crate:
157
159
- If you are keen: talk with a maintainer of the crate to see if there is
158
160
anything we should be aware of when using this crate as a compile-time
@@ -161,8 +163,10 @@ Rust code being written today.
161
163
- Download it with ` collector download -c $CATEGORY crate $NAME $VERSION ` .
162
164
The ` $CATEGORY ` is probably ` primary ` .
163
165
- It makes it easier for reviewers if you split things into two commits.
164
- - In the first commit, just add the new code.
166
+ - In the first commit, just add the code for the entire benchmark .
165
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.
166
170
- In the second commit, do everything else.
167
171
- Add ` [workspace] ` to the very bottom of the benchmark's ` Cargo.toml ` , if
168
172
doesn't already have a ` [workspace] ` section. This means commands like
@@ -172,28 +176,32 @@ Rust code being written today.
172
176
` "cargo_toml" ` entry.
173
177
- If you get a "non-wrapped rustc" error when running it, you'll need a
174
178
` "touch_file" ` entry.
175
- - Consider adding one or more ` N-*.patch ` files.
179
+ - Consider adding one or more ` N-*.patch ` files for the ` IncrPatched `
180
+ scenario.
176
181
- If it's a primary benchmark, you should definitely do this.
177
- - Creating the diff against what you've committed so far might be useful.
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.
178
185
Use ` git diff ` from the repository root, or ` git diff --relative ` within
179
186
the benchmark directory. Copy the output into the ` N-*.patch ` file.
180
187
- Do a test run with an ` IncrPatched ` scenario to make sure the patch
181
- applies correctly.
188
+ applies correctly, e.g. `target/release/collector bench_local +nightly
189
+ --id Test --profiles=Check --scenarios=IncrPatched
190
+ --include=$NEW_BENCHMARK`
182
191
- ` git grep ` for occurrences of the old benchmark name (e.g. in
183
192
` .github/workflows/ci.yml ` or ` ci/check-*.sh ` ) and see if anything similar
184
193
needs doing for the new benchmark... usually not.
185
194
- Add the new entry to ` collector/benchmarks/README.md ` . Don't remove the
186
195
entry for the old benchmark yet.
187
196
- Compare benchmarking time for the old and new versions of the benchmark.
188
197
(It's useful to know if the new one is a lot slower than the old one.)
189
- - First, consider the entire compilation time with something like this, by
198
+ - First, measure the entire compilation time with something like this, by
190
199
doing this within the benchmark directory is good:
191
200
```
192
- CARGO_INCREMENTAL=0 cargo check ; \rm -rf target
193
- CARGO_INCREMENTAL=0 cargo build ; \rm -rf target
194
- CARGO_INCREMENTAL=0 cargo build --release ; \rm -rf target
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
195
204
```
196
- Put this info in the commit message.
197
205
- Second, compare the final crate time with these commands:
198
206
```
199
207
target/release/collector bench_local +nightly --id Test \
@@ -206,7 +214,7 @@ Rust code being written today.
206
214
- E.g. `futures` was changed so it's just a facade for a bunch of
207
215
sub-crates, and the final crate time became very similar to `helloworld`,
208
216
which wasn't interesting.
209
- - File a PR.
217
+ - File a PR, including the two sets of timing measurements in the description .
210
218
211
219
## Remove a benchmark
212
220
0 commit comments