Skip to content

Commit c189751

Browse files
authored
Merge pull request #1694 from Kobzol/benchmark-detail-links
Move comparison table links to a separate section
2 parents 43d16fe + 8d07e53 commit c189751

File tree

4 files changed

+306
-131
lines changed

4 files changed

+306
-131
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+
baselineCommit?: string;
9+
}>();
10+
11+
const firstCommit = computed(() => {
12+
if (props.baselineCommit !== undefined) {
13+
return props.baselineCommit;
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 --release profile_local cachegrind \
47+
+{{ firstCommit }} \<template v-if="props.baselineCommit !== 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: 215 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ 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;
1920
metric: string;
2021
artifact: ArtifactDescription;
22+
baseArtifact: ArtifactDescription;
2123
benchmarkMap: CompileBenchmarkMap;
2224
}>();
2325
@@ -128,6 +130,34 @@ function getGraphTitle() {
128130
}
129131
}
130132
133+
function benchmarkLink(benchmark: string): string {
134+
return `https://github.com/rust-lang/rustc-perf/tree/master/collector/compile-benchmarks/${benchmark}`;
135+
}
136+
137+
function detailedQueryLink(
138+
commit: ArtifactDescription,
139+
baseCommit?: ArtifactDescription
140+
): string {
141+
const {benchmark, profile, scenario} = props.testCase;
142+
let link = `/detailed-query.html?commit=${commit.commit}&benchmark=${benchmark}-${profile}&scenario=${scenario}`;
143+
if (baseCommit !== undefined) {
144+
link += `&base_commit=${baseCommit.commit}`;
145+
}
146+
return link;
147+
}
148+
149+
function graphLink(
150+
commit: ArtifactDescription,
151+
metric: string,
152+
testCase: CompileTestCase
153+
): string {
154+
// Move to `30 days ago` to display history of the test case
155+
const start = getPastDate(new Date(commit.date), 30);
156+
const end = commit.commit;
157+
const {benchmark, profile, scenario} = testCase;
158+
return `/index.html?start=${start}&end=${end}&benchmark=${benchmark}&profile=${profile}&scenario=${scenario}&stat=${metric}`;
159+
}
160+
131161
const metadata = computed(
132162
(): CompileBenchmarkMetadata =>
133163
props.benchmarkMap[props.testCase.benchmark] ?? null
@@ -149,88 +179,209 @@ const cargoProfile = computed((): CargoProfileMetadata => {
149179
const chartElement: Ref<HTMLElement | null> = ref(null);
150180
const graphRange = computed(() => getGraphRange(props.artifact));
151181
182+
enum ProfileCommand {
183+
Before = "before",
184+
After = "after",
185+
Diff = "diff",
186+
}
187+
188+
const profileCommand: Ref<ProfileCommand> = ref(ProfileCommand.Diff);
189+
const profileCommit = computed(() => {
190+
if (profileCommand.value === ProfileCommand.Before) {
191+
return props.baseArtifact.commit;
192+
}
193+
return props.artifact.commit;
194+
});
195+
const profileBaselineCommit = computed(() => {
196+
if (profileCommand.value === ProfileCommand.Diff) {
197+
return props.baseArtifact.commit;
198+
}
199+
return undefined;
200+
});
201+
202+
function changeProfileCommand(event: Event) {
203+
const target = event.target as HTMLSelectElement;
204+
profileCommand.value = target.value as ProfileCommand;
205+
}
206+
152207
onMounted(() => renderGraph());
153208
</script>
154209

155210
<template>
156-
<div class="wrapper">
157-
<div>
158-
<div class="title info bold">Benchmark info</div>
159-
<table>
160-
<tbody>
161-
<tr>
162-
<td>Benchmark</td>
163-
<td>{{ testCase.benchmark }}</td>
164-
</tr>
165-
<tr>
166-
<td>Profile</td>
167-
<td>{{ testCase.profile }}</td>
168-
</tr>
169-
<tr>
170-
<td>Scenario</td>
171-
<td>{{ testCase.scenario }}</td>
172-
</tr>
173-
<tr>
174-
<td>Category</td>
175-
<td>{{ testCase.category }}</td>
176-
</tr>
177-
<tr v-if="(metadata?.binary ?? null) !== null">
178-
<td>Artifact</td>
179-
<td>{{ metadata.binary ? "binary" : "library" }}</td>
180-
</tr>
181-
<tr v-if="(metadata?.iterations ?? null) !== null">
182-
<td>
183-
Iterations<Tooltip>
184-
How many times is the benchmark executed?
185-
</Tooltip>
186-
</td>
187-
<td>{{ metadata.iterations }}</td>
188-
</tr>
189-
<tr v-if="(cargoProfile?.lto ?? null) !== null">
190-
<td>LTO</td>
191-
<td>{{ cargoProfile.lto }}</td>
192-
</tr>
193-
<tr v-if="(cargoProfile?.debug ?? null) !== null">
194-
<td>Debuginfo</td>
195-
<td>{{ cargoProfile.debug }}</td>
196-
</tr>
197-
<tr v-if="(cargoProfile?.codegen_units ?? null) !== null">
198-
<td>Codegen units</td>
199-
<td>{{ cargoProfile.codegen_units }}</td>
200-
</tr>
201-
</tbody>
202-
</table>
203-
</div>
204-
<div>
205-
<div class="title">
206-
<div class="bold">{{ getGraphTitle() }}</div>
207-
<div style="font-size: 0.8em">
208-
Each plotted value is relative to its previous commit
211+
<div>
212+
<div class="columns">
213+
<div class="rows grow">
214+
<div>
215+
<div class="title info bold">Benchmark info</div>
216+
<table>
217+
<tbody>
218+
<tr>
219+
<td>Benchmark</td>
220+
<td>{{ testCase.benchmark }}</td>
221+
</tr>
222+
<tr>
223+
<td>Profile</td>
224+
<td>{{ testCase.profile }}</td>
225+
</tr>
226+
<tr>
227+
<td>Scenario</td>
228+
<td>{{ testCase.scenario }}</td>
229+
</tr>
230+
<tr>
231+
<td>Category</td>
232+
<td>{{ testCase.category }}</td>
233+
</tr>
234+
<tr v-if="(metadata?.binary ?? null) !== null">
235+
<td>Artifact</td>
236+
<td>{{ metadata.binary ? "binary" : "library" }}</td>
237+
</tr>
238+
<tr v-if="(metadata?.iterations ?? null) !== null">
239+
<td>
240+
Iterations
241+
<Tooltip> How many times is the benchmark executed? </Tooltip>
242+
</td>
243+
<td>{{ metadata.iterations }}</td>
244+
</tr>
245+
<tr v-if="(cargoProfile?.lto ?? null) !== null">
246+
<td>LTO</td>
247+
<td>{{ cargoProfile.lto }}</td>
248+
</tr>
249+
<tr v-if="(cargoProfile?.debug ?? null) !== null">
250+
<td>Debuginfo</td>
251+
<td>{{ cargoProfile.debug }}</td>
252+
</tr>
253+
<tr v-if="(cargoProfile?.codegen_units ?? null) !== null">
254+
<td>Codegen units</td>
255+
<td>{{ cargoProfile.codegen_units }}</td>
256+
</tr>
257+
</tbody>
258+
</table>
209259
</div>
210-
<div style="font-size: 0.8em">
211-
The shaded region shows values that are more recent than the
212-
benchmarked commit
260+
<div class="links">
261+
<div class="title bold">Links</div>
262+
<ul>
263+
<li>
264+
<a
265+
:href="detailedQueryLink(props.artifact, props.baseArtifact)"
266+
target="_blank"
267+
>
268+
Detailed results
269+
</a>
270+
</li>
271+
<li>
272+
<a
273+
:href="graphLink(props.artifact, props.metric, props.testCase)"
274+
target="_blank"
275+
>
276+
History graph
277+
</a>
278+
</li>
279+
<li>
280+
<a :href="detailedQueryLink(props.baseArtifact)" target="_blank">
281+
Rustc self-profile: baseline commit
282+
</a>
283+
</li>
284+
<li>
285+
<a :href="detailedQueryLink(props.artifact)" target="_blank">
286+
Rustc self-profile: benchmarked commit
287+
</a>
288+
</li>
289+
<li>
290+
<a :href="benchmarkLink(testCase.benchmark)" target="_blank">
291+
Benchmark source code
292+
</a>
293+
</li>
294+
</ul>
295+
</div>
296+
</div>
297+
<div class="rows center-items grow">
298+
<div class="title">
299+
<div class="bold">{{ getGraphTitle() }}</div>
300+
<div style="font-size: 0.8em">
301+
Each plotted value is relative to its previous commit
302+
</div>
303+
<div style="font-size: 0.8em">
304+
The shaded region shows values that are more recent than the
305+
benchmarked commit
306+
</div>
213307
</div>
308+
<div ref="chartElement"></div>
214309
</div>
215-
<div ref="chartElement"></div>
310+
</div>
311+
<div class="command">
312+
<div class="title bold">
313+
Local profiling command<Tooltip>
314+
Execute this command in a checkout of
315+
<a href="https://github.com/rust-lang/rustc-perf">rustc-perf</a>
316+
to generate a Cachegrind profile.
317+
</Tooltip>
318+
</div>
319+
320+
<select @change="changeProfileCommand">
321+
<option
322+
:value="ProfileCommand.Diff"
323+
:selected="profileCommand === ProfileCommand.Diff"
324+
>
325+
Diff
326+
</option>
327+
<option
328+
:value="ProfileCommand.Before"
329+
:selected="profileCommand === ProfileCommand.Before"
330+
>
331+
Baseline commit
332+
</option>
333+
<option
334+
:value="ProfileCommand.After"
335+
:selected="profileCommand === ProfileCommand.After"
336+
>
337+
Benchmarked commit
338+
</option>
339+
</select>
340+
341+
<CachegrindCmd
342+
:commit="profileCommit"
343+
:baseline-commit="profileBaselineCommit"
344+
:test-case="testCase"
345+
/>
216346
</div>
217347
</div>
218348
</template>
219349

220350
<style scoped lang="scss">
221-
.wrapper {
351+
.columns {
222352
display: flex;
353+
flex-wrap: wrap;
354+
gap: 15px;
223355
margin: 10px 0;
356+
357+
.grow {
358+
flex-grow: 1;
359+
}
360+
}
361+
.rows {
362+
display: flex;
363+
flex-direction: column;
364+
gap: 15px;
365+
366+
&.center-items {
367+
align-items: center;
368+
}
369+
}
370+
.command {
371+
text-align: left;
224372
}
373+
225374
.title {
226375
&.bold,
227376
.bold {
228377
font-weight: bold;
229378
}
379+
230380
&.info {
231381
margin-bottom: 15px;
232382
}
233383
}
384+
234385
table {
235386
align-self: flex-start;
236387
margin-right: 20px;
@@ -244,6 +395,12 @@ table {
244395
}
245396
}
246397
}
398+
399+
.links {
400+
li {
401+
text-align: left;
402+
}
403+
}
247404
</style>
248405

249406
<style>

0 commit comments

Comments
 (0)