Skip to content

Commit e66a275

Browse files
committed
Add typenum to benchmark list
1 parent 2c8e569 commit e66a275

File tree

1 file changed

+85
-76
lines changed

1 file changed

+85
-76
lines changed

collector/compile-benchmarks/README.md

Lines changed: 85 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ They mostly consist of real-world crates.
3535
- **hyper-0.14.18**: A fairly large crate. Utilizes async/await, and used by
3636
many Rust programs. The crate uses cargo features to enable large portions of its
3737
structure and is built with `--features=client,http1,http2,server,stream`.
38-
- **image-0.24.1**: Basic image processing functions and methods for
39-
converting to and from various image formats. Used often in graphics
38+
- **image-0.24.1**: Basic image processing functions and methods for
39+
converting to and from various image formats. Used often in graphics
4040
programming.
4141
- **libc-0.2.124**: An interface to `libc`. Contains many declarations of
4242
types, constants, and functions, but relatively little normal code. Stresses
@@ -53,6 +53,8 @@ They mostly consist of real-world crates.
5353
built with `--features=stm32f410` to have faster benchmarking times.
5454
- **syn-1.0.89**: A library for parsing Rust code. An important part of the Rust
5555
ecosystem.
56+
- **typenum-1.17.0**: A library that encodes integer computation within the trait system. Serves as
57+
a stress test for the trait solver, but at the same time it is also a very popular crate.
5658
- **unicode-normalization-0.1.19**: Unicode character composition and decomposition
5759
utilities. Uses huge `match` statements that stress the compiler in unusual
5860
ways.
@@ -74,16 +76,18 @@ compiler in interesting ways.
7476
caused [poor performance](https://github.com/rust-lang/rust/issues/32278) in
7577
the past.
7678
- **ctfe-stress-5**: A stress test for compile-time function evaluation.
77-
- **deeply-nested-multi**: A small program containing multiple examples
79+
- **deeply-nested-multi**: A small program containing multiple examples
7880
([one](https://github.com/rust-lang/rust/issues/38528),
7981
[two](https://github.com/rust-lang/rust/issues/72408),
8082
[three](https://github.com/rust-lang/rust/issues/75992))
8183
of code that caused exponential behavior in the past.
8284
- **deep-vector**: A test containing a single large vector of zeroes, which
8385
caused [poor performance](https://github.com/rust-lang/rust/issues/20936) in
8486
the past. Stresses macro expansion and type inference.
85-
- **derive**: A large number of simple structs with a `#[derive]` attribute for common built-in traits such as Copy and Debug.
86-
- **externs**: A large number of extern functions has caused [slowdowns in the past](https://github.com/rust-lang/rust/pull/78448).
87+
- **derive**: A large number of simple structs with a `#[derive]` attribute for common built-in
88+
traits such as Copy and Debug.
89+
- **externs**: A large number of extern functions has
90+
caused [slowdowns in the past](https://github.com/rust-lang/rust/pull/78448).
8791
- **helloworld-tiny**: A trivial program optimized with flags that should reduce binary size.
8892
Gives a lower bound on compiled binary size.
8993
- **issue-46449**: A small program that caused [poor
@@ -96,7 +100,7 @@ compiler in interesting ways.
96100
- **many-assoc-items**: Contains a struct with many associated items, which
97101
caused [quadratic behavior](https://github.com/rust-lang/rust/issues/68957)
98102
in the past.
99-
- **match-stress**: Contains examples
103+
- **match-stress**: Contains examples
100104
(one involving [a huge enum](https://github.com/rust-lang/rust/issues/7462),
101105
one involving
102106
[`exhaustive_patterns`](https://github.com/rust-lang/rust/pull/79394)) of
@@ -169,90 +173,92 @@ Rust code being written today.
169173
crate, and secondary if it's a stress test or intended to catch specific
170174
regressions.
171175
- If it's a third-party crate:
172-
- If you are keen: talk with a maintainer of the crate to see if there is
173-
anything we should be aware of when using this crate as a compile-time
174-
benchmark.
175-
- Look at [crates.io](https://crates.io) to find the latest (non-prerelease) version.
176-
- Download it with `collector download -c $CATEGORY -a $ARTIFACT crate $NAME $VERSION`.
177-
The `$CATEGORY` is probably `primary`. `$ARTIFACT` is either `library` or `binary`, depending
178-
on what kind of artifact does the benchmark build.
176+
- If you are keen: talk with a maintainer of the crate to see if there is
177+
anything we should be aware of when using this crate as a compile-time
178+
benchmark.
179+
- Look at [crates.io](https://crates.io) to find the latest (non-prerelease) version.
180+
- Download it with `collector download -c $CATEGORY -a $ARTIFACT crate $NAME $VERSION`.
181+
The `$CATEGORY` is probably `primary`. `$ARTIFACT` is either `library` or `binary`, depending
182+
on what kind of artifact does the benchmark build.
179183
- It makes it easier for reviewers if you split things into two commits.
180184
- In the first commit, just add the code for the entire benchmark.
181-
- Do this by doing `git add` on the new directory.
182-
- There is no need to remove seemingly unnecessary files such as
183-
documentation or CI configuration.
185+
- Do this by doing `git add` on the new directory.
186+
- There is no need to remove seemingly unnecessary files such as
187+
documentation or CI configuration.
184188
- In the second commit, do everything else.
185-
- Add `[workspace]` to the very bottom of the benchmark's `Cargo.toml`, if
186-
doesn't already have a `[workspace]` section. This means commands like
187-
`cargo build` will work within the benchmark directory.
188-
- Add any necessary stuff to the `perf-config.json` file.
189-
- If the benchmark is a sub-crate within a top-level crate, you'll need a
190-
`"cargo_toml"` entry.
191-
- If you get a "non-wrapped rustc" error when running it, you'll need a
192-
`"touch_file"` entry.
193-
- See [`collector/src/benchmark/mod.rs`](https://github.com/rust-lang/rustc-perf/blob/12cb796f8a932a891b385ba23a36d78a2867ace1/collector/src/benchmark/mod.rs#L24-L27) for a complete reference.
194-
- Consider adding one or more `N-*.patch` files for the `IncrPatched`
195-
scenario.
196-
- If it's a primary benchmark, you should definitely do this.
197-
- These usually consist of a patch that adds a single
198-
`println!("testing");` statement somewhere.
199-
- Creating the patch against what you've committed so far might be useful.
200-
Use `git diff` from the repository root, or `git diff --relative` within
201-
the benchmark directory. Copy the output into the `N-*.patch` file.
202-
- Do a test run with an `IncrPatched` scenario to make sure the patch
203-
applies correctly, e.g. `target/release/collector bench_local +nightly
204-
--id Test --profiles=Check --scenarios=IncrPatched
205-
--include=$NEW_BENCHMARK`
206-
- Add the new entry to `collector/compile-benchmarks/README.md`.
207-
- `git add` the `Cargo.lock` file, if it's not already part of the
208-
benchmark's committed code.
209-
- If the benchmark has a `.gitignore` file that contains `Cargo.lock`,
210-
you'll need to comment out that line so that `Cargo.lock` gets uploaded
211-
in the PR.
189+
- Add `[workspace]` to the very bottom of the benchmark's `Cargo.toml`, if
190+
doesn't already have a `[workspace]` section. This means commands like
191+
`cargo build` will work within the benchmark directory.
192+
- Add any necessary stuff to the `perf-config.json` file.
193+
- If the benchmark is a sub-crate within a top-level crate, you'll need a
194+
`"cargo_toml"` entry.
195+
- If you get a "non-wrapped rustc" error when running it, you'll need a
196+
`"touch_file"` entry.
197+
-
198+
See [`collector/src/benchmark/mod.rs`](https://github.com/rust-lang/rustc-perf/blob/12cb796f8a932a891b385ba23a36d78a2867ace1/collector/src/benchmark/mod.rs#L24-L27)
199+
for a complete reference.
200+
- Consider adding one or more `N-*.patch` files for the `IncrPatched`
201+
scenario.
202+
- If it's a primary benchmark, you should definitely do this.
203+
- These usually consist of a patch that adds a single
204+
`println!("testing");` statement somewhere.
205+
- Creating the patch against what you've committed so far might be useful.
206+
Use `git diff` from the repository root, or `git diff --relative` within
207+
the benchmark directory. Copy the output into the `N-*.patch` file.
208+
- Do a test run with an `IncrPatched` scenario to make sure the patch
209+
applies correctly, e.g. `target/release/collector bench_local +nightly
210+
--id Test --profiles=Check --scenarios=IncrPatched
211+
--include=$NEW_BENCHMARK`
212+
- Add the new entry to `collector/compile-benchmarks/README.md`.
213+
- `git add` the `Cargo.lock` file, if it's not already part of the
214+
benchmark's committed code.
215+
- If the benchmark has a `.gitignore` file that contains `Cargo.lock`,
216+
you'll need to comment out that line so that `Cargo.lock` gets uploaded
217+
in the PR.
212218
- Consider the benchmarking time for the benchmark.
213-
- First, measure the entire compilation time with something like this, by
214-
doing this within the benchmark directory is good:
215-
```
216-
CARGO_INCREMENTAL=0 cargo check ; cargo clean
217-
CARGO_INCREMENTAL=0 cargo build ; cargo clean
218-
CARGO_INCREMENTAL=0 cargo build --release ; cargo clean
219-
```
220-
- Second, compare the final crate time with these commands:
221-
```
222-
target/release/collector bench_local +nightly --id Test \
223-
--profiles=Check,Debug,Opt --scenarios=Full --include=$NEW,helloworld
224-
target/release/site results.db
225-
```
226-
(See [here](../../site/README.md) for instructions on how to build the website).
227-
Then switch to wall-times, compare `Test` against itself, and toggle the
228-
"Show non-relevant results"/"Display raw data" check boxes to make sure it
229-
hasn't changed drastically.
230-
- E.g. `futures` was changed so it's just a facade for a bunch of
231-
sub-crates, and the final crate time became very similar to `helloworld`,
232-
which wasn't interesting.
219+
- First, measure the entire compilation time with something like this, by
220+
doing this within the benchmark directory is good:
221+
```
222+
CARGO_INCREMENTAL=0 cargo check ; cargo clean
223+
CARGO_INCREMENTAL=0 cargo build ; cargo clean
224+
CARGO_INCREMENTAL=0 cargo build --release ; cargo clean
225+
```
226+
- Second, compare the final crate time with these commands:
227+
```
228+
target/release/collector bench_local +nightly --id Test \
229+
--profiles=Check,Debug,Opt --scenarios=Full --include=$NEW,helloworld
230+
target/release/site results.db
231+
```
232+
(See [here](../../site/README.md) for instructions on how to build the website).
233+
Then switch to wall-times, compare `Test` against itself, and toggle the
234+
"Show non-relevant results"/"Display raw data" check boxes to make sure it
235+
hasn't changed drastically.
236+
- E.g. `futures` was changed so it's just a facade for a bunch of
237+
sub-crates, and the final crate time became very similar to `helloworld`,
238+
which wasn't interesting.
233239
- File a PR, including the two sets of timing measurements in the description.
234240
235241
## Remove a benchmark
236242
237243
- It makes it easier for reviewers if you split things into two commits.
238244
- In the first commit just remove the old code.
239-
- Do this with `git rm -r` on the directory.
245+
- Do this with `git rm -r` on the directory.
240246
- In the second commit do everything else.
241-
- Remove the entry from `collector/compile-benchmarks/README.md`.
242-
- `git grep` for occurrences of the old benchmark name (e.g. in
243-
`.github/workflows/ci.yml` or `ci/check-*.sh`) and see if anything needs
244-
changing... usually not.
247+
- Remove the entry from `collector/compile-benchmarks/README.md`.
248+
- `git grep` for occurrences of the old benchmark name (e.g. in
249+
`.github/workflows/ci.yml` or `ci/check-*.sh`) and see if anything needs
250+
changing... usually not.
245251
- File a PR.
246252
247253
## Update a benchmark
248254
249255
- Do this in two steps.
250-
- First add the new version of the benchmark. Compare the benchmarking time
251-
of the two versions to make sure nothing outrageous has happened. Once the
252-
PR is merged, make sure it's running correctly.
253-
- Second, remove the old version of the benchmark.
254-
Doing it in two steps ensures we have continuity of profiling coverage in the
255-
case where something goes wrong.
256+
- First add the new version of the benchmark. Compare the benchmarking time
257+
of the two versions to make sure nothing outrageous has happened. Once the
258+
PR is merged, make sure it's running correctly.
259+
- Second, remove the old version of the benchmark.
260+
Doing it in two steps ensures we have continuity of profiling coverage in the
261+
case where something goes wrong.
256262
- Compare the benchmarking time of the two versions.
257263
- When adding the new version, for `perf-config.json` and the `N-*.patch`
258264
files, use the corresponding files for the old version as a starting point.
@@ -266,15 +272,17 @@ benchmarks in rustc-perf are verbatim copies of third-party crates. We
266272
periodically do a mass update of these benchmarks.
267273
268274
Benefits of this approach:
275+
269276
- We ensure we are measuring compilation of the crates most people are using.
270277
This is most relevant for popular crates.
271278
- We get coverage of newer language features.
272279
273280
Costs of this approach:
281+
274282
- It takes time and effort.
275283
- We lose some data continuity.
276-
- But the stable set of benchmarks used for the dashboard are not affected,
277-
and they provide the greatest continuity.
284+
- But the stable set of benchmarks used for the dashboard are not affected,
285+
and they provide the greatest continuity.
278286
- If the code hasn't changed much, it won't have much effect.
279287
280288
## Update policy
@@ -297,5 +305,6 @@ Costs of this approach:
297305
maintainers.
298306
299307
History:
308+
300309
- The first mass update of third-party crates occurred in [March/April
301310
2022](https://hackmd.io/d9uE7qgtTWKDLivy0uoVQw).

0 commit comments

Comments
 (0)