-
Notifications
You must be signed in to change notification settings - Fork 154
Add binary size local command shortcut to benchmark detail #1773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
site/frontend/src/pages/compare/compile/table/shortcuts/binary-size-shortcut.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<script setup lang="ts"> | ||
/** | ||
* This component displays a rustc-perf command for analyzing binary size diff between the baseline | ||
* and the new commit. | ||
**/ | ||
|
||
import {CompileTestCase} from "../../common"; | ||
import {ArtifactDescription} from "../../../types"; | ||
import Tooltip from "../../../tooltip.vue"; | ||
import {normalizeProfile} from "./utils"; | ||
|
||
const props = defineProps<{ | ||
artifact: ArtifactDescription; | ||
baseArtifact: ArtifactDescription; | ||
testCase: CompileTestCase; | ||
}>(); | ||
|
||
function normalizeBackend(backend: string): string { | ||
if (backend === "llvm") { | ||
return "Llvm"; | ||
} else if (backend == "cranelift") { | ||
return "Cranelift"; | ||
} | ||
return "<invalid backend>"; | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="title"> | ||
Command for analyzing binary size locally | ||
<Tooltip> | ||
Execute this command in a checkout of | ||
<a href="https://github.com/rust-lang/rustc-perf">rustc-perf</a>, after a | ||
`cargo build --release`, to compare binary sizes. | ||
</Tooltip> | ||
</div> | ||
|
||
<pre><code>./target/release/collector binary_stats \ | ||
+{{ props.baseArtifact.commit }} \ | ||
--rustc2 +{{ props.artifact.commit }} \ | ||
--include {{ testCase.benchmark }} \ | ||
--profile {{ normalizeProfile(testCase.profile) }} \ | ||
--backend {{ normalizeBackend(testCase.backend) }}</code></pre> | ||
Kobzol marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</template> | ||
|
||
<style scoped lang="scss"> | ||
.title { | ||
font-weight: bold; | ||
} | ||
|
||
pre { | ||
background-color: #eeeeee; | ||
} | ||
|
||
code { | ||
user-select: all; | ||
} | ||
</style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
site/frontend/src/pages/compare/compile/table/shortcuts/profile-shortcut.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<script setup lang="ts"> | ||
/** | ||
* This component displays a select box that allows users to choose between three variants | ||
* of the `CachegrindCmd` component with a local `rustc-perf` profiling command. | ||
* Users can choose either to profile the baseline commit, the new commit, or to profile both | ||
* and display a diff. | ||
**/ | ||
|
||
import {computed, ref, Ref} from "vue"; | ||
Kobzol marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import {CompileTestCase} from "../../common"; | ||
import {ArtifactDescription} from "../../../types"; | ||
import Tooltip from "../../../tooltip.vue"; | ||
import CachegrindCmd from "./cachegrind-cmd.vue"; | ||
|
||
const props = defineProps<{ | ||
artifact: ArtifactDescription; | ||
baseArtifact: ArtifactDescription; | ||
testCase: CompileTestCase; | ||
}>(); | ||
|
||
enum ProfileCommand { | ||
Before = "before", | ||
After = "after", | ||
Diff = "diff", | ||
} | ||
|
||
function changeProfileCommand(event: Event) { | ||
const target = event.target as HTMLSelectElement; | ||
profileCommand.value = target.value as ProfileCommand; | ||
} | ||
|
||
const profileCommand: Ref<ProfileCommand> = ref(ProfileCommand.Diff); | ||
const profileCommit = computed(() => { | ||
if (profileCommand.value === ProfileCommand.Before) { | ||
return props.baseArtifact.commit; | ||
} | ||
return props.artifact.commit; | ||
}); | ||
const profileBaselineCommit = computed(() => { | ||
if (profileCommand.value === ProfileCommand.Diff) { | ||
return props.baseArtifact.commit; | ||
} | ||
return undefined; | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div class="title"> | ||
Command for profiling locally | ||
<Tooltip> | ||
Execute this command in a checkout of | ||
<a href="https://github.com/rust-lang/rustc-perf">rustc-perf</a>, after a | ||
`cargo build --release`, to generate a Cachegrind profile. | ||
</Tooltip> | ||
</div> | ||
|
||
<select @change="changeProfileCommand"> | ||
<option | ||
:value="ProfileCommand.Diff" | ||
:selected="profileCommand === ProfileCommand.Diff" | ||
> | ||
Diff | ||
</option> | ||
<option | ||
:value="ProfileCommand.Before" | ||
:selected="profileCommand === ProfileCommand.Before" | ||
> | ||
Baseline commit | ||
</option> | ||
<option | ||
:value="ProfileCommand.After" | ||
:selected="profileCommand === ProfileCommand.After" | ||
> | ||
Benchmarked commit | ||
</option> | ||
</select> | ||
|
||
<CachegrindCmd | ||
:commit="profileCommit" | ||
:baseline-commit="profileBaselineCommit" | ||
:test-case="props.testCase" | ||
/> | ||
</template> | ||
|
||
<style scoped lang="scss"> | ||
.title { | ||
font-weight: bold; | ||
} | ||
</style> |
15 changes: 15 additions & 0 deletions
15
site/frontend/src/pages/compare/compile/table/shortcuts/utils.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {Profile} from "../../common"; | ||
|
||
// Normalize profile from a test case to a CLI value for collector. | ||
export function normalizeProfile(profile: Profile): string { | ||
if (profile === "opt") { | ||
return "Opt"; | ||
} else if (profile === "debug") { | ||
return "Debug"; | ||
} else if (profile === "check") { | ||
return "Check"; | ||
} else if (profile === "doc") { | ||
return "Doc"; | ||
} | ||
return "<invalid profile>"; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.