ui: Add GpuCompute plugin for GPU kernel performance analysis#5436
Open
ui: Add GpuCompute plugin for GPU kernel performance analysis#5436
Conversation
Adds the dev.perfetto.GpuCompute plugin for analyzing GPU compute kernel performance across multiple vendors and hardware architectures in the Perfetto trace viewer. When a compute GPU slice (render stage event) is selected, the Compute tab automatically opens and loads detailed metrics for the selected kernel. Core plugin (dev.perfetto.GpuCompute): - Compute tab that auto-opens on compute slice selection - Details tab with per-kernel metric tables, collapsible sections, baseline comparison, and percent bars - Summary table with sortable columns and double-click navigation - Toolbar with kernel selector, terminology picker, humanize toggle, and baseline comparison controls - Declarative Section registry for metric group definitions - Terminology registry for adapting GPU concepts (thread, warp, block, SM, etc.) to different vendors - Well-known metric registry for vendor-agnostic toolbar and summary display (duration, cycles, frequency, throughput) - Analysis provider interface for optional analysis backends Built-in vendor support: - CUDA (NVIDIA) — metrics, terminology, well-known metrics - AMD — metrics, well-known metrics - OpenCL — terminology Additional vendors can register support through companion plugins that provide terminologies, metric sections, well-known metrics, and analysis providers. Built-in sections (section/): - Speed of Light — compute and memory throughput overview - Launch Statistics — kernel launch configuration - Occupancy — warp occupancy and limiting factors - Workload Analysis — per-pipeline utilization
🎨 Perfetto UI Builds
|
dreveman
commented
Apr 11, 2026
Comment on lines
+341
to
+381
| // Observe selection changes via a periodic check. | ||
| // When a compute slice is selected, fetch its metrics, update state, | ||
| // and auto-show the tab. The interval only reads a property on each | ||
| // tick; SQL queries are only issued when the selection actually changes. | ||
| // TODO: Replace this polling with a proper selection change observer API | ||
| // once one is available (e.g. trace.selection.onChange). | ||
| let lastSliceId: number | undefined; | ||
| let selectionGeneration = 0; | ||
| const selectionInterval = setInterval(() => { | ||
| const sel = trace.selection.selection; | ||
| const sliceId = | ||
| sel.kind === 'track_event' | ||
| ? (sel as TrackEventSelection).eventId | ||
| : undefined; | ||
| if (sliceId === lastSliceId) return; | ||
| lastSliceId = sliceId; | ||
| const gen = ++selectionGeneration; | ||
|
|
||
| if (sliceId !== undefined) { | ||
| fetchSelectedKernelMetricData(trace.engine, sliceId) | ||
| .then((data) => { | ||
| if (gen !== selectionGeneration) return; | ||
| const hasMetrics = Array.isArray(data) && data.length > 0; | ||
| const toolbar = hasMetrics ? data[0].toolbar : undefined; | ||
| content.setSliceId(sliceId, false, {hasMetrics, toolbar}); | ||
| if (hasMetrics) { | ||
| trace.tabs.showTab(tabUri); | ||
| } | ||
| }) | ||
| .catch((e) => { | ||
| if (gen !== selectionGeneration) return; | ||
| console.warn('GpuCompute: failed to fetch slice metrics:', e); | ||
| content.setSliceId(sliceId, false, { | ||
| hasMetrics: false, | ||
| toolbar: undefined, | ||
| }); | ||
| }); | ||
| } else { | ||
| content.setSliceId(undefined); | ||
| } | ||
| }, 100); |
Collaborator
Author
There was a problem hiding this comment.
@stevegolton Is there a better way to do this? what I'm doing here is obviously a hack but it achieves my goal of automatically opening and navigating to a "Compute" tab when a GPU slice with compute details is selected. How do you feel about adding a trace.selection.onChange if there's not a way to do this already?
Collaborator
Author
|
@mohammadawwad FYI |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds the dev.perfetto.GpuCompute plugin for analyzing GPU compute kernel performance across multiple vendors and hardware architectures in the Perfetto trace viewer.
When a compute GPU slice (render stage event) is selected, the Compute tab automatically opens and loads detailed metrics for the selected kernel.
Core plugin (dev.perfetto.GpuCompute):
Built-in vendor support:
Additional vendors can register support through companion plugins that provide terminologies, metric sections, well-known metrics, and analysis providers.
Built-in sections (section/):