Skip to content

Commit 7d09861

Browse files
committed
Add option to filter compile benchmarks based on the artifact that they produce (binary/library)
1 parent 2a33346 commit 7d09861

File tree

6 files changed

+94
-27
lines changed

6 files changed

+94
-27
lines changed

site/frontend/src/pages/compare/compile/common.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export type CompileBenchmarkFilter = {
1818
primary: boolean;
1919
secondary: boolean;
2020
};
21+
artifact: {
22+
binary: boolean;
23+
library: boolean;
24+
};
2125
} & BenchmarkFilter;
2226
export const defaultCompileFilter: CompileBenchmarkFilter = {
2327
name: null,
@@ -39,16 +43,21 @@ export const defaultCompileFilter: CompileBenchmarkFilter = {
3943
primary: true,
4044
secondary: true,
4145
},
46+
artifact: {
47+
binary: true,
48+
library: true,
49+
},
4250
};
4351

4452
export type Profile = "check" | "debug" | "opt" | "doc";
4553
export type Category = "primary" | "secondary";
4654

47-
export type CompileBenchmarkMap = Dict<{category: Category}>;
55+
export type CompileBenchmarkMap = Dict<CompileBenchmarkMetadata>;
4856

49-
export interface CompileBenchmarkDescription {
57+
export interface CompileBenchmarkMetadata {
5058
name: string;
5159
category: Category;
60+
binary: boolean | null;
5261
}
5362

5463
export interface CompileBenchmarkComparison {
@@ -99,6 +108,17 @@ export function computeCompileComparisonsWithNonRelevant(
99108
}
100109
}
101110

111+
function artifactFilter(metadata: CompileBenchmarkMetadata | null): boolean {
112+
if (metadata?.binary === null) return true;
113+
114+
const isBinary = metadata.binary;
115+
const isLibrary = !isBinary;
116+
if (isBinary && !filter.artifact.binary) return false;
117+
if (isLibrary && !filter.artifact.library) return false;
118+
119+
return true;
120+
}
121+
102122
function categoryFilter(category: Category) {
103123
if (category === "primary" && !filter.category.primary) return false;
104124
if (category === "secondary" && !filter.category.secondary) return false;
@@ -114,6 +134,7 @@ export function computeCompileComparisonsWithNonRelevant(
114134
profileFilter(comparison.testCase.profile) &&
115135
scenarioFilter(comparison.testCase.scenario) &&
116136
categoryFilter(comparison.testCase.category) &&
137+
artifactFilter(benchmarkMap[comparison.testCase.benchmark] ?? null) &&
117138
nameFiltered
118139
);
119140
}
@@ -147,10 +168,8 @@ export function createCompileBenchmarkMap(
147168
data: CompareResponse
148169
): CompileBenchmarkMap {
149170
const benchmarks = {};
150-
for (const benchmark of data.compile_benchmark_data) {
151-
benchmarks[benchmark.name] = {
152-
category: benchmark.category,
153-
};
171+
for (const benchmark of data.compile_benchmark_metadata) {
172+
benchmarks[benchmark.name] = {...benchmark};
154173
}
155174
return benchmarks;
156175
}

site/frontend/src/pages/compare/compile/compile-page.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ function loadFilterFromUrl(
6464
defaultFilter.category.secondary
6565
),
6666
},
67+
artifact: {
68+
binary: getBoolOrDefault("binary", defaultFilter.artifact.binary),
69+
library: getBoolOrDefault("library", defaultFilter.artifact.library),
70+
},
6771
};
6872
}
6973
@@ -123,6 +127,12 @@ function storeFilterToUrl(
123127
filter.category.secondary,
124128
defaultFilter.category.secondary
125129
);
130+
storeOrReset("binary", filter.artifact.binary, defaultFilter.artifact.binary);
131+
storeOrReset(
132+
"library",
133+
filter.artifact.library,
134+
defaultFilter.artifact.library
135+
);
126136
127137
changeUrl(urlParams);
128138
}

site/frontend/src/pages/compare/compile/filters.vue

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,31 @@ const opened = createPersistedRef(PREF_FILTERS_OPENED);
203203
</li>
204204
</ul>
205205
</div>
206+
<div class="section section-list-wrapper">
207+
<div class="section-heading">
208+
<div style="width: 160px">
209+
<span>Artifacts</span>
210+
<Tooltip>
211+
Select benchmarks based on the artifact that they produce
212+
(either a binary or a library).
213+
</Tooltip>
214+
</div>
215+
</div>
216+
<ul class="states-list">
217+
<li>
218+
<label>
219+
<input type="checkbox" v-model="filter.artifact.binary" />
220+
<span class="cache-label">binary</span>
221+
</label>
222+
</li>
223+
<li>
224+
<label>
225+
<input type="checkbox" v-model="filter.artifact.library" />
226+
<span class="cache-label">library</span>
227+
</label>
228+
</li>
229+
</ul>
230+
</div>
206231
<div class="section">
207232
<div class="section-heading">
208233
<span>Show non-relevant results</span>

site/frontend/src/pages/compare/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
CompileBenchmarkComparison,
3-
CompileBenchmarkDescription,
3+
CompileBenchmarkMetadata,
44
} from "./compile/common";
55
import {RuntimeBenchmarkComparison} from "./runtime/common";
66

@@ -42,7 +42,7 @@ export interface CompareResponse {
4242
new_errors: Array<[string, string]>;
4343

4444
compile_comparisons: CompileBenchmarkComparison[];
45-
compile_benchmark_data: CompileBenchmarkDescription[];
45+
compile_benchmark_metadata: CompileBenchmarkMetadata[];
4646

4747
runtime_comparisons: RuntimeBenchmarkComparison[];
4848
}

site/src/api.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pub mod bootstrap {
133133
pub mod comparison {
134134
use crate::comparison::Metric;
135135
use collector::Bound;
136-
use database::{CompileBenchmark, Date};
136+
use database::Date;
137137
use serde::{Deserialize, Serialize};
138138
use std::collections::HashMap;
139139

@@ -145,18 +145,14 @@ pub mod comparison {
145145
}
146146

147147
#[derive(Debug, Clone, Serialize, Deserialize)]
148-
pub struct BenchmarkInfo {
148+
pub struct CompileBenchmarkMetadata {
149149
pub name: String,
150150
pub category: String,
151-
}
152-
153-
impl From<CompileBenchmark> for BenchmarkInfo {
154-
fn from(data: CompileBenchmark) -> Self {
155-
Self {
156-
name: data.name,
157-
category: data.category,
158-
}
159-
}
151+
// We need to keep the data below as optional, because we get the data from information
152+
// gathered from the actual state of the compile benchmarks. But if we remove a compile
153+
// benchmark, the metadata for it will no longer be available, so we might not always have
154+
// access to the metadata.
155+
pub binary: Option<bool>,
160156
}
161157

162158
#[derive(Debug, Clone, Serialize)]
@@ -174,10 +170,10 @@ pub mod comparison {
174170
/// The names for the next artifact after `b`, if any.
175171
pub next: Option<String>,
176172

177-
/// If `a` and `b` are adjacent artifacts (i.e., `a` is the parent of
178-
/// `b`).
173+
/// If `a` and `b` are adjacent artifacts (i.e., `a` is the parent of `b`).
179174
pub is_contiguous: bool,
180-
pub compile_benchmark_data: Vec<BenchmarkInfo>,
175+
176+
pub compile_benchmark_metadata: Vec<CompileBenchmarkMetadata>,
181177
}
182178

183179
#[derive(Debug, Clone, Serialize)]

site/src/comparison.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ use collector::compile::benchmark::category::Category;
1414
use collector::Bound;
1515
use serde::{Deserialize, Serialize};
1616

17+
use crate::api::comparison::CompileBenchmarkMetadata;
18+
use crate::benchmark_metadata::get_compile_benchmarks_metadata;
1719
use crate::server::comparison::StatComparison;
18-
use database::CommitType;
20+
use collector::compile::benchmark::ArtifactType;
21+
use database::{CommitType, CompileBenchmark};
1922
use serde::de::IntoDeserializer;
2023
use std::cmp;
2124
use std::collections::{HashMap, HashSet};
@@ -167,6 +170,23 @@ pub async fn handle_compare(
167170
.into_iter()
168171
.collect::<Vec<_>>();
169172
new_errors.sort();
173+
174+
let compile_metadata = get_compile_benchmarks_metadata();
175+
// Enrich data from the DB with metadata generated by the build script
176+
let compile_benchmark_metadata = compile_benchmark_map
177+
.into_iter()
178+
.map(|benchmark| {
179+
let CompileBenchmark { name, category } = benchmark;
180+
let metadata = compile_metadata.get(&name);
181+
182+
CompileBenchmarkMetadata {
183+
name,
184+
category,
185+
binary: metadata.map(|m| m.perf_config.artifact() == ArtifactType::Binary),
186+
}
187+
})
188+
.collect();
189+
170190
Ok(api::comparison::Response {
171191
prev,
172192
a: comparison.a.into(),
@@ -176,10 +196,7 @@ pub async fn handle_compare(
176196
new_errors,
177197
next,
178198
is_contiguous,
179-
compile_benchmark_data: compile_benchmark_map
180-
.into_iter()
181-
.map(|bench| bench.into())
182-
.collect(),
199+
compile_benchmark_metadata,
183200
})
184201
}
185202

0 commit comments

Comments
 (0)