Skip to content

Commit 95764b8

Browse files
committed
Add Cachegrind command to benchmark detail and modify its layout
1 parent 357bb2b commit 95764b8

File tree

3 files changed

+191
-92
lines changed

3 files changed

+191
-92
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<script setup lang="ts">
2+
import {CompileTestCase, Profile} from "../pages/compare/compile/common";
3+
import {computed} from "vue";
4+
5+
const props = defineProps<{
6+
commit: string;
7+
testCase: CompileTestCase;
8+
baseline_commit?: string;
9+
}>();
10+
11+
const firstCommit = computed(() => {
12+
if (props.baseline_commit !== undefined) {
13+
return props.baseline_commit;
14+
} else {
15+
return props.commit;
16+
}
17+
});
18+
19+
function normalizeProfile(profile: Profile): string {
20+
if (profile === "opt") {
21+
return "Opt";
22+
} else if (profile === "debug") {
23+
return "Debug";
24+
} else if (profile === "check") {
25+
return "Check";
26+
} else if (profile === "doc") {
27+
return "Doc";
28+
}
29+
return "<invalid profile>";
30+
}
31+
function normalizeScenario(scenario: string): string {
32+
if (scenario === "full") {
33+
return "Full";
34+
} else if (scenario === "incr-full") {
35+
return "IncrFull";
36+
} else if (scenario === "incr-unchanged") {
37+
return "IncrUnchanged";
38+
} else if (scenario.startsWith("incr-patched")) {
39+
return "IncrPatched";
40+
}
41+
return "<invalid scenario>";
42+
}
43+
</script>
44+
45+
<template>
46+
<pre><code>cargo run --bin collector profile_local cachegrind \
47+
+{{ firstCommit }} \<template v-if="props.baseline_commit !== undefined">
48+
--rustc2 +{{ props.commit }} \</template>
49+
--include {{ testCase.benchmark }} \
50+
--profiles {{ normalizeProfile(testCase.profile) }} \
51+
--scenarios {{ normalizeScenario(testCase.scenario) }}</code></pre>
52+
</template>
53+
54+
<style scoped lang="scss">
55+
pre {
56+
background-color: #eeeeee;
57+
}
58+
code {
59+
user-select: all;
60+
}
61+
</style>

site/frontend/src/pages/compare/compile/table/benchmark-detail.vue

Lines changed: 129 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {GraphRenderOpts, renderPlots} from "../../../../graph/render";
1313
import {GRAPH_RESOLVER} from "../../../../graph/resolver";
1414
import {GraphKind} from "../../../../graph/data";
1515
import uPlot from "uplot";
16+
import CachegrindCmd from "../../../../components/cachegrind-cmd.vue";
1617
1718
const props = defineProps<{
1819
testCase: CompileTestCase;
@@ -182,109 +183,145 @@ onMounted(() => renderGraph());
182183
</script>
183184

184185
<template>
185-
<div class="wrapper">
186-
<div>
187-
<div class="title info bold">Benchmark info</div>
188-
<table>
189-
<tbody>
190-
<tr>
191-
<td>Benchmark</td>
192-
<td>{{ testCase.benchmark }}</td>
193-
</tr>
194-
<tr>
195-
<td>Profile</td>
196-
<td>{{ testCase.profile }}</td>
197-
</tr>
198-
<tr>
199-
<td>Scenario</td>
200-
<td>{{ testCase.scenario }}</td>
201-
</tr>
202-
<tr>
203-
<td>Category</td>
204-
<td>{{ testCase.category }}</td>
205-
</tr>
206-
<tr v-if="(metadata?.binary ?? null) !== null">
207-
<td>Artifact</td>
208-
<td>{{ metadata.binary ? "binary" : "library" }}</td>
209-
</tr>
210-
<tr v-if="(metadata?.iterations ?? null) !== null">
211-
<td>
212-
Iterations
213-
<Tooltip> How many times is the benchmark executed? </Tooltip>
214-
</td>
215-
<td>{{ metadata.iterations }}</td>
216-
</tr>
217-
<tr v-if="(cargoProfile?.lto ?? null) !== null">
218-
<td>LTO</td>
219-
<td>{{ cargoProfile.lto }}</td>
220-
</tr>
221-
<tr v-if="(cargoProfile?.debug ?? null) !== null">
222-
<td>Debuginfo</td>
223-
<td>{{ cargoProfile.debug }}</td>
224-
</tr>
225-
<tr v-if="(cargoProfile?.codegen_units ?? null) !== null">
226-
<td>Codegen units</td>
227-
<td>{{ cargoProfile.codegen_units }}</td>
228-
</tr>
229-
</tbody>
230-
</table>
231-
</div>
232-
<div>
233-
<div class="title">
234-
<div class="bold">{{ getGraphTitle() }}</div>
235-
<div style="font-size: 0.8em">
236-
Each plotted value is relative to its previous commit
186+
<div>
187+
<div class="columns">
188+
<div class="rows grow">
189+
<div>
190+
<div class="title info bold">Benchmark info</div>
191+
<table>
192+
<tbody>
193+
<tr>
194+
<td>Benchmark</td>
195+
<td>{{ testCase.benchmark }}</td>
196+
</tr>
197+
<tr>
198+
<td>Profile</td>
199+
<td>{{ testCase.profile }}</td>
200+
</tr>
201+
<tr>
202+
<td>Scenario</td>
203+
<td>{{ testCase.scenario }}</td>
204+
</tr>
205+
<tr>
206+
<td>Category</td>
207+
<td>{{ testCase.category }}</td>
208+
</tr>
209+
<tr v-if="(metadata?.binary ?? null) !== null">
210+
<td>Artifact</td>
211+
<td>{{ metadata.binary ? "binary" : "library" }}</td>
212+
</tr>
213+
<tr v-if="(metadata?.iterations ?? null) !== null">
214+
<td>
215+
Iterations
216+
<Tooltip> How many times is the benchmark executed? </Tooltip>
217+
</td>
218+
<td>{{ metadata.iterations }}</td>
219+
</tr>
220+
<tr v-if="(cargoProfile?.lto ?? null) !== null">
221+
<td>LTO</td>
222+
<td>{{ cargoProfile.lto }}</td>
223+
</tr>
224+
<tr v-if="(cargoProfile?.debug ?? null) !== null">
225+
<td>Debuginfo</td>
226+
<td>{{ cargoProfile.debug }}</td>
227+
</tr>
228+
<tr v-if="(cargoProfile?.codegen_units ?? null) !== null">
229+
<td>Codegen units</td>
230+
<td>{{ cargoProfile.codegen_units }}</td>
231+
</tr>
232+
</tbody>
233+
</table>
234+
</div>
235+
<div class="links">
236+
<div class="title bold">Links</div>
237+
<ul>
238+
<li>
239+
<a
240+
:href="graphLink(props.artifact, props.metric, props.testCase)"
241+
target="_blank"
242+
>
243+
History graph
244+
</a>
245+
</li>
246+
<li>
247+
<a
248+
:href="detailedQueryLink(props.artifact, props.baseArtifact)"
249+
target="_blank"
250+
>
251+
Self profile (diff)
252+
</a>
253+
</li>
254+
<li>
255+
<a :href="detailedQueryLink(props.baseArtifact)" target="_blank">
256+
Self profile (before)
257+
</a>
258+
</li>
259+
<li>
260+
<a :href="detailedQueryLink(props.artifact)" target="_blank">
261+
Self profile (after)
262+
</a>
263+
</li>
264+
<li>
265+
<a :href="benchmarkLink(testCase.benchmark)" target="_blank">
266+
Benchmark source code
267+
</a>
268+
</li>
269+
</ul>
237270
</div>
238-
<div style="font-size: 0.8em">
239-
The shaded region shows values that are more recent than the
240-
benchmarked commit
271+
</div>
272+
<div class="rows center-items grow">
273+
<div class="title">
274+
<div class="bold">{{ getGraphTitle() }}</div>
275+
<div style="font-size: 0.8em">
276+
Each plotted value is relative to its previous commit
277+
</div>
278+
<div style="font-size: 0.8em">
279+
The shaded region shows values that are more recent than the
280+
benchmarked commit
281+
</div>
241282
</div>
283+
<div ref="chartElement"></div>
242284
</div>
243-
<div ref="chartElement"></div>
244285
</div>
245-
<div class="links">
246-
<div class="title bold">Links</div>
247-
<ul>
248-
<li>
249-
<a
250-
:href="graphLink(props.artifact, props.metric, props.testCase)"
251-
target="_blank"
252-
>
253-
History graph
254-
</a>
255-
</li>
256-
<li>
257-
<a
258-
:href="detailedQueryLink(props.artifact, props.baseArtifact)"
259-
target="_blank"
260-
>
261-
Self profile (diff)
262-
</a>
263-
</li>
264-
<li>
265-
<a :href="detailedQueryLink(props.baseArtifact)" target="_blank">
266-
Self profile (before)
267-
</a>
268-
</li>
269-
<li>
270-
<a :href="detailedQueryLink(props.artifact)" target="_blank">
271-
Self profile (after)
272-
</a>
273-
</li>
274-
<li>
275-
<a :href="benchmarkLink(testCase.benchmark)" target="_blank">
276-
Benchmark source code
277-
</a>
278-
</li>
279-
</ul>
286+
<div class="command">
287+
<div class="title bold">
288+
Local profiling command<Tooltip>
289+
Execute this command in a checkout of
290+
<a href="https://github.com/rust-lang/rustc-perf">rustc-perf</a>
291+
to generate a Cachegrind diff between the two artifacts.
292+
</Tooltip>
293+
</div>
294+
<CachegrindCmd
295+
:commit="artifact.commit"
296+
:baseline_commit="baseArtifact.commit"
297+
:test-case="testCase"
298+
/>
280299
</div>
281300
</div>
282301
</template>
283302

284303
<style scoped lang="scss">
285-
.wrapper {
304+
.columns {
286305
display: flex;
306+
flex-wrap: wrap;
307+
gap: 15px;
287308
margin: 10px 0;
309+
310+
.grow {
311+
flex-grow: 1;
312+
}
313+
}
314+
.rows {
315+
display: flex;
316+
flex-direction: column;
317+
gap: 15px;
318+
319+
&.center-items {
320+
align-items: center;
321+
}
322+
}
323+
.command {
324+
text-align: left;
288325
}
289326
290327
.title {

site/frontend/src/pages/detailed-query.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ function populate_data(data, state: Selector) {
131131
state.scenario
132132
)})
133133
results for ${state.commit.substring(0, 10)} (new commit)`;
134+
// TODO: use the Cachegrind Vue components once this page is refactored to Vue
134135
let profile = (b) =>
135136
b.endsWith("-opt")
136137
? "Opt"

0 commit comments

Comments
 (0)