Skip to content

Commit 1ffdbaa

Browse files
committed
Add benchmark files and update documentation
1 parent 7f8fd76 commit 1ffdbaa

File tree

5 files changed

+44
-24
lines changed

5 files changed

+44
-24
lines changed

collector/compile-benchmarks/README.md

+22-22
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ They mostly consist of real-world crates.
3232
crate.
3333
- **helloworld**: A trivial program. Gives a lower bound on compile time.
3434
- **html5ever-0.26.0**: An HTML parser. Stresses macro parsing code.
35+
- **html5ever-0.31.0**: An HTML parser. Stresses macro parsing code.
3536
- **hyper-0.14.18**: A fairly large crate. Utilizes async/await, and used by
3637
many Rust programs. The crate uses cargo features to enable large portions of its
3738
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
39+
- **image-0.24.1**: Basic image processing functions and methods for
40+
converting to and from various image formats. Used often in graphics
4041
programming.
4142
- **libc-0.2.124**: An interface to `libc`. Contains many declarations of
4243
types, constants, and functions, but relatively little normal code. Stresses
@@ -78,7 +79,7 @@ compiler in interesting ways.
7879
caused [poor performance](https://github.com/rust-lang/rust/issues/32278) in
7980
the past.
8081
- **ctfe-stress-5**: A stress test for compile-time function evaluation.
81-
- **deeply-nested-multi**: A small program containing multiple examples
82+
- **deeply-nested-multi**: A small program containing multiple examples
8283
([one](https://github.com/rust-lang/rust/issues/38528),
8384
[two](https://github.com/rust-lang/rust/issues/72408),
8485
[three](https://github.com/rust-lang/rust/issues/75992))
@@ -100,7 +101,7 @@ compiler in interesting ways.
100101
- **many-assoc-items**: Contains a struct with many associated items, which
101102
caused [quadratic behavior](https://github.com/rust-lang/rust/issues/68957)
102103
in the past.
103-
- **match-stress**: Contains examples
104+
- **match-stress**: Contains examples
104105
(one involving [a huge enum](https://github.com/rust-lang/rust/issues/7462),
105106
one involving
106107
[`exhaustive_patterns`](https://github.com/rust-lang/rust/pull/79394)) of
@@ -119,7 +120,7 @@ compiler in interesting ways.
119120
- **tt-muncher**: Calls a quadratic TT muncher macro (based on `quote::quote!`)
120121
with a long input, which stresses macro expansion.
121122
- **tuple-stress**: Contains a single array of 65,535 nested `(i32, (f64, f64,
122-
f64))` tuples. The data was extracted and reduced from a [program dealing
123+
f64))` tuples. The data was extracted and reduced from a [program dealing
123124
with grid coordinates](https://github.com/urschrei/ostn15_phf) that was
124125
causing rustc to [run out of
125126
memory](https://github.com/rust-lang/rust/issues/36799).
@@ -196,25 +197,21 @@ Rust code being written today.
196197
`"touch_file"` entry.
197198
- 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.
198199
- Consider adding one or more `N-*.patch` files for the `IncrPatched`
199-
scenario.
200-
- If it's a primary benchmark, you should definitely do this.
201-
- These usually consist of a patch that adds a single
202-
`println!("testing");` statement somewhere.
203-
- Creating the patch against what you've committed so far might be useful.
204-
Use `git diff` from the repository root, or `git diff --relative` within
205-
the benchmark directory. Copy the output into the `N-*.patch` file.
206-
- Do a test run with an `IncrPatched` scenario to make sure the patch
207-
applies correctly, e.g. `target/release/collector bench_local +nightly
208-
--id Test --profiles=Check --scenarios=IncrPatched
209-
--include=$NEW_BENCHMARK`
200+
scenario. - If it's a primary benchmark, you should definitely do this. - These usually consist of a patch that adds a single
201+
`println!("testing");` statement somewhere. - Creating the patch against what you've committed so far might be useful.
202+
Use `git diff` from the repository root, or `git diff --relative` within
203+
the benchmark directory. Copy the output into the `N-*.patch` file. - Do a test run with an `IncrPatched` scenario to make sure the patch
204+
applies correctly, e.g. `target/release/collector bench_local +nightly
205+
--id Test --profiles=Check --scenarios=IncrPatched
206+
--include=$NEW_BENCHMARK`
210207
- Add the new entry to `collector/compile-benchmarks/README.md`.
211208
- Add a new licensing entry to `collector/compile-benchmarks/REUSE.toml` (see existing entries
212-
for inspiration).
209+
for inspiration).
213210
- If the benchmark is artificial, use the `MIT OR Apache-2.0` license and set Rust Project
214-
developers as the copyright owners (see e.g. `await-call-tree` as an example).
211+
developers as the copyright owners (see e.g. `await-call-tree` as an example).
215212
- If the benchmark is a third-party crate, make sure to use its license. Try to find the
216-
copyright owner in the crate's `COPYRIGHT` or `README` files. If you cannot find it, consider
217-
using the copyright owner `<crate-name> contributors`.
213+
copyright owner in the crate's `COPYRIGHT` or `README` files. If you cannot find it, consider
214+
using the copyright owner `<crate-name> contributors`.
218215
- `git add` the `Cargo.lock` file, if it's not already part of the
219216
benchmark's committed code.
220217
- If the benchmark has a `.gitignore` file that contains `Cargo.lock`,
@@ -262,8 +259,8 @@ Rust code being written today.
262259
of the two versions to make sure nothing outrageous has happened. Once the
263260
PR is merged, make sure it's running correctly.
264261
- Second, remove the old version of the benchmark.
265-
Doing it in two steps ensures we have continuity of profiling coverage in the
266-
case where something goes wrong.
262+
Doing it in two steps ensures we have continuity of profiling coverage in the
263+
case where something goes wrong.
267264
- Compare the benchmarking time of the two versions.
268265
- When adding the new version, for `perf-config.json` and the `N-*.patch`
269266
files, use the corresponding files for the old version as a starting point.
@@ -277,11 +274,13 @@ benchmarks in rustc-perf are verbatim copies of third-party crates. We
277274
periodically do a mass update of these benchmarks.
278275
279276
Benefits of this approach:
277+
280278
- We ensure we are measuring compilation of the crates most people are using.
281279
This is most relevant for popular crates.
282280
- We get coverage of newer language features.
283281
284282
Costs of this approach:
283+
285284
- It takes time and effort.
286285
- We lose some data continuity.
287286
- But the stable set of benchmarks used for the dashboard are not affected,
@@ -308,5 +307,6 @@ Costs of this approach:
308307
maintainers.
309308
310309
History:
310+
311311
- The first mass update of third-party crates occurred in [March/April
312312
2022](https://hackmd.io/d9uE7qgtTWKDLivy0uoVQw).

collector/compile-benchmarks/REUSE.toml

+5
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ path = "html5ever-0.26.0/**"
110110
SPDX-FileCopyrightText = "The html5ever Project Developers"
111111
SPDX-License-Identifier = "MIT OR Apache-2.0"
112112

113+
[[annotations]]
114+
path = "html5ever-0.31.0/**"
115+
SPDX-FileCopyrightText = "The html5ever Project Developers"
116+
SPDX-License-Identifier = "MIT OR Apache-2.0"
117+
113118
[[annotations]]
114119
path = "hyper-0.14.18/**"
115120
SPDX-FileCopyrightText = "hyper contributors"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/src/util/str.rs b/src/util/str.rs
2+
index 2c0ec3e2..a78ff669 100644
3+
--- a/src/util/str.rs
4+
+++ b/src/util/str.rs
5+
@@ -10,6 +10,7 @@
6+
use std::fmt;
7+
8+
pub(crate) fn to_escaped_string<T: fmt::Debug>(x: &T) -> String {
9+
+ println!("testing");
10+
// FIXME: don't allocate twice
11+
let string = format!("{x:?}");
12+
string.chars().flat_map(|c| c.escape_default()).collect()

collector/compile-benchmarks/html5ever-0.31.0/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,5 @@ version = "2.0.2"
8686

8787
[features]
8888
trace_tokenizer = []
89+
90+
[workspace]
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2-
"artifact": "library",
3-
"category": "primary"
2+
"touch_file": "src/lib.rs",
3+
"category": "primary",
4+
"artifact": "library"
45
}

0 commit comments

Comments
 (0)