Skip to content

Commit 5844007

Browse files
committed
Allow for stable-only benchmarks.
Currently, every benchmark has a category defined by the `perf-config.json`, either explicitly or implicitly (where the default is "secondary" if not specified). This commit allows for a benchmark to have no category, so long as it has `supports_stable` set. - The ability to implicitly specify the category has been removed. - These benchmarks are not considered primary or secondary from the point of view of the user, though they are marked as primary in the DB. - These benchmarks are indicated in `perf-config.json` by setting `supports_stable` to true and leaving `category` unspecified. - These benchmarks are run by `bench_published`, but not by `bench_local`, `bench_next`, or `profile_local`. It is still possible for a benchmark to set `supports_stable` *and* still have a category, and several benchmarks fit into this category. However, many of these benchmarks will soon have their category removed, which means they will only be measured as part of the "stable" set.
1 parent 1d08022 commit 5844007

File tree

4 files changed

+25
-16
lines changed

4 files changed

+25
-16
lines changed

collector/src/execute.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ struct BenchmarkConfig {
131131
#[serde(default)]
132132
touch_file: Option<String>,
133133

134-
category: Category,
134+
/// If this field is `None` when read from `perf-config.json`:
135+
/// - If `supports_stable` is true, it will be replaced with
136+
/// `Some(Primary)` when the result is recorded in the DB.
137+
/// - If `supports_stable` is false, an error will be returned.
138+
category: Option<Category>,
135139
}
136140

137141
#[derive(Ord, PartialOrd, Eq, PartialEq, Clone, Hash)]
@@ -1227,6 +1231,9 @@ impl Benchmark {
12271231
} else {
12281232
bail!("missing a perf-config.json file for `{}`", name);
12291233
};
1234+
if config.category.is_none() && !config.supports_stable {
1235+
bail!("bad perf-config.json for `{}`: category == None && !supports_stable", name);
1236+
}
12301237

12311238
Ok(Benchmark {
12321239
name: BenchmarkName(name),
@@ -1240,8 +1247,8 @@ impl Benchmark {
12401247
self.config.supports_stable
12411248
}
12421249

1243-
pub fn category(&self) -> &Category {
1244-
&self.config.category
1250+
pub fn category(&self) -> Option<Category> {
1251+
self.config.category
12451252
}
12461253

12471254
#[cfg(windows)]

collector/src/main.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,11 @@ fn bench(
242242
measure_and_record(
243243
&benchmark.name,
244244
benchmark.supports_stable(),
245-
benchmark.category().clone(),
245+
benchmark.category().unwrap_or_else(|| {
246+
// Stable-only benchmarks are marked in the DB as "primary".
247+
assert!(benchmark.supports_stable());
248+
Category::Primary
249+
}),
246250
&|| {
247251
eprintln!(
248252
"{}",
@@ -924,11 +928,12 @@ fn main_result() -> anyhow::Result<i32> {
924928
"",
925929
)?;
926930

927-
let benchmarks = get_benchmarks(
931+
let mut benchmarks = get_benchmarks(
928932
&benchmark_dir,
929933
local.include.as_deref(),
930934
local.exclude.as_deref(),
931935
)?;
936+
benchmarks.retain(|b| b.category().is_some());
932937

933938
let res = bench(
934939
&mut rt,
@@ -978,11 +983,12 @@ fn main_result() -> anyhow::Result<i32> {
978983
let sysroot = Sysroot::install(commit.sha.to_string(), &target_triple)
979984
.with_context(|| format!("failed to install sysroot for {:?}", commit))?;
980985

981-
let benchmarks = get_benchmarks(
986+
let mut benchmarks = get_benchmarks(
982987
&benchmark_dir,
983988
next.include.as_deref(),
984989
next.exclude.as_deref(),
985990
)?;
991+
benchmarks.retain(|b| b.category().is_some());
986992

987993
let res = bench(
988994
&mut rt,
@@ -1077,11 +1083,13 @@ fn main_result() -> anyhow::Result<i32> {
10771083
let profiles = Profile::expand_all(&local.profiles);
10781084
let scenarios = Scenario::expand_all(&local.scenarios);
10791085

1080-
let benchmarks = get_benchmarks(
1086+
let mut benchmarks = get_benchmarks(
10811087
&benchmark_dir,
10821088
local.include.as_deref(),
10831089
local.exclude.as_deref(),
10841090
)?;
1091+
benchmarks.retain(|b| b.category().is_some());
1092+
10851093
let mut errors = BenchmarkErrors::new();
10861094

10871095
let mut get_toolchain_and_profile =

database/src/lib.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -770,19 +770,13 @@ pub struct BenchmarkData {
770770
pub category: Category,
771771
}
772772

773-
#[derive(Debug, Clone, Serialize, Deserialize)]
773+
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
774774
#[serde(rename_all = "lowercase")]
775775
pub enum Category {
776776
Primary,
777777
Secondary,
778778
}
779779

780-
impl Default for Category {
781-
fn default() -> Self {
782-
Self::Secondary
783-
}
784-
}
785-
786780
impl fmt::Display for Category {
787781
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
788782
match self {

docs/glossary.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +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).
12+
* **category**: a high-level group of benchmarks. Currently, there are two categories, primary (mostly real-world crates) and secondary (mostly stress tests). There are also some benchmarks that are neither primary nor secondary, being only measured as part of the "stable" set measured for the dashboard.
1313

1414
## Benchmarks
1515

@@ -44,4 +44,4 @@ The following is a glossary of domain specific terminology. Although benchmarks
4444
## Other
4545

4646
* **bootstrap**: the process of building the compiler from a previous version of the compiler
47-
* **compiler query**: a query used inside the [compiler query system](https://rustc-dev-guide.rust-lang.org/overview.html#queries).
47+
* **compiler query**: a query used inside the [compiler query system](https://rustc-dev-guide.rust-lang.org/overview.html#queries).

0 commit comments

Comments
 (0)