Skip to content

Commit a7f7b0e

Browse files
Merge pull request #1206 from nnethercote/demote-style-servo
Demote `style-servo` to only run in the "stable" set.
2 parents bc1f2fc + 16e35f3 commit a7f7b0e

File tree

20 files changed

+120
-127
lines changed

20 files changed

+120
-127
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ jobs:
6464
strategy:
6565
matrix:
6666
BENCH_INCLUDE_EXCLUDE_OPTS: [
67-
"--exclude webrender-wrench,style-servo,cargo",
68-
"--include webrender-wrench,style-servo,cargo",
67+
"--exclude webrender-wrench,cargo",
68+
"--include webrender-wrench,cargo",
6969
]
7070
PROFILES: [
7171
"Check,Doc,Debug",

collector/benchmarks/README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ 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-
There are two categories of benchmarks, **Primary** and **Secondary**.
10+
There are three categories of benchmarks, **Primary**, **Secondary**, and
11+
**Stable**.
1112

1213
## Primary
1314

@@ -38,8 +39,6 @@ They mostly consist of real-world crates.
3839
- **serde**: A serialization/deserialization crate. Used by many other
3940
Rust programs.
4041
- **stm32f4**: A crate that has many thousands of blanket impl blocks.
41-
- **style-servo**: Servo's `style` crate. A large crate, and one used by
42-
Firefox.
4342
- **syn**: A library for parsing Rust code. An important part of the Rust
4443
ecosystem.
4544
- **tokio-webpush-simple**: A simple web server built with tokio. Uses futures
@@ -125,3 +124,22 @@ compiler in interesting ways.
125124
- **wg-grammar**: A parser generator.
126125
[Stresses](https://github.com/rust-lang/rust/issues/58178) the borrow
127126
checker's implementation of NLL.
127+
128+
**Stable**
129+
130+
These are benchmarks used in the
131+
[dashboard](https://perf.rust-lang.org/dashboard.html). They provide the
132+
longest continuous data set for compiler performance. As a result, they are
133+
quite old (e.g. 2017 or earlier), and not necessarily reflective of typical
134+
Rust code being written today.
135+
136+
- **encoding**: See above.
137+
- **futures**: See above.
138+
- **html5ever**: See above.
139+
- **inflate**: See above.
140+
- **regex**: See above.
141+
- **piston-image**: See above.
142+
- **style-servo**: An old version of Servo's `style` crate. A large crate, and
143+
one used by old versions of Firefox.
144+
- **syn**: See above.
145+
- **tokio-webpush-simple**: See above.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"supports_stable": true,
32
"touch_file": "src/lib.rs",
4-
"category": "primary"
3+
"category": "primary-and-stable"
54
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"supports_stable": true,
3-
"category": "primary"
2+
"category": "primary-and-stable"
43
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"supports_stable": true,
32
"touch_file": "src/lib.rs",
4-
"category": "primary"
3+
"category": "primary-and-stable"
54
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"supports_stable": true,
3-
"category": "primary"
2+
"category": "primary-and-stable"
43
}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"supports_stable": false,
32
"touch_file": "src/lib.rs",
43
"category": "secondary"
54
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"supports_stable": true,
32
"runs": 1,
4-
"category": "primary"
3+
"category": "primary-and-stable"
54
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"supports_stable": true,
32
"touch_file": "src/lib.rs",
4-
"category": "primary"
3+
"category": "primary-and-stable"
54
}

collector/benchmarks/style-servo/perf-config.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"cargo_rustc_opts": "--cap-lints=warn",
44
"cargo_toml": "components/style/Cargo.toml",
55
"runs": 1,
6-
"supports_stable": true,
76
"touch_file": "components/style/lib.rs",
8-
"category": "primary"
7+
"category": "stable"
98
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"supports_stable": true,
32
"touch_file": "src/lib.rs",
4-
"category": "primary"
3+
"category": "primary-and-stable"
54
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"supports_stable": true,
32
"touch_file": "src/main.rs",
4-
"category": "primary"
3+
"category": "primary-and-stable"
54
}

collector/src/execute.rs

Lines changed: 56 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ use crate::{Compiler, Profile, Scenario};
44
use anyhow::{bail, Context};
55
use collector::command_output;
66
use collector::etw_parser;
7-
use database::{Category, PatchName, QueryLabel};
7+
use database::{PatchName, QueryLabel};
88
use futures::stream::FuturesUnordered;
99
use futures::stream::StreamExt;
10+
use serde::{Deserialize, Serialize};
1011
use std::collections::HashMap;
1112
use std::env;
1213
use std::fmt;
@@ -106,6 +107,57 @@ fn touch_all(path: &Path) -> anyhow::Result<()> {
106107
Ok(())
107108
}
108109

110+
#[derive(Debug, Clone, Copy, Serialize, Deserialize, clap::ArgEnum)]
111+
#[serde(rename_all = "kebab-case")]
112+
pub enum Category {
113+
Primary,
114+
Secondary,
115+
// FIXME: this should disappear after the 2022 benchmark overhaul is
116+
// complete.
117+
PrimaryAndStable,
118+
Stable,
119+
}
120+
121+
impl Category {
122+
pub fn has_stable(&self) -> bool {
123+
match self {
124+
Category::Primary | Category::Secondary => false,
125+
Category::PrimaryAndStable | Category::Stable => true,
126+
}
127+
}
128+
129+
pub fn is_primary_or_secondary(&self) -> bool {
130+
match self {
131+
Category::Primary | Category::Secondary | Category::PrimaryAndStable => true,
132+
Category::Stable => false,
133+
}
134+
}
135+
136+
// Within the DB, `Category` is represented in two fields:
137+
// - a `supports_stable` bool,
138+
// - a `category` which is either "primary" or "secondary".
139+
pub fn db_representation(&self) -> (bool, String) {
140+
match self {
141+
Category::Primary => (false, "primary".to_string()),
142+
Category::Secondary => (false, "secondary".to_string()),
143+
// These two have the same DB representation, even though they are
144+
// treated differently when choosing which benchmarks to run.
145+
Category::PrimaryAndStable | Category::Stable => (true, "primary".to_string()),
146+
}
147+
}
148+
}
149+
150+
impl fmt::Display for Category {
151+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
152+
match self {
153+
Category::Primary => f.write_str("primary"),
154+
Category::Secondary => f.write_str("secondary"),
155+
Category::PrimaryAndStable => f.write_str("primary-and-stable"),
156+
Category::Stable => f.write_str("stable"),
157+
}
158+
}
159+
}
160+
109161
fn default_runs() -> usize {
110162
3
111163
}
@@ -121,8 +173,6 @@ struct BenchmarkConfig {
121173
disabled: bool,
122174
#[serde(default = "default_runs")]
123175
runs: usize,
124-
#[serde(default)]
125-
supports_stable: bool,
126176

127177
/// The file that should be touched to ensure cargo re-checks the leaf crate
128178
/// we're interested in. Likely, something similar to `src/lib.rs`. The
@@ -134,21 +184,6 @@ struct BenchmarkConfig {
134184
category: Category,
135185
}
136186

137-
impl Default for BenchmarkConfig {
138-
fn default() -> BenchmarkConfig {
139-
BenchmarkConfig {
140-
cargo_opts: None,
141-
cargo_rustc_opts: None,
142-
cargo_toml: None,
143-
disabled: false,
144-
runs: default_runs(),
145-
supports_stable: false,
146-
touch_file: None,
147-
category: Category::Secondary,
148-
}
149-
}
150-
}
151-
152187
#[derive(Ord, PartialOrd, Eq, PartialEq, Clone, Hash)]
153188
pub struct BenchmarkName(pub String);
154189

@@ -1240,7 +1275,7 @@ impl Benchmark {
12401275
)
12411276
.with_context(|| format!("failed to parse {:?}", config_path))?
12421277
} else {
1243-
BenchmarkConfig::default()
1278+
bail!("missing a perf-config.json file for `{}`", name);
12441279
};
12451280

12461281
Ok(Benchmark {
@@ -1251,12 +1286,8 @@ impl Benchmark {
12511286
})
12521287
}
12531288

1254-
pub fn supports_stable(&self) -> bool {
1255-
self.config.supports_stable
1256-
}
1257-
1258-
pub fn category(&self) -> &Category {
1259-
&self.config.category
1289+
pub fn category(&self) -> Category {
1290+
self.config.category
12601291
}
12611292

12621293
#[cfg(windows)]

collector/src/main.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use anyhow::{bail, Context};
44
use clap::Parser;
5-
use database::{ArtifactId, Category, Commit};
5+
use database::{ArtifactId, Commit};
66
use log::debug;
77
use std::collections::HashSet;
88
use std::fs;
@@ -18,7 +18,7 @@ use tokio::runtime::Runtime;
1818
mod execute;
1919
mod sysroot;
2020

21-
use execute::{BenchProcessor, Benchmark, BenchmarkName, ProfileProcessor, Profiler};
21+
use execute::{BenchProcessor, Benchmark, BenchmarkName, Category, ProfileProcessor, Profiler};
2222
use sysroot::Sysroot;
2323

2424
#[derive(Debug, Copy, Clone)]
@@ -190,8 +190,7 @@ fn bench(
190190

191191
let mut measure_and_record =
192192
|benchmark_name: &BenchmarkName,
193-
benchmark_supports_stable: bool,
194-
benchmark_category: Category,
193+
category: Category,
195194
print_intro: &dyn Fn(),
196195
measure: &dyn Fn(&mut BenchProcessor) -> anyhow::Result<()>| {
197196
let is_fresh =
@@ -202,10 +201,11 @@ fn bench(
202201
return;
203202
}
204203
let mut tx = rt.block_on(conn.transaction());
204+
let (supports_stable, category) = category.db_representation();
205205
rt.block_on(tx.conn().record_benchmark(
206206
&benchmark_name.0,
207-
Some(benchmark_supports_stable),
208-
benchmark_category,
207+
Some(supports_stable),
208+
category,
209209
));
210210
print_intro();
211211

@@ -241,8 +241,7 @@ fn bench(
241241
for (nth_benchmark, benchmark) in benchmarks.iter().enumerate() {
242242
measure_and_record(
243243
&benchmark.name,
244-
benchmark.supports_stable(),
245-
benchmark.category().clone(),
244+
benchmark.category(),
246245
&|| {
247246
eprintln!(
248247
"{}",
@@ -257,7 +256,6 @@ fn bench(
257256
if bench_rustc {
258257
measure_and_record(
259258
&BenchmarkName("rustc".to_string()),
260-
/* supports_stable */ false,
261259
Category::Primary,
262260
&|| eprintln!("Special benchmark commencing (due to `--bench-rustc`)"),
263261
&|processor| processor.measure_rustc(compiler).context("measure rustc"),
@@ -860,12 +858,12 @@ struct DownloadCommand {
860858
#[clap(long, global = true)]
861859
name: Option<String>,
862860

863-
/// Overwrite the benchmark directory if it already exists.
861+
/// Overwrite the benchmark directory if it already exists
864862
#[clap(long, short('f'), global = true)]
865863
force: bool,
866864

867-
/// What category does the benchmark belong to (primary or secondary).
868-
#[clap(long, short('c'), global = true, default_value = "secondary")]
865+
/// What category does the benchmark belong to
866+
#[clap(long, short('c'), arg_enum, global = true, default_value = "secondary")]
869867
category: Category,
870868

871869
#[clap(subcommand)]
@@ -924,11 +922,12 @@ fn main_result() -> anyhow::Result<i32> {
924922
"",
925923
)?;
926924

927-
let benchmarks = get_benchmarks(
925+
let mut benchmarks = get_benchmarks(
928926
&benchmark_dir,
929927
local.include.as_deref(),
930928
local.exclude.as_deref(),
931929
)?;
930+
benchmarks.retain(|b| b.category().is_primary_or_secondary());
932931

933932
let res = bench(
934933
&mut rt,
@@ -978,11 +977,12 @@ fn main_result() -> anyhow::Result<i32> {
978977
let sysroot = Sysroot::install(commit.sha.to_string(), &target_triple)
979978
.with_context(|| format!("failed to install sysroot for {:?}", commit))?;
980979

981-
let benchmarks = get_benchmarks(
980+
let mut benchmarks = get_benchmarks(
982981
&benchmark_dir,
983982
next.include.as_deref(),
984983
next.exclude.as_deref(),
985984
)?;
985+
benchmarks.retain(|b| b.category().is_primary_or_secondary());
986986

987987
let res = bench(
988988
&mut rt,
@@ -1044,7 +1044,7 @@ fn main_result() -> anyhow::Result<i32> {
10441044

10451045
// Exclude benchmarks that don't work with a stable compiler.
10461046
let mut benchmarks = get_benchmarks(&benchmark_dir, None, None)?;
1047-
benchmarks.retain(|b| b.supports_stable());
1047+
benchmarks.retain(|b| b.category().has_stable());
10481048

10491049
let res = bench(
10501050
&mut rt,
@@ -1077,11 +1077,13 @@ fn main_result() -> anyhow::Result<i32> {
10771077
let profiles = Profile::expand_all(&local.profiles);
10781078
let scenarios = Scenario::expand_all(&local.scenarios);
10791079

1080-
let benchmarks = get_benchmarks(
1080+
let mut benchmarks = get_benchmarks(
10811081
&benchmark_dir,
10821082
local.include.as_deref(),
10831083
local.exclude.as_deref(),
10841084
)?;
1085+
benchmarks.retain(|b| b.category().is_primary_or_secondary());
1086+
10851087
let mut errors = BenchmarkErrors::new();
10861088

10871089
let mut get_toolchain_and_profile =

0 commit comments

Comments
 (0)