Skip to content

Commit 69a77e6

Browse files
committed
Add comparison of LLVM against Cranelift
1 parent e98ca17 commit 69a77e6

File tree

2 files changed

+85
-1
lines changed

2 files changed

+85
-1
lines changed

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

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,58 @@ export function createCompileBenchmarkMap(
208208
export function testCaseKey(testCase: CompileTestCase): string {
209209
return `${testCase.benchmark};${testCase.profile};${testCase.scenario};${testCase.backend};${testCase.category}`;
210210
}
211+
212+
// Transform compile comparisons to compare LLVM vs Cranelift, instead of
213+
// before/after. Assumes that the data comes from the same commit.
214+
export function transformDataForBackendComparison(
215+
comparisons: CompileBenchmarkComparison[]
216+
): CompileBenchmarkComparison[] {
217+
const benchmarkMap: Map<
218+
string,
219+
{
220+
llvm: number | null;
221+
cranelift: number | null;
222+
benchmark: string;
223+
profile: Profile;
224+
scenario: string;
225+
}
226+
> = new Map();
227+
for (const comparison of comparisons) {
228+
const key = `${comparison.benchmark};${comparison.profile};${comparison.scenario}`;
229+
if (!benchmarkMap.has(key)) {
230+
benchmarkMap.set(key, {
231+
llvm: null,
232+
cranelift: null,
233+
benchmark: comparison.benchmark,
234+
profile: comparison.profile,
235+
scenario: comparison.scenario,
236+
});
237+
}
238+
const record = benchmarkMap.get(key);
239+
if (comparison.backend === "llvm") {
240+
record.llvm = comparison.comparison.statistics[0];
241+
} else if (comparison.backend === "cranelift") {
242+
record.cranelift = comparison.comparison.statistics[0];
243+
}
244+
}
245+
246+
const transformed = [];
247+
benchmarkMap.forEach((entry) => {
248+
const comparison: CompileBenchmarkComparison = {
249+
benchmark: entry.benchmark,
250+
profile: entry.profile,
251+
scenario: entry.scenario,
252+
// Treat the backend as LLVM
253+
backend: "llvm",
254+
comparison: {
255+
statistics: [entry.llvm, entry.cranelift],
256+
is_relevant: true,
257+
significance_factor: 1.0,
258+
significance_threshold: 1.0,
259+
},
260+
};
261+
transformed.push(comparison);
262+
});
263+
264+
return transformed;
265+
}

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
computeCompileComparisonsWithNonRelevant,
1515
createCompileBenchmarkMap,
1616
defaultCompileFilter,
17+
transformDataForBackendComparison,
1718
} from "./common";
1819
import {BenchmarkInfo} from "../../../api";
1920
import {importantCompileMetrics} from "../metrics";
@@ -197,15 +198,31 @@ const urlParams = getUrlParams();
197198
const quickLinksKey = ref(0);
198199
const filter = ref(loadFilterFromUrl(urlParams, defaultCompileFilter));
199200
201+
// Should we use the backend as the source of before/after data?
202+
const selfCompareBackend = ref(false);
203+
200204
function exportData() {
201205
exportToMarkdown(comparisons.value, filter.value.showRawData);
202206
}
203207
208+
// Are we currently comparing the same commit against each other?
209+
const comparesIdenticalCommits = computed(() => {
210+
return props.data.a.commit === props.data.b.commit;
211+
});
204212
const benchmarkMap = createCompileBenchmarkMap(props.data);
213+
214+
// Artificially restructure the data to create a comparison between backends
215+
const compileComparisons = computed(() => {
216+
if (selfCompareBackend.value) {
217+
return transformDataForBackendComparison(props.data.compile_comparisons);
218+
} else {
219+
return props.data.compile_comparisons;
220+
}
221+
});
205222
const allComparisons = computed(() =>
206223
computeCompileComparisonsWithNonRelevant(
207224
filter.value,
208-
props.data.compile_comparisons,
225+
compileComparisons.value,
209226
benchmarkMap
210227
)
211228
);
@@ -222,6 +239,9 @@ const filteredSummary = computed(() => computeSummary(comparisons.value));
222239
:selected-metric="selector.stat"
223240
:metrics="benchmarkInfo.compile_metrics"
224241
/>
242+
<div v-if="comparesIdenticalCommits">
243+
Self-compare backend: <input type="checkbox" v-model="selfCompareBackend" />
244+
</div>
225245
<Filters
226246
:defaultFilter="defaultCompileFilter"
227247
:initialFilter="filter"
@@ -230,6 +250,9 @@ const filteredSummary = computed(() => computeSummary(comparisons.value));
230250
/>
231251
<OverallSummary :summary="filteredSummary" />
232252
<Aggregations :cases="comparisons" />
253+
<div class="warning" v-if="selfCompareBackend">
254+
Comparing LLVM against Cranelift!
255+
</div>
233256
<Benchmarks
234257
:data="data"
235258
:test-cases="comparisons"
@@ -239,3 +262,9 @@ const filteredSummary = computed(() => computeSummary(comparisons.value));
239262
:benchmark-map="benchmarkMap"
240263
></Benchmarks>
241264
</template>
265+
<style lang="scss" scoped>
266+
.warning {
267+
color: red;
268+
font-weight: bold;
269+
}
270+
</style>

0 commit comments

Comments
 (0)