Warpspandocs

Span profiles and cost

What "Profiles for this span" shows, how the agent groups similar spans to keep storage bounded, and how to choose between grouped, full and off.

A GPU service launches thousands of kernels a second. Keeping every kernel of every span means about one stored sample per kernel launch, so storage grows with traffic. For a video pipeline with TensorRT (8 streams, NVTX labels on every layer), that was about 30 GB a day in Pyroscope. So by default the agent groups similar spans.

Two views

The agent exports two kinds of profile. In the service view every kernel counts once. In one span's profile no kernel counts twice either; summed over all spans, though, span_gpu_time counts a kernel once for its span and once more for each ancestor (see below), so don't use it for totals:

Profile typeWhat it isUse it for
gpu_time, kernel_launchesThe service view: every kernel, no span links. Kernels launched inside spans sit under their group, like [spans 8ac31b · typical].The service's flame graph, comparing typical and slow groups
span_gpu_timeThe per-span view, linked to each spanGrafana's Profiles for this span

Point Tempo's Trace to profiles at span_gpu_time (the compose stack does).

Parent spans and CPU stages

A span's profile has everything below it in the trace. The bridges report each span's parent, and the agent adds every span's rows to all its ancestors in the per-span view: in a trace like

infer batch       ← the request
├─ gather batch   ← CPU only
└─ tensorrt infer ← launches the kernels

infer batch shows the kernels of tensorrt infer too, although it launched none itself. The service view (gpu_time) is not affected: there every kernel counts once. A span has one parent, the first reported; a link that would make a cycle is ignored. The Python and C++ bridges report parents; with the Go, Java and Rust bridges a span only has the kernels launched while it was itself current.

With NVTX routed to Warpspan and the agent started with --span-cpu-stages (off by default: the timeline shows stages over time, which reads better), a span's profile also has its stages: the NVTX ranges pushed and popped while it was current, directly inside it, with their whole duration. They sit under their own root, cpu (NVTX ranges), next to cuda:0:

infer batch
├─ cuda:0             11.1 ms   GPU time of its kernels (the tree of layers and kernels)
└─ cpu (NVTX ranges)  20.7 ms   thread time in its stages
   ├─ infer batch n=8 20.7 ms
   └─ gather batch     0.006 ms

So gather batch, which runs no kernels, has a profile with its range. A stage of a child span inside a stage of its parent is left out of the parent's stage, so the parent shows it once, under the child's path. A range that is open around the span (pushed before the span starts) isn't a stage of it. Stages are sent within about a second, and those of a thread that exits while a span is still current are lost. The two roots are different clocks: GPU time of the kernels, and wall time of the thread inside the ranges (which includes waiting for the GPU). Their sum is not the span's duration. Ranges nested inside a stage (TensorRT's per-layer ranges) aren't kept per span; their times are in the nvtx_time profile.

Grouping (the default, --span-profiles=grouped)

Every interval, for each process, the agent:

  1. Groups spans by shape. Spans that ran the same set of (NVTX path, kernel) rows share a group, for example every inference batch of 8 frames. The group's ID is a hash of that set, so it stays the same across intervals and Pyroscope adds it up over any time range.
  2. Splits each group by speed. Within a group of at least 10 spans, those above the 90th percentile of GPU time, and at least 1.2 times the group's median, are slow; the rest are typical. The 64 largest groups of a process keep their own frame; smaller ones share [spans · other shapes], so code whose spans never repeat can't flood the flame graph.
  3. Keeps exemplars. The slowest span of the process in the interval (--exemplars, default 1), whatever its group, keeps all its rows.
  4. Gives every other span a small profile of its own: its real GPU time, under its group and the NVTX ranges all its kernels share, ending in a frame that says how many kernel rows it had:
cuda:0
└─ [spans 9127ad · typical]
   └─ infer batch n=8 > enqueue > ExecutionContext::enqueueV3
      └─ (192 kernel rows; per-kernel detail in gpu_time)     12.9 ms  ← this span's own time

So Profiles for this span always shows the span's GPU time as recorded, and which group it belongs to. Kernels lost under load (the library's dropped, or the agent's unlinked_over_cap in its log) are missing from it. For the per-kernel breakdown of a typical span, open gpu_time for the same service and time and look under its group: that is what spans of this group do, not this span alone. Exemplars show their own kernels.

Kernels finish after the span that launched them. Spans whose last kernel ended within 2 s (GPU time) of the newest kernel of the process wait for the next interval, once, so a normal span is grouped whole. A span that keeps launching kernels for longer (a training loop, a long stream) is exported as it goes, in parts, and so is one with more than 2 s between its GPU bursts.

Modes

--span-profilesPer-span viewCost
grouped (default)Each span's own total and group; every kernel for the slowest spansAbout one row per span instead of one per kernel, plus one profile per group
fullEvery span keeps every kernelAbout one row per kernel launch per level of span nesting (a span's rows are repeated in each ancestor); fine for a short local run
offNoneOnly the service view

What it costs

Measured on the TensorRT pipeline above (8 streams, 248 batch spans, 50,682 kernels in one interval): full produced 48,608 span rows, grouped 439. Pyroscope kept about 70 bytes per row before compaction, so:

Per-span view, live at 25 batches a second, 10 s intervalRows per intervalRough storage per day
full, every trace sampled~48,000~30 GB
grouped, every trace sampled~440 (250 own rows + one 192-row exemplar)~0.27 GB
grouped, traces sampled at 5%~200, mostly the exemplar~0.12 GB
the same with --interval 60s~270 per minute (75 own rows + the exemplar)~0.03 GB

The service view (gpu_time) adds about one row per (group, NVTX path, kernel) per interval: about 2,500 for this pipeline at 10 s, so ~1.5 GB a day. Most of those rows come from labels that change on every call (its decode ranges carry the frame number), and those grow with the interval, so a longer interval saves little here. Without them it would be a few hundred rows per interval, and a 60 s interval would cut that part six times. See NVTX labels. All figures are estimates from the measured rows, before Pyroscope's compaction.

The cheapest control is the one you already have: trace sampling. Only kernels under sampled spans are linked, so OTEL_TRACES_SAMPLER=parentbased_traceidratio with OTEL_TRACES_SAMPLER_ARG=0.05 cuts the per-span view 20 times.

Limits

  • Grouping by exact shape works when spans repeat the same kernels, like a fixed model or a fixed batch size. Code that picks different kernels on every call (dynamic shapes, autotuning) gives every span its own group, and grouping saves little.
  • slow is relative to the interval: the 90th percentile of that group in that interval.
  • A typical span's profile has its total, not its per-kernel times.

On this page