Skip to content

Commit f602dbb

Browse files
authored
Merge pull request #2272 from Kobzol/compare-target
Render target in compile-time compare page
2 parents 566ed03 + 98ff0f3 commit f602dbb

File tree

7 files changed

+76
-2
lines changed

7 files changed

+76
-2
lines changed

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ export type CompileBenchmarkFilter = {
1919
llvm: boolean;
2020
cranelift: boolean;
2121
};
22+
target: {
23+
x86_64_unknown_linux_gnu: boolean;
24+
};
2225
category: {
2326
primary: boolean;
2427
secondary: boolean;
@@ -54,6 +57,9 @@ export const defaultCompileFilter: CompileBenchmarkFilter = {
5457
llvm: true,
5558
cranelift: true,
5659
},
60+
target: {
61+
x86_64_unknown_linux_gnu: true,
62+
},
5763
category: {
5864
primary: true,
5965
secondary: true,
@@ -72,6 +78,7 @@ export const defaultCompileFilter: CompileBenchmarkFilter = {
7278
export type Profile = "check" | "debug" | "opt" | "doc";
7379
export type CodegenBackend = "llvm" | "cranelift";
7480
export type Category = "primary" | "secondary";
81+
export type Target = "x86_64-unknown-linux-gnu";
7582

7683
export type CompileBenchmarkMap = Dict<CompileBenchmarkMetadata>;
7784

@@ -95,6 +102,7 @@ export interface CompileBenchmarkComparison {
95102
profile: Profile;
96103
scenario: string;
97104
backend: CodegenBackend;
105+
target: Target;
98106
comparison: StatComparison;
99107
}
100108

@@ -103,6 +111,7 @@ export interface CompileTestCase {
103111
profile: Profile;
104112
scenario: string;
105113
backend: CodegenBackend;
114+
target: Target;
106115
category: Category;
107116
}
108117

@@ -151,6 +160,15 @@ export function computeCompileComparisonsWithNonRelevant(
151160
}
152161
}
153162

163+
function targetFilter(target: Target): boolean {
164+
if (target === "x86_64-unknown-linux-gnu") {
165+
return filter.target.x86_64_unknown_linux_gnu;
166+
} else {
167+
// Unknown, but by default we should show things
168+
return true;
169+
}
170+
}
171+
154172
function artifactFilter(metadata: CompileBenchmarkMetadata | null): boolean {
155173
if (metadata?.binary === null) return true;
156174

@@ -183,6 +201,7 @@ export function computeCompileComparisonsWithNonRelevant(
183201
profileFilter(comparison.testCase.profile) &&
184202
scenarioFilter(comparison.testCase.scenario) &&
185203
backendFilter(comparison.testCase.backend) &&
204+
targetFilter(comparison.testCase.target) &&
186205
categoryFilter(comparison.testCase.category) &&
187206
artifactFilter(benchmarkMap[comparison.testCase.benchmark] ?? null) &&
188207
changeFilter(comparison) &&
@@ -198,6 +217,7 @@ export function computeCompileComparisonsWithNonRelevant(
198217
profile: c.profile,
199218
scenario: c.scenario,
200219
backend: c.backend,
220+
target: c.target,
201221
category: (benchmarkMap[c.benchmark] || {}).category || "secondary",
202222
};
203223
return calculateComparison(c.comparison, testCase);
@@ -242,18 +262,20 @@ export function transformDataForBackendComparison(
242262
cranelift: number | null;
243263
benchmark: string;
244264
profile: Profile;
265+
target: Target;
245266
scenario: string;
246267
}
247268
> = new Map();
248269
for (const comparison of comparisons) {
249-
const key = `${comparison.benchmark};${comparison.profile};${comparison.scenario}`;
270+
const key = `${comparison.benchmark};${comparison.profile};${comparison.scenario};${comparison.target}`;
250271
if (!benchmarkMap.has(key)) {
251272
benchmarkMap.set(key, {
252273
llvm: null,
253274
cranelift: null,
254275
benchmark: comparison.benchmark,
255276
profile: comparison.profile,
256277
scenario: comparison.scenario,
278+
target: comparison.target,
257279
});
258280
}
259281
const record = benchmarkMap.get(key);
@@ -271,6 +293,7 @@ export function transformDataForBackendComparison(
271293
scenario: entry.scenario,
272294
// Treat LLVM as the baseline
273295
backend: "llvm",
296+
target: entry.target,
274297
comparison: {
275298
statistics: [entry.llvm, entry.cranelift],
276299
is_relevant: true,

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ function loadFilterFromUrl(
7878
defaultFilter.backend.cranelift
7979
),
8080
},
81+
target: {
82+
x86_64_unknown_linux_gnu: getBoolOrDefault(
83+
urlParams,
84+
"target-x86_64-unknown-linux-gnu",
85+
defaultFilter.target.x86_64_unknown_linux_gnu
86+
),
87+
},
8188
category: {
8289
primary: getBoolOrDefault(
8390
urlParams,
@@ -174,6 +181,11 @@ function storeFilterToUrl(
174181
filter.backend.cranelift,
175182
defaultFilter.backend.cranelift
176183
);
184+
storeOrReset(
185+
"target-x86_64-unknown-linux-gnu",
186+
filter.target.x86_64_unknown_linux_gnu,
187+
defaultFilter.target.x86_64_unknown_linux_gnu
188+
);
177189
storeOrReset(
178190
"primary",
179191
filter.category.primary,

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,26 @@ const opened = createPersistedRef(PREF_FILTERS_OPENED);
207207
</li>
208208
</ul>
209209
</div>
210+
<div class="section section-list-wrapper">
211+
<div class="section-heading">
212+
<div style="width: 160px">
213+
<span>Targets</span>
214+
<Tooltip>The host target of the benchmarked compiler. </Tooltip>
215+
</div>
216+
</div>
217+
<ul class="states-list">
218+
<li>
219+
<label>
220+
<input
221+
type="checkbox"
222+
v-model="filter.target.x86_64_unknown_linux_gnu"
223+
/>
224+
<span class="label">x86_64-unknown-linux-gnu</span>
225+
</label>
226+
<Tooltip>The default Linux x64 target.</Tooltip>
227+
</li>
228+
</ul>
229+
</div>
210230
<div class="section section-list-wrapper">
211231
<div class="section-heading">
212232
<div style="width: 160px">

site/frontend/src/pages/compare/compile/table/comparisons-table.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import {TestCaseComparison} from "../../data";
33
import Tooltip from "../../tooltip.vue";
44
import {ArtifactDescription} from "../../types";
5-
import {percentClass} from "../../shared";
5+
import {formatTarget, percentClass} from "../../shared";
66
import {CompileBenchmarkMap, CompileTestCase} from "../common";
77
import {computed} from "vue";
88
import {testCaseKey} from "../common";
@@ -62,6 +62,7 @@ const unit = computed(() => {
6262
<th>Profile</th>
6363
<th>Scenario</th>
6464
<th v-if="showBackend">Backend</th>
65+
<th>Target</th>
6566
<th>% Change</th>
6667
<th class="narrow">
6768
Significance Threshold
@@ -101,6 +102,9 @@ const unit = computed(() => {
101102
</td>
102103
<td>{{ comparison.testCase.scenario }}</td>
103104
<td v-if="showBackend">{{ comparison.testCase.backend }}</td>
105+
<td :title="comparison.testCase.target">
106+
{{ formatTarget(comparison.testCase.target) }}
107+
</td>
104108
<td>
105109
<div class="numeric-aligned">
106110
<span v-bind:class="percentClass(comparison.percent)">

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import {Target} from "./compile/common";
2+
13
export function formatDate(dateString: string): string {
24
const date = new Date(dateString);
35
function padStr(i) {
@@ -93,3 +95,11 @@ export function benchmarkNameMatchesFilter(
9395
return benchmarkName.includes(trimmedFilterName);
9496
}
9597
}
98+
99+
const TARGET_SHORTCUTS: {[target in Target]: string} = {
100+
"x86_64-unknown-linux-gnu": "x64",
101+
};
102+
103+
export function formatTarget(target: Target): string {
104+
return TARGET_SHORTCUTS[target] ?? target;
105+
}

site/src/api.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ pub mod comparison {
332332
pub profile: String,
333333
pub scenario: String,
334334
pub backend: String,
335+
pub target: String,
335336
pub comparison: StatComparison,
336337
}
337338

site/src/comparison.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use collector::Bound;
1111
use database::{
1212
metric::Metric,
1313
selector::{self, BenchmarkQuery, CompileBenchmarkQuery, RuntimeBenchmarkQuery, TestCase},
14+
Target,
1415
};
1516
use database::{ArtifactId, Benchmark, Lookup, Profile, Scenario};
1617
use serde::Serialize;
@@ -152,6 +153,7 @@ pub async fn handle_compare(
152153
profile: comparison.profile.to_string(),
153154
scenario: comparison.scenario.to_string(),
154155
backend: comparison.backend.to_string(),
156+
target: comparison.target.to_string(),
155157
comparison: comparison.comparison.into(),
156158
})
157159
.collect();
@@ -742,6 +744,7 @@ async fn compare_given_commits(
742744
scenario: test_case.scenario,
743745
benchmark: test_case.benchmark,
744746
backend: test_case.backend,
747+
target: test_case.target,
745748
comparison,
746749
},
747750
)
@@ -1315,6 +1318,7 @@ pub struct CompileTestResultComparison {
13151318
profile: Profile,
13161319
scenario: Scenario,
13171320
backend: CodegenBackend,
1321+
target: Target,
13181322
comparison: TestResultComparison,
13191323
}
13201324

0 commit comments

Comments
 (0)