Skip to content

ui: Add GpuCompute plugin for GPU kernel performance analysis#5436

Open
dreveman wants to merge 1 commit intomainfrom
dev/reveman/gpu-compute
Open

ui: Add GpuCompute plugin for GPU kernel performance analysis#5436
dreveman wants to merge 1 commit intomainfrom
dev/reveman/gpu-compute

Conversation

@dreveman
Copy link
Copy Markdown
Collaborator

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

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
@github-actions
Copy link
Copy Markdown

🎨 Perfetto UI Builds

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);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

@dreveman dreveman requested a review from stevegolton April 11, 2026 02:34
@dreveman
Copy link
Copy Markdown
Collaborator Author

@mohammadawwad FYI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant