Skip to content

tp: Add gpu_context table for InternedGraphicsContext#5523

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

tp: Add gpu_context table for InternedGraphicsContext#5523
dreveman wants to merge 1 commit intomainfrom
dev/reveman/gpu-context

Conversation

@dreveman
Copy link
Copy Markdown
Collaborator

@dreveman dreveman commented Apr 21, 2026

Add a new gpu_context table that maps GPU graphics context IDs to their associated process ID and API type (OPEN_GL, VULKAN, OPEN_CL, CUDA, HIP). This resolves the TODO in gpu_event_parser.cc to create a proper table for graphics context data.

Previously, the context field on GpuRenderStageEvent was used to look up InternedGraphicsContext but only the pid was extracted -- the api field was ignored and no structured table existed for context metadata. Now the full context metadata is materialized into a queryable table.

The table is populated lazily: each unique context_id is inserted on first encounter during GpuRenderStageEvent parsing.

The view is exposed via a new gpu stdlib module at gpu.context, accessible with INCLUDE PERFETTO MODULE gpu.context.

Schema:
gpu_context(id, context_id, pid, api)

Example query:
INCLUDE PERFETTO MODULE gpu.context;
SELECT gc.api, gs.name, gs.dur
FROM gpu_slice gs
JOIN gpu_context gc ON gs.context_id = gc.context_id
WHERE gc.api = 'CUDA'

Related: #5097

@dreveman dreveman requested a review from LalitMaganti April 21, 2026 15:17
@dreveman dreveman requested a review from a team as a code owner April 21, 2026 15:17
Comment thread src/trace_processor/importers/proto/gpu_event_parser.cc Outdated
Comment thread src/trace_processor/importers/proto/gpu_event_parser.cc Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 21, 2026

@dreveman dreveman force-pushed the dev/reveman/gpu-context branch from 22eb082 to 642e99e Compare April 21, 2026 15:49
@dreveman dreveman requested a review from LalitMaganti April 21, 2026 15:49
Comment thread src/trace_processor/perfetto_sql/stdlib/prelude/after_eof/views.sql Outdated
@dreveman dreveman requested a review from LalitMaganti April 21, 2026 17:32
@dreveman dreveman force-pushed the dev/reveman/gpu-context branch from 642e99e to 195ff6e Compare April 21, 2026 17:33
Comment thread tools/check_sql_modules.py
Add a new gpu_context table that maps GPU graphics context IDs to
their associated process ID and API type (OPEN_GL, VULKAN, OPEN_CL,
CUDA, HIP). This resolves the TODO in gpu_event_parser.cc to create
a proper table for graphics context data.

Previously, the context field on GpuRenderStageEvent was used to look
up InternedGraphicsContext but only the pid was extracted -- the api
field was ignored and no structured table existed for context metadata.
Now the full context metadata is materialized into a queryable table.

The table is populated lazily: each unique context_id is inserted on
first encounter during GpuRenderStageEvent parsing.

The view is exposed via a new gpu module under std at std.gpu.context,
accessible with INCLUDE PERFETTO MODULE std.gpu.context.

Schema:
  gpu_context(id, context_id, pid, api)

Example query:
  INCLUDE PERFETTO MODULE std.gpu.context;
  SELECT gc.api, gs.name, gs.dur
  FROM gpu_slice gs
  JOIN gpu_context gc ON gs.context_id = gc.context_id
  WHERE gc.api = 'CUDA'

Related: #5097
@dreveman dreveman force-pushed the dev/reveman/gpu-context branch from 195ff6e to ab089d3 Compare April 21, 2026 18:09
@dreveman dreveman requested a review from LalitMaganti April 21, 2026 18:10
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