From e98ca17d036d7e680c17384ac224e418bcc461d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Sun, 17 Nov 2024 09:49:35 +0100 Subject: [PATCH 1/8] Add backend to test case key --- site/frontend/src/pages/compare/compile/common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/frontend/src/pages/compare/compile/common.ts b/site/frontend/src/pages/compare/compile/common.ts index 7c034ba41..b128658e8 100644 --- a/site/frontend/src/pages/compare/compile/common.ts +++ b/site/frontend/src/pages/compare/compile/common.ts @@ -206,5 +206,5 @@ export function createCompileBenchmarkMap( } export function testCaseKey(testCase: CompileTestCase): string { - return `${testCase.benchmark};${testCase.profile};${testCase.scenario};${testCase.category}`; + return `${testCase.benchmark};${testCase.profile};${testCase.scenario};${testCase.backend};${testCase.category}`; } From 69a77e60edf4b932c7dd69c37099912de84d9c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Sun, 17 Nov 2024 10:08:24 +0100 Subject: [PATCH 2/8] Add comparison of LLVM against Cranelift --- .../src/pages/compare/compile/common.ts | 55 +++++++++++++++++++ .../pages/compare/compile/compile-page.vue | 31 ++++++++++- 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/site/frontend/src/pages/compare/compile/common.ts b/site/frontend/src/pages/compare/compile/common.ts index b128658e8..e33e53f7b 100644 --- a/site/frontend/src/pages/compare/compile/common.ts +++ b/site/frontend/src/pages/compare/compile/common.ts @@ -208,3 +208,58 @@ export function createCompileBenchmarkMap( export function testCaseKey(testCase: CompileTestCase): string { return `${testCase.benchmark};${testCase.profile};${testCase.scenario};${testCase.backend};${testCase.category}`; } + +// Transform compile comparisons to compare LLVM vs Cranelift, instead of +// before/after. Assumes that the data comes from the same commit. +export function transformDataForBackendComparison( + comparisons: CompileBenchmarkComparison[] +): CompileBenchmarkComparison[] { + const benchmarkMap: Map< + string, + { + llvm: number | null; + cranelift: number | null; + benchmark: string; + profile: Profile; + scenario: string; + } + > = new Map(); + for (const comparison of comparisons) { + const key = `${comparison.benchmark};${comparison.profile};${comparison.scenario}`; + if (!benchmarkMap.has(key)) { + benchmarkMap.set(key, { + llvm: null, + cranelift: null, + benchmark: comparison.benchmark, + profile: comparison.profile, + scenario: comparison.scenario, + }); + } + const record = benchmarkMap.get(key); + if (comparison.backend === "llvm") { + record.llvm = comparison.comparison.statistics[0]; + } else if (comparison.backend === "cranelift") { + record.cranelift = comparison.comparison.statistics[0]; + } + } + + const transformed = []; + benchmarkMap.forEach((entry) => { + const comparison: CompileBenchmarkComparison = { + benchmark: entry.benchmark, + profile: entry.profile, + scenario: entry.scenario, + // Treat the backend as LLVM + backend: "llvm", + comparison: { + statistics: [entry.llvm, entry.cranelift], + is_relevant: true, + significance_factor: 1.0, + significance_threshold: 1.0, + }, + }; + transformed.push(comparison); + }); + + return transformed; +} diff --git a/site/frontend/src/pages/compare/compile/compile-page.vue b/site/frontend/src/pages/compare/compile/compile-page.vue index aeb7f4de8..f69a7df94 100644 --- a/site/frontend/src/pages/compare/compile/compile-page.vue +++ b/site/frontend/src/pages/compare/compile/compile-page.vue @@ -14,6 +14,7 @@ import { computeCompileComparisonsWithNonRelevant, createCompileBenchmarkMap, defaultCompileFilter, + transformDataForBackendComparison, } from "./common"; import {BenchmarkInfo} from "../../../api"; import {importantCompileMetrics} from "../metrics"; @@ -197,15 +198,31 @@ const urlParams = getUrlParams(); const quickLinksKey = ref(0); const filter = ref(loadFilterFromUrl(urlParams, defaultCompileFilter)); +// Should we use the backend as the source of before/after data? +const selfCompareBackend = ref(false); + function exportData() { exportToMarkdown(comparisons.value, filter.value.showRawData); } +// Are we currently comparing the same commit against each other? +const comparesIdenticalCommits = computed(() => { + return props.data.a.commit === props.data.b.commit; +}); const benchmarkMap = createCompileBenchmarkMap(props.data); + +// Artificially restructure the data to create a comparison between backends +const compileComparisons = computed(() => { + if (selfCompareBackend.value) { + return transformDataForBackendComparison(props.data.compile_comparisons); + } else { + return props.data.compile_comparisons; + } +}); const allComparisons = computed(() => computeCompileComparisonsWithNonRelevant( filter.value, - props.data.compile_comparisons, + compileComparisons.value, benchmarkMap ) ); @@ -222,6 +239,9 @@ const filteredSummary = computed(() => computeSummary(comparisons.value)); :selected-metric="selector.stat" :metrics="benchmarkInfo.compile_metrics" /> +
+ Self-compare backend: +
computeSummary(comparisons.value)); /> +
+ Comparing LLVM against Cranelift! +
computeSummary(comparisons.value)); :benchmark-map="benchmarkMap" > + From cd5b340867b30e38e7892f8cdd4afae167b5ea98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Sun, 17 Nov 2024 10:11:09 +0100 Subject: [PATCH 3/8] Do not show backend column when comparing backends --- site/frontend/src/pages/compare/compile/benchmarks.vue | 3 +++ site/frontend/src/pages/compare/compile/compile-page.vue | 1 + .../src/pages/compare/compile/table/comparisons-table.vue | 5 +++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/site/frontend/src/pages/compare/compile/benchmarks.vue b/site/frontend/src/pages/compare/compile/benchmarks.vue index fdc4e6dab..975b4e56a 100644 --- a/site/frontend/src/pages/compare/compile/benchmarks.vue +++ b/site/frontend/src/pages/compare/compile/benchmarks.vue @@ -16,6 +16,7 @@ export interface BenchmarkProps { benchmarkMap: CompileBenchmarkMap; filter: CompileBenchmarkFilter; stat: string; + showBackend: boolean; } const props = defineProps(); @@ -77,6 +78,7 @@ const secondaryHasNonRelevant = computed( :commit-b="data.b" :stat="stat" :benchmark-map="benchmarkMap" + :show-backend="showBackend" >