Skip to content

Commit 0fdfc9e

Browse files
committed
Add a command shortcut for analyzing binary size to benchmark detail
1 parent 82b3ad3 commit 0fdfc9e

File tree

5 files changed

+104
-18
lines changed

5 files changed

+104
-18
lines changed

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
import CompileSectionsChart from "./sections-chart.vue";
2424
import PerfettoLink from "../../../../components/perfetto-link.vue";
2525
import ProfileShortcut from "./shortcuts/profile-shortcut.vue";
26+
import BinarySizeShortcut from "./shortcuts/binary-size-shortcut.vue";
2627
2728
const props = defineProps<{
2829
testCase: CompileTestCase;
@@ -32,6 +33,8 @@ const props = defineProps<{
3233
benchmarkMap: CompileBenchmarkMap;
3334
}>();
3435
36+
const BINARY_SIZE_METRIC: string = "size:linked_artifact";
37+
3538
type GraphRange = {
3639
start: string;
3740
end: string;
@@ -348,17 +351,17 @@ onMounted(() => {
348351
<PerfettoLink
349352
:artifact="props.baseArtifact"
350353
:test-case="props.testCase"
351-
>query trace</PerfettoLink
352-
>
354+
>query trace
355+
</PerfettoLink>
353356
</li>
354357
<li>
355358
After:
356359
<a :href="detailedQueryLink(props.artifact)" target="_blank"
357360
>self-profile</a
358361
>,
359362
<PerfettoLink :artifact="props.artifact" :test-case="props.testCase"
360-
>query trace</PerfettoLink
361-
>
363+
>query trace
364+
</PerfettoLink>
362365
</li>
363366
<li>
364367
<a
@@ -431,7 +434,16 @@ onMounted(() => {
431434
</div>
432435
</div>
433436
<div class="shortcut">
437+
<template v-if="props.metric === BINARY_SIZE_METRIC">
438+
<BinarySizeShortcut
439+
v-if="testCase.profile === 'debug' || testCase.profile === 'opt'"
440+
:artifact="props.artifact"
441+
:base-artifact="props.baseArtifact"
442+
:test-case="props.testCase"
443+
/>
444+
</template>
434445
<ProfileShortcut
446+
v-else
435447
:artifact="props.artifact"
436448
:base-artifact="props.baseArtifact"
437449
:test-case="props.testCase"
@@ -455,9 +467,11 @@ onMounted(() => {
455467
flex-wrap: nowrap;
456468
}
457469
}
470+
458471
.graphs {
459472
margin-top: 15px;
460473
}
474+
461475
.rows {
462476
display: flex;
463477
flex-direction: column;
@@ -467,6 +481,7 @@ onMounted(() => {
467481
align-items: center;
468482
}
469483
}
484+
470485
.shortcut {
471486
margin-top: 15px;
472487
text-align: left;
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<script setup lang="ts">
2+
/**
3+
* This component displays a rustc-perf command for analyzing binary size diff between the baseline
4+
* and the new commit.
5+
**/
6+
7+
import {CompileTestCase} from "../../common";
8+
import {ArtifactDescription} from "../../../types";
9+
import Tooltip from "../../../tooltip.vue";
10+
import {normalizeProfile} from "./utils";
11+
12+
const props = defineProps<{
13+
artifact: ArtifactDescription;
14+
baseArtifact: ArtifactDescription;
15+
testCase: CompileTestCase;
16+
}>();
17+
18+
function normalizeBackend(backend: string): string {
19+
if (backend === "llvm") {
20+
return "Llvm";
21+
} else if (backend == "cranelift") {
22+
return "Cranelift";
23+
}
24+
return "<invalid backend>";
25+
}
26+
</script>
27+
28+
<template>
29+
<div class="title">
30+
Command for analyzing binary size locally
31+
<Tooltip>
32+
Execute this command in a checkout of
33+
<a href="https://github.com/rust-lang/rustc-perf">rustc-perf</a>, after a
34+
`cargo build --release`, to compare binary sizes.
35+
</Tooltip>
36+
</div>
37+
38+
<pre><code>./target/release/collector binary_stats \
39+
+{{ props.baseArtifact.commit }} \
40+
--rustc2 +{{ props.artifact.commit }} \
41+
--include {{ testCase.benchmark }} \
42+
--profile {{ normalizeProfile(testCase.profile) }} \
43+
--backend {{ normalizeBackend(testCase.backend) }}</code></pre>
44+
</template>
45+
46+
<style scoped lang="scss">
47+
.title {
48+
font-weight: bold;
49+
}
50+
51+
pre {
52+
background-color: #eeeeee;
53+
}
54+
55+
code {
56+
user-select: all;
57+
}
58+
</style>

site/frontend/src/pages/compare/compile/table/shortcuts/cachegrind-cmd.vue

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<script setup lang="ts">
22
/**
33
* This component displays a rustc-perf command for profiling a compile benchmark with Cachegrind.
4-
* */
5-
import {CompileTestCase, Profile} from "../../common";
4+
**/
5+
6+
import {CompileTestCase} from "../../common";
67
import {computed} from "vue";
8+
import {normalizeProfile} from "./utils";
79
810
const props = defineProps<{
911
commit: string;
@@ -19,18 +21,6 @@ const firstCommit = computed(() => {
1921
}
2022
});
2123
22-
function normalizeProfile(profile: Profile): string {
23-
if (profile === "opt") {
24-
return "Opt";
25-
} else if (profile === "debug") {
26-
return "Debug";
27-
} else if (profile === "check") {
28-
return "Check";
29-
} else if (profile === "doc") {
30-
return "Doc";
31-
}
32-
return "<invalid profile>";
33-
}
3424
function normalizeScenario(scenario: string): string {
3525
if (scenario === "full") {
3626
return "Full";
@@ -58,6 +48,7 @@ function normalizeScenario(scenario: string): string {
5848
pre {
5949
background-color: #eeeeee;
6050
}
51+
6152
code {
6253
user-select: all;
6354
}

site/frontend/src/pages/compare/compile/table/shortcuts/profile-shortcut.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<script setup lang="ts">
2+
/**
3+
* This component displays a select box that allows users to choose between three variants
4+
* of the `CachegrindCmd` component with a local `rustc-perf` profiling command.
5+
* Users can choose either to profile the baseline commit, the new commit, or to profile both
6+
* and display a diff.
7+
**/
8+
29
import {computed, ref, Ref} from "vue";
310
import {CompileTestCase} from "../../common";
411
import {ArtifactDescription} from "../../../types";
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {Profile} from "../../common";
2+
3+
// Normalize profile from a test case to a CLI value for collector.
4+
export function normalizeProfile(profile: Profile): string {
5+
if (profile === "opt") {
6+
return "Opt";
7+
} else if (profile === "debug") {
8+
return "Debug";
9+
} else if (profile === "check") {
10+
return "Check";
11+
} else if (profile === "doc") {
12+
return "Doc";
13+
}
14+
return "<invalid profile>";
15+
}

0 commit comments

Comments
 (0)