Skip to content

Adds generic GPU TrackEvent support across Perfetto - #6923

Open
dreveman wants to merge 12 commits into
mainfrom
dev/dreveman/generic-gpu-tracks
Open

Adds generic GPU TrackEvent support across Perfetto#6923
dreveman wants to merge 12 commits into
mainfrom
dev/dreveman/generic-gpu-tracks

Conversation

@dreveman

@dreveman dreveman commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds generic GPU timelines built from standard TrackDescriptor and
TrackEvent packets. Producers can control GPU hierarchy, naming, ordering,
annotations, counters, and state tracks without adding API-specific
hierarchy fields.

GPU hierarchy uses ordinary parent_uuid relationships. Process-scoped
concepts such as CUDA streams are associated with a process by parenting the
GPU root to a process TrackDescriptor.

Render-stage integration

GpuTrackDescriptor can bind an exact authored track to either:

oneof render_stage_queue {
  uint64 hw_queue_iid = 2;
  uint64 logical_queue_id = 3;
}

Matching GpuRenderStageEvents are projected onto that authored track while
remaining available as canonical gpu_slice rows. Authored annotations and
projected render-stage events use normal TrackEvent sibling merging:

  • tracks merge by name by default;
  • sibling_merge_key provides an explicit merge identity;
  • SIBLING_MERGE_BEHAVIOR_NONE keeps the sources separate.

This lets producers add annotations directly to hardware or logical queue
tracks. For example, a producer can emit iteration ranges, scheduling
phases, queue-saturation intervals, or instant markers on the bound
descriptor. Annotations are displayed on the same visual track as the
matching GPU work, without duplicating render-stage events in the producer.

Flow relationships are mirrored onto projected representations without
creating cross-hierarchy or Cartesian duplicate flows.

Hardware queue IDs are scoped to the trusted packet sequence. Logical queue
IDs are scoped to the process resolved from the render event's graphics
context.

UI behavior

A global GPU descriptor introducing a concrete gpu_id acts as the
placement anchor for that GPU. Existing frequency, memory, counters, and
other GPU-specific tracks become direct children of the anchor. This avoids
synthetic structures such as Counters -> GPU N.

For example, a producer can create:

NVIDIA A100
  Frequency
  Memory
  Utilization
  Channels
    Channel #1
    Channel #2

Process-owned hierarchies can similarly represent logical concepts:

CUDA
  Device #0
    Stream #2

Only successfully bound hardware or logical queues move into authored
locations. Unbound sources remain in the existing fallback hierarchy, so
authored and inferred tracks can coexist.

Traces without generic GPU descriptors retain the current UI hierarchy,
naming, and ordering.

Other changes

  • Exposes generic GPU scope and process ownership in Trace Processor.
  • Keeps GPU placement policy in the GPU plugins while TrackEventPlugin
    remains generic.
  • Resolves projected GPU Compute selections back to canonical slices.
  • Updates visualization SQL, generated Python/Rust bindings, tests, and GPU
    documentation.
  • Bumps perfetto-protos-gpu to 1.0.3.

@dreveman
dreveman requested a review from a team as a code owner July 30, 2026 14:10
@dreveman
dreveman requested a review from LalitMaganti July 30, 2026 14:10
@dreveman

Copy link
Copy Markdown
Collaborator Author

@LalitMaganti You might want to look at the individual commits as the full set of commits does a lot. This PR provides a complete picture but we can land each commit as a separate PR if you prefer.

@LalitMaganti

Copy link
Copy Markdown
Member

Still out on vacation for another week and a bit so will take a look when I'm back.

@dreveman
dreveman force-pushed the dev/dreveman/generic-gpu-tracks branch from fe2e88c to 1514129 Compare July 31, 2026 17:48
@dreveman

Copy link
Copy Markdown
Collaborator Author

Still out on vacation for another week and a bit so will take a look when I'm back.

No worries. I iterated on this approach some and I think the current version is now something I'm pretty happy with and provide all the features I was missing from perfetto when it comes to GPU workloads.

@dreveman
dreveman force-pushed the dev/dreveman/generic-gpu-tracks branch from 1514129 to 53aa55e Compare July 31, 2026 18:12
dreveman added 12 commits August 4, 2026 08:49
Allow a GPU TrackEvent root to inherit process ownership from a parent process TrackDescriptor while retaining its producer-authored GPU hierarchy.
Allow GPU TrackDescriptors to bind hardware or process logical queues. Project matching render stages through the descriptor's native sibling-merge factory while preserving canonical GPU slices and flows.
Treat authored GPU TrackEvent trees as authoritative for their global or process scope. Keep the existing inferred hierarchy only when no authored tree is present.
Share the common interning logic between GPU tracks with known and unspecified GPU IDs. Keep the blueprint and dimension differences at the two call sites.
Use the authored parent descriptor UUID to isolate process-associated GPU roots. This removes the need for process-specific GPU merge blueprints and factory branches.
Expose canonical-to-projected render stage slices through one internal PerfettoSQL relation. Reuse it across the global, per-process, and compute GPU views while keeping temporary filtering state query-scoped.
Filter ambiguous authored GPU placement anchors in SQL. This removes temporary candidate maps, null sentinels, and the associated cleanup logic.
Accumulate every canonical, hardware, and logical render stage slice for an event ID instead of overwriting each representation. This preserves dependency flows when producers reuse event IDs.
@dreveman
dreveman force-pushed the dev/dreveman/generic-gpu-tracks branch from 53aa55e to c38540e Compare August 4, 2026 17:40
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.

2 participants