Warpspandocs

Timeline

Every NVTX range and GPU kernel of a process over time, like Nsight Systems, in a Grafana dashboard, kept continuously in short windows.

The timeline shows what an app does over time: one row per NVTX label, with a bar wherever that label was running, and the GPU kernels at their real start and end. It's the view Nsight Systems gives you for a short capture, kept all the time in production and opened from Grafana.

Requests          ███████████   ████████ (slowest)    ███████████
NVTX ranges
 ▸ decode s3 f#     ▆▆   ▆▆   ▆▆   ▆▆   ▆▆   ▆▆
 ▸ preprocess s3 f#   ▆    ▆    ▆    ▆    ▆
 ▾ infer batch n=8  ███████████   ████████████   ██████████
   ▸ copy in        ▏             ▏              ▏
   ▾ enqueue         █████████     ██████████     ████████
     ▸ /model/model.0/conv …  (each TensorRT layer, and under it "GPU": its kernels)
 ▸ encode s3 f#         ▆▆        ▆▆        ▆▆
GPU
 ▸ cuda:0  stream 33 ▌▌▌▌▌▌ ▌▌▌▌▌   ▌▌▌▌▌▌▌▌      ← gaps: the GPU idle for this process
Threads
 ▸ thread 3402      ranges as pushed on that thread (Nsight's per-thread view)

Open it

In Grafana, open Dashboards → Warpspan → Warpspan and pick a service. The Timeline panel at the top shows the windows in the dashboard's time range (see below): click one in the bar above the timeline. The slowest-request window opens first.

  • Click ▸ on a row to see what ran inside it, down to the kernels (the GPU row under a label).
  • Drag across the time axis to zoom in; W/S zoom, A/D move.
  • Click a bar to see its details: kernel name, stream, launching thread, span. Each kernel is linked to the NVTX range it was launched in (a Perfetto flow).
  • Below the timeline: time per stage (nvtx_time) and GPU time per layer and kernel (gpu_time) over the whole time range, and the slowest requests, linked to their traces.

The viewer is Perfetto, the open-source trace viewer Nsight-style tools use, inside a Grafana panel.

From a trace

Every span in Grafana's trace view (Explore → Tempo, or a trace opened from a dashboard) has a GPU timeline button. It opens the Warpspan dashboard on the window that holds that request, zoomed to it, with the span's time marked in orange across the rows.

A window exists for the slowest request of every 5 seconds and for one second of every minute, so most requests have none. The panel then says so and shows the nearest window, which is what the process was doing around that time, not the request itself.

The mark covers the span's time on every row. On a process serving several requests at once, the bars under it belong to all of them.

Windows

Keeping every event is too much: a TensorRT pipeline with 8 video streams makes about 47,000 a second. The agent keeps the last 10 seconds of each process in memory and saves windows of it:

  • every minute, one second of normal operation (--timeline-every, --timeline-window);
  • around the slowest request of each process in every 5 seconds (--timeline-slowest). A request is a trace: from when a thread first enters one of its spans to when the last thread leaves it. The window covers the whole request; one that started before the agent's 10-second buffer is marked (cut).

A window is written a few seconds after its end, once the kernels in it have arrived. Windows are gzipped Perfetto traces in --timeline-dir, about 1.5 MB for a one-second window of the pipeline above and 0.1–0.2 MB for a slow-request window. The oldest are deleted past --timeline-max-bytes (1 GiB) or --timeline-max-age (24 h).

How it fits together

GPU process ──▶ agent (each node) ──upload──▶ gateway ──▶ Grafana: Warpspan data source + Timeline panel
                 keeps 10 s, cuts windows       keeps windows    (windows through Grafana's proxy,
                                                serves the viewer   the viewer from the gateway)
  • Agents cut windows and upload them to the gateway (warpspan gateway, same image as the agent) with --timeline-push.
  • In Grafana, the Warpspan data source lists and fetches windows from the gateway through Grafana's data source proxy, so Grafana's login and permissions apply and browsers never talk to agents.
  • The Warpspan timeline panel shows them. It frames the viewer (the Perfetto UI, static code with no data) from the gateway's /embed page and hands it each window, so the data source's Viewer URL must be where your users' browsers reach the gateway.

The two plugins are in deploy/grafana-plugins (razinai-warpspan-datasource, razinai-warpspan-panel). They aren't signed yet, so Grafana loads them only when allowed by name: allow_loading_unsigned_plugins = razinai-warpspan-datasource,razinai-warpspan-panel under [plugins] (GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS). That's the only Grafana setting they need; HTML sanitizing stays on.

Turn it on

The library records the events unless WARPSPAN_TIMELINE=0. Label rows need NVTX_INJECTION64_PATH; without it you get GPU rows and requests only.

  • Compose stack: it has the gateway (on 127.0.0.1:9099), both plugins, the data source and the dashboard. The data source's Viewer URL is http://localhost:9099, so open Grafana in a browser on the same machine. Run the agent on the host with:

    ./bin/warpspan --timeline-dir ./timeline --timeline-push http://127.0.0.1:9099 …
  • Kubernetes: the Helm chart runs the gateway (gateway.enabled) and points every agent at it. Its windows are in an emptyDir and lost when the gateway restarts, unless you turn on gateway.persistence (a 20 GiB claim; needs a StorageClass). In your Grafana:

    1. Copy the two plugin folders into Grafana's plugins directory and allow them as above.
    2. Add a Warpspan data source with URL http://<release>-warpspan-gateway.<namespace>:9099, and as Viewer URL an address your browsers reach the gateway at: an ingress for /embed and /perfetto (gateway.ingress), or http://localhost:9099 with kubectl port-forward svc/<release>-warpspan-gateway 9099:9099.
    3. Import deploy/grafana-dashboards/warpspan.json.
    4. For the GPU timeline button on spans, add a correlation to your Tempo data source (Administration → Plugins and data → Correlations, or in provisioning as below): type External, results field traceID, and this URL.
      correlations:
        - label: GPU timeline
          type: external
          config:
            field: traceID
            target:
              url: "/d/warpspan/warpspan?var-service=$${serviceName}&var-trace=$${traceID}&var-at=$${startTime}&var-dur=$${duration}"
      In a provisioning file each $ is doubled as shown, because Grafana otherwise reads ${…} as an environment variable. In the Correlations page, write a single $.

    Set gateway.uploadToken and gateway.readToken, two different values: agents then need the first to upload, and listing or fetching windows needs the second, which you add to the data source as a custom header Authorization: Bearer <readToken>. Set gateway.frameOrigins to your Grafana's origin, so only it can embed the viewer. The viewer itself holds no data.

    The Viewer URL must use https if Grafana does (browsers block an http frame in an https page), and be reachable from your users' browsers; the panel says so when the viewer doesn't answer.

  • One machine, no gateway: the agent can serve its own view: --timeline-listen 127.0.0.1:9099 --timeline-ui ./perfetto-ui (unzipped perfetto-ui.zip v59.1), then open http://127.0.0.1:9099/view.

To turn it off: WARPSPAN_TIMELINE=0 in the app (no timeline events or launch times are recorded or sent, and the agent keeps nothing for that process), or --timeline-dir= on the agent.

Cost

  • In the app: each NVTX push and pop and each span change writes 48 bytes into a per-thread ring, with no lock; a separate thread sends the rings every 25 ms. Each kernel launch also stores its time and thread. On the pipeline above, run times with and without it were within the run-to-run noise (5–6 s for a short run).
  • In the agent: about 0.13 CPU core and up to ~300 MB of memory per busy GPU process (the 10-second buffer, at most 600,000 events per process and 1.2 million per node, and building windows). On the pipeline above the app ran as fast as without the timeline.
  • Socket: about 1–2 MB/s per busy process.

What it doesn't show

  • Work on the video decoder and encoder (NVDEC, NVENC): CUPTI doesn't trace them. Their NVTX ranges still show how long the CPU spent in them.
  • Memory copies, synchronisation and CUDA API calls: not recorded yet.
  • Other processes on the same GPU: gaps in the GPU rows are idle time of this process only.
  • Kernel times are the GPU's, converted to the CPU's clock, so a kernel can appear a few microseconds early.
  • Windows are per process: a window doesn't show the other GPU processes on the node at that time.
  • A range is recorded when it ends, so one still open when a window is written (longer than a few seconds, or wrapping a whole thread) is missing, though the ranges inside it show.
  • Times are shown in the agent's time zone (set TZ on the agent container, which is UTC by default).
  • Without tokens, anything that can reach the gateway can list, read and upload windows, including a web page in the same browser through DNS rebinding when the gateway is on localhost. Set gateway.uploadToken and gateway.readToken in a shared cluster.
  • If the gateway is down, agents keep the windows on their disk and upload them when it is back (the newest 1,000 per agent).
  • Windows live on the gateway's volume; one gateway replica. Object storage (S3, GCS) is not supported yet.

On this page