Skip to content

Commit 9ef06fd

Browse files
committed
Address review comments
1 parent 35e1246 commit 9ef06fd

File tree

13 files changed

+86
-66
lines changed

13 files changed

+86
-66
lines changed

collector/benchmarks/README.md

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,33 @@ The suite changes over time. Sometimes the code for a benchmark is updated, in
77
which case a small suffix will be added (starting with "-2", then "-3", and so
88
on.)
99

10-
## Real programs that are important
10+
There are two categories of benchmarks, **Primary** and **Secondary**.
11+
12+
## Primary
1113

1214
These are real programs that are important in some way, and worth tracking.
15+
They mostly consist of real-world crates.
1316

1417
- **cargo**: The Rust package manager. An important program in the Rust
1518
ecosystem.
1619
- **clap-rs**: A command line argument parser. A crate used by many Rust
1720
programs.
1821
- **cranelift-codegen**: The largest crate from a code generator. Used by
1922
Firefox.
23+
- **diesel**: A type save SQL query builder. Utilizes the type system to
24+
ensure a lot of invariants. Stresses anything related to resolving
25+
trait bounds, by having a lot of trait impls for a large number of different
26+
types.
27+
- **encoding**: Character encoding support. Contains some large tables.
2028
- **futures**: A futures implementation. Used by many Rust programs.
2129
- **helloworld**: A trivial program. Gives a lower bound on compile time.
30+
- **html5ever**: An HTML parser. Stresses macro parsing code significantly.
2231
- **hyper-2**: A fairly large crate. Utilizes async/await, and used by
2332
many Rust programs.
33+
- **inflate**: An old implementation of the DEFLATE algorithm. Stresses the
34+
compiler in certain ways.
35+
- **keccak**: A cryptography algorithm. Contains a very high number of locals
36+
and basic blocks.
2437
- **piston-image**: A modular game engine. An interesting Rust program.
2538
- **regex**: A regular expression parser. Used by many Rust programs.
2639
- **ripgrep**: A line-oriented search tool. A widely-used utility.
@@ -33,40 +46,20 @@ These are real programs that are important in some way, and worth tracking.
3346
ecosystem.
3447
- **tokio-webpush-simple**: A simple web server built with tokio. Uses futures
3548
a lot.
36-
- **webrender**: A web renderer. Used by Firefox and Servo.
37-
- **webrender-wrench**: WebRender's test bench. An executable pulling in large
38-
dependencies.
39-
40-
## Real programs that stress the compiler
41-
42-
These are real programs that are known to stress the compiler in interesting
43-
ways.
44-
45-
- **diesel**: A type save SQL query builder. Utilizes the type system to
46-
ensure a lot of invariants. Stresses anything related to resolving
47-
trait bounds, by having a lot of trait impls for a large number of different
48-
types.
49-
- **encoding**: Character encoding support. Contains some large tables.
50-
- **html5ever**: An HTML parser. Stresses macro parsing code significantly.
51-
- **inflate**: An old implementation of the DEFLATE algorithm. Stresses the
52-
compiler in certain ways.
53-
- **keccak**: A cryptography algorithm. Contains a very high number of locals
54-
and basic blocks.
5549
- **ucd**: A Unicode crate. Contains large statics that
5650
[stress](https://github.com/rust-lang/rust/issues/53643) the borrow checker's
5751
implementation of NLL.
5852
- **unicode_normalization**: Unicode character composition and decomposition
5953
utilities. Uses huge `match` statements that stress the compiler in unusual
6054
ways.
61-
- **wg-grammar**: A parser generator.
62-
[Stresses](https://github.com/rust-lang/rust/issues/58178) the borrow
63-
checker's implementation of NLL.
55+
- **webrender**: A web renderer. Used by Firefox and Servo.
56+
- **webrender-wrench**: WebRender's test bench. An executable pulling in large
57+
dependencies.
6458

65-
## Artificial stress tests
59+
## Secondary
6660

67-
These are artificial programs that stress one particular aspect of the
68-
compiler. Some are entirely artificial, and some are extracted from real
69-
programs.
61+
These are either artificial programs or real crates that stress one particular aspect of the
62+
compiler in interesting ways.
7063

7164
- **await-call-tree**: A tree of async fns that await each other, creating a
7265
large type composed of many repeated `impl Future` types. Such types caused
@@ -85,6 +78,8 @@ programs.
8578
- **deep-vector**: A test containing a single large vector of zeroes, which
8679
caused [poor performance](https://github.com/rust-lang/rust/issues/20936) in
8780
the past.
81+
- **derive**: A large amount of simple structs with a `#[derive]` attribute for common built-in traits such as Copy and Debug.
82+
- **externs**: A large amount of extern functions has caused [slowdowns in the past](https://github.com/rust-lang/rust/pull/78448).
8883
- **issue-46449**: A small program that caused [poor
8984
performance](https://github.com/rust-lang/rust/issues/46449) in the past.
9085
- **issue-58319**: A small program that caused [poor
@@ -103,7 +98,7 @@ programs.
10398
- **projection-caching**: A small program that causes extremely, deeply nested
10499
types which stress the trait system's projection cache. Removing that cache
105100
resulted in hours long compilations for some programs using futures,
106-
actix-web and other libraries with similiarly nested type combinators.
101+
actix-web and other libraries with similarly nested type combinators.
107102
- **regression-31157**: A small program that caused a [large performance
108103
regression](https://github.com/rust-lang/rust/issues/31157) from the past.
109104
- **token-stream-stress**: Constructs a long token stream much like the `quote`
@@ -122,5 +117,6 @@ programs.
122117
- **wf-projection-stress-65510**: A stress test which showcases [quadratic
123118
behavior](https://github.com/rust-lang/rust/issues/65510) (in the number of
124119
associated type bounds).
125-
- **externs**: A large amount of extern functions has caused [slowdowns in the past](https://github.com/rust-lang/rust/pull/78448).
126-
- **derive**: A large amount of simple structs with a `#[derive]` attribute for common built-in traits such as Copy and Debug.
120+
- **wg-grammar**: A parser generator.
121+
[Stresses](https://github.com/rust-lang/rust/issues/58178) the borrow
122+
checker's implementation of NLL.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"supports_stable": true
2+
"supports_stable": true,
3+
"category": "primary"
34
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"touch_file": "src/lib.rs",
3-
"category": "primary"
2+
"touch_file": "src/lib.rs"
43
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"supports_stable": true,
3-
"touch_file": "src/main.rs"
3+
"touch_file": "src/main.rs",
4+
"category": "primary"
45
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"touch_file": "src/lib.rs",
3-
"category": "primary"
2+
"touch_file": "src/lib.rs"
43
}

collector/src/execute.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,25 @@ fn default_runs() -> usize {
112112

113113
#[derive(Debug, Clone, serde::Deserialize)]
114114
#[serde(rename_all = "lowercase")]
115-
enum BenchmarkCategory {
115+
enum Category {
116116
Primary,
117-
Secondary
117+
Secondary,
118118
}
119119

120-
impl Default for BenchmarkCategory {
120+
impl Default for Category {
121121
fn default() -> Self {
122122
Self::Secondary
123123
}
124124
}
125125

126+
impl fmt::Display for Category {
127+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
128+
match self {
129+
Category::Primary => f.write_str("primary"),
130+
Category::Secondary => f.write_str("secondary"),
131+
}
132+
}
133+
}
126134
/// This is the internal representation of an individual benchmark's
127135
/// perf-config.json file.
128136
#[derive(Debug, Clone, serde::Deserialize)]
@@ -145,7 +153,7 @@ struct BenchmarkConfig {
145153
touch_file: Option<String>,
146154

147155
#[serde(default)]
148-
category: BenchmarkCategory
156+
category: Category,
149157
}
150158

151159
impl Default for BenchmarkConfig {
@@ -158,7 +166,7 @@ impl Default for BenchmarkConfig {
158166
runs: default_runs(),
159167
supports_stable: false,
160168
touch_file: None,
161-
category: BenchmarkCategory::Secondary
169+
category: Category::Secondary,
162170
}
163171
}
164172
}
@@ -1256,11 +1264,8 @@ impl Benchmark {
12561264
self.config.supports_stable
12571265
}
12581266

1259-
pub fn category_name(&self) -> &str {
1260-
match self.config.category {
1261-
BenchmarkCategory::Primary => "primary",
1262-
BenchmarkCategory::Secondary => "secondary"
1263-
}
1267+
pub fn category(&self) -> &Category {
1268+
&self.config.category
12641269
}
12651270

12661271
#[cfg(windows)]

collector/src/main.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,11 @@ fn bench(
199199
return;
200200
}
201201
let mut tx = rt.block_on(conn.transaction());
202-
rt.block_on(
203-
tx.conn()
204-
.record_benchmark(&benchmark_name.0, Some(benchmark_supports_stable), benchmark_category),
205-
);
202+
rt.block_on(tx.conn().record_benchmark(
203+
&benchmark_name.0,
204+
Some(benchmark_supports_stable),
205+
benchmark_category,
206+
));
206207
print_intro();
207208

208209
let mut processor = BenchProcessor::new(
@@ -238,7 +239,7 @@ fn bench(
238239
measure_and_record(
239240
&benchmark.name,
240241
benchmark.supports_stable(),
241-
benchmark.category_name(),
242+
&benchmark.category().to_string(),
242243
&|| {
243244
eprintln!(
244245
"{}",

database/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,5 +767,5 @@ impl fmt::Display for CollectionId {
767767
#[derive(Debug, Clone, Serialize)]
768768
pub struct BenchmarkData {
769769
name: String,
770-
category: String
770+
category: String,
771771
}

database/src/pool/postgres.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use crate::pool::{Connection, ConnectionManager, ManagedConnection, Transaction};
2-
use crate::{ArtifactId, ArtifactIdNumber, Benchmark, BenchmarkData, CollectionId, Commit, Date, Index, Profile, QueuedCommit, Scenario};
2+
use crate::{
3+
ArtifactId, ArtifactIdNumber, Benchmark, BenchmarkData, CollectionId, Commit, Date, Index,
4+
Profile, QueuedCommit, Scenario,
5+
};
36
use anyhow::Context as _;
47
use chrono::{DateTime, TimeZone, Utc};
58
use hashbrown::HashMap;
@@ -599,18 +602,16 @@ where
599602
}
600603
}
601604
async fn get_benchmarks(&self) -> Vec<BenchmarkData> {
602-
let rows = self.conn()
605+
let rows = self
606+
.conn()
603607
.query(&self.statements().get_benchmarks, &[])
604608
.await
605609
.unwrap();
606610
rows.into_iter()
607611
.map(|r| {
608612
let name: String = r.get(0);
609613
let category: String = r.get(1);
610-
BenchmarkData {
611-
name,
612-
category
613-
}
614+
BenchmarkData { name, category }
614615
})
615616
.collect()
616617
}
@@ -985,7 +986,12 @@ where
985986
.await
986987
.unwrap();
987988
}
988-
async fn record_benchmark(&self, benchmark: &str, supports_stable: Option<bool>, category: &str) {
989+
async fn record_benchmark(
990+
&self,
991+
benchmark: &str,
992+
supports_stable: Option<bool>,
993+
category: &str,
994+
) {
989995
if let Some(r) = self
990996
.conn()
991997
.query_opt(

database/src/pool/sqlite.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -506,11 +506,17 @@ impl Connection for SqliteConnection {
506506

507507
async fn get_benchmarks(&self) -> Vec<BenchmarkData> {
508508
let conn = self.raw_ref();
509-
let mut query = conn.prepare_cached("select name, category from benchmark").unwrap();
510-
let rows = query.query_map([], |row| Ok(BenchmarkData {
511-
name: row.get(0)?,
512-
category: row.get(1)?
513-
})).unwrap();
509+
let mut query = conn
510+
.prepare_cached("select name, category from benchmark")
511+
.unwrap();
512+
let rows = query
513+
.query_map([], |row| {
514+
Ok(BenchmarkData {
515+
name: row.get(0)?,
516+
category: row.get(1)?,
517+
})
518+
})
519+
.unwrap();
514520
let mut benchmarks = Vec::new();
515521
for row in rows {
516522
benchmarks.push(row.unwrap());
@@ -878,7 +884,12 @@ impl Connection for SqliteConnection {
878884
)
879885
.unwrap();
880886
}
881-
async fn record_benchmark(&self, benchmark: &str, supports_stable: Option<bool>, category: &str) {
887+
async fn record_benchmark(
888+
&self,
889+
benchmark: &str,
890+
supports_stable: Option<bool>,
891+
category: &str,
892+
) {
882893
if let Some(stable) = supports_stable {
883894
self.raw_ref()
884895
.execute(

docs/glossary.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The following is a glossary of domain specific terminology. Although benchmarks
99
* **scenario**: The scenario under which a user is compiling their code. Currently, this is the incremental cache state and an optional change in the source since last compilation (e.g., full incremental cache and a `println!` statement is added).
1010
* **metric**: a name of a quantifiable metric being measured (e.g., instruction count)
1111
* **artifact**: a specific version of rustc (usually a commit sha or some sort of human readable "tag" like 1.51.0)
12+
* **category**: a high-level group of benchmarks. Currently, there are two categories, primary (mostly real-world crates) and secondary (mostly stress tests).
1213

1314
## Benchmarks
1415

site/src/comparison.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub async fn handle_compare(
137137
new_errors,
138138
next,
139139
is_contiguous,
140-
benchmark_data: benchmark_map
140+
benchmark_data: benchmark_map,
141141
})
142142
}
143143

0 commit comments

Comments
 (0)