Skip to content

research: GPU utilization readout in the status bar, merged with the acceleration light #1004

Closed
9 of 9 issues completed

Description

@zackees

Goal

The status bar shows `CPU: 1.5%`, but nothing comparable for the GPU. Users want to see at a glance CPU %, GPU %, and whether OBS renders on the GPU at all. The plan is for the GPU readout to take over the current green/yellow/red acceleration light, with the color showing hardware vs. software rendering. "GPU acceleration" needs a clearer user-facing name.

This is a research issue. The output is a written proposal plus follow-up implementation issues, not code.

Questions to answer

  1. Which GPU's utilization? The adapter OBS renders on, which may not be the only GPU (multi-GPU systems: RTX 3060 + RTX 2080 Ti here). Per-process utilization (OBS's share), or whole-GPU?
  2. Sources per platform, with their cost (polling every 1–2 s from the UI) and whether they work in sandboxes (AppImage, Flatpak, Nix FHS):
    • NVIDIA: NVML (`nvmlDeviceGetUtilizationRates`, per-process `nvmlDeviceGetProcessUtilization`), loaded dynamically, not `nvidia-smi` spawns.
    • AMD/Intel on Linux: `/sys/class/drm/card*/device/gpu_busy_percent` (amdgpu), i915/xe PMU via perf or `/sys/class/drm//engine`, or DRM fdinfo (`/proc/self/fdinfo/`, `drm-engine-*`) for per-process usage.
    • Windows: PDH "GPU Engine" counters (per-process, all vendors) or D3DKMT queries.
    • macOS: IOKit `PerformanceStatistics` ("Device Utilization %").
  3. Software rendering: what to show when OBS is on llvmpipe or WARP. GPU % is meaningless there, so it should probably say "CPU rendering" in yellow or red.
  4. Naming: candidates such as "GPU: 23%" with a colored dot, "Render: GPU 23%" / "Render: CPU", or a tooltip-only explanation. It must work in all locales (feat: Localize the GPU status summary and causes #945).
  5. Where the logic lives: `rust/obs-gpu-status` (Tier 1-testable sampling and parsing, platform code behind `src/platform/`), plus the frontend widget next to the CPU label (sibling issue), and possibly a `GetStats` field (`gpuUsage`, additive only).

Deliverable

  • A comment here or a doc under `docs/` answering 1–5, with measured overhead for each source on at least Linux NVIDIA and one other platform.
  • Follow-up implementation issues (one per platform source, plus the UI change), each with a RED → GREEN test plan.

Related

Sub-issues

Sub-issues

9 of 9 Issues completed
Loading 9 sub-issues

Activity

  1. zackees commented on Oct 16, 2026

    @zackees
    MemberAuthor

    Research result

    Status: I measured NVML on real hardware and checked the kernel's DRM fdinfo spec. Claims marked unverified come from memory and need a check before implementing.

    Measured (NixOS 26.05, kernel 6.18.48, RTX 3060 + RTX 2080 Ti, driver 595.99.02)

    Query Cost
    NVML nvmlDeviceGetUtilizationRates 0.68 ms median per device (p95 1.09 ms)
    NVML nvmlDeviceGetProcessUtilization 14 ms; works, returned 2 per-process samples
    Spawning nvidia-smi --query-gpu=utilization.gpu 87 ms median
    • NVML is about 130× cheaper than nvidia-smi for polling, so use it, loaded with dlopen, never by spawning a process.
    • NVML enumerates both cards with PCI bus IDs (00000000:06:00.0, 00000000:07:00.0). Match the render adapter by bus ID (nvmlDeviceGetHandleByPciBusId_v2), never by index.
    • NixOS finding: libnvidia-ml.so.1 is not on the default loader path; it lives in /run/opengl-driver/lib. The loader must search that directory explicitly, as AppRun already does for the EGL configs.
    • No gpu_busy_percent exists on this host (NVIDIA only). That file is amdgpu-specific.

    Verified: kernel DRM fdinfo (docs.kernel.org/gpu/drm-usage-stats.html)

    • Mandatory: drm-driver.
    • Optional: drm-pdev (PCI slot, which ties a fd to an adapter), drm-client-id (dedupes shared or duplicated fds), drm-engine-<name> (busy time in ns), drm-engine-capacity-<name>, and drm-cycles-<name> with drm-total-cycles-<name>.
    • The values are cumulative counters, not percentages: sample twice and divide by the elapsed time.
    • The page has implementation notes for i915, Xe, Panfrost and Panthor. Which amdgpu kernel version exposes engine times is unverified. NVIDIA's proprietary driver does not provide fdinfo engine stats (unverified, consistent with this host).

    1. Which GPU, and what to show

    • Measure the adapter OBS renders on:
    • Headline value: whole-adapter utilization, which is what users compare with Task Manager or nvtop. OBS's own share goes in the tooltip where it's cheap.
    • Decision for the maintainer: headline is whole-GPU, not OBS-only.

    2. Sources per platform

    Platform Source Scope Notes
    NVIDIA (Linux, Windows) NVML via dlopen Whole GPU, plus per-process Measured above
    Linux AMD gpu_busy_percent sysfs Whole GPU Cheapest AMD source (unverified on all kernels)
    Linux Intel/AMD/Xe DRM fdinfo Per-process Verified key format
    Linux Intel i915/xe PMU (perf) Whole GPU Needs perf permissions; often blocked in Flatpak/bwrap. Not first choice.
    Windows (all vendors) PDH \GPU Engine(*)\Utilization Percentage Per process and adapter (LUID) Whole-adapter = max over engine types, as Task Manager does it (unverified)
    macOS IOKit IOAccelerator → PerformanceStatistics → Device Utilization % Whole GPU Undocumented key (unverified); hide it when missing

    3. Software rendering (with the colors from #1005)

    • On llvmpipe or WARP a GPU percentage means nothing, so replace it with the text "CPU rendering". The color follows obs-gpu-status: Red when a GPU is present but unused, yellow for software-only machines #1005: red if a GPU is present but unused, yellow if there's no GPU.
    • Never show a percentage for a GPU OBS isn't using, such as an idle RTX at 0% while OBS renders on llvmpipe.
    • If hardware rendering works but no utilization source is available, show "GPU: n/a" with a green dot, and give the reason in the tooltip.

    4. Naming

    • Recommended: GPU: 23% with the colored dot. Keys: Basic.StatusBar.Gpu.Usage="GPU: %1%", .Unavailable="GPU: n/a", .Software="CPU rendering". The existing Basic.StatusBar.GpuStatus.* keys become the tooltip. Add keys only, so translations aren't broken (feat: Localize the GPU status summary and causes #945).
    • Dialog title: "GPU Acceleration" becomes "Graphics rendering".
    • Rejected: Render: GPU 23% (clips in long-word locales) and a bare 23% (doesn't say what it is).
    • Note: the existing CPU: label is a hard-coded English string (OBSBasicStatusBar::UpdateCPUUsage). Don't copy that pattern; localizing it could be a small follow-up.

    5. Where the code goes

    • rust/obs-gpu-status, pure Tier 1 code:
      • Parsers: fdinfo text, PDH instance names, gpu_busy_percent.
      • Logic: counter deltas, max-over-engines aggregation, and the mapping from classify plus a sample to what's displayed.
    • src/platform/: host calls (NVML dlopen, PDH, IOKit, /proc scanning).
    • src/ffi: a sampler C ABI for the frontend.
    • Frontend: UpdateGpuUsage() on the same timer as the CPU label, next to it (frontend: Put the GPU status light next to the CPU usage (#1003) #1010 already moves the light there). Sample off the UI thread, because the PDH and fdinfo scans aren't free.
    • obs-websocket: an additive, nullable GetStats.gpuUsage.

    Proposed follow-ups, in order of value

    1. Adapter identity resolver (render node / LUID / registryID → PCI bus ID). Test: Tier 1 fixture with two identical cards.
    2. NVML dlopen sampler with bus-ID matching and NixOS /run/opengl-driver/lib search. Test: fake symbol table; a missing library gives Unavailable.
    3. Windows PDH sampler. Test: Tier 1 on captured instance-name lists.
    4. Linux fdinfo sampler (Intel/AMD/Xe). Test: fixture fdinfo texts.
    5. amdgpu gpu_busy_percent fallback. Test: fixture sysfs tree.
    6. GPU: x% label replaces the light. Test: injected sampler gives the right text and color for hardware, software and n/a.
    7. macOS IOKit sampler. Test: captured dictionary.
    8. GetStats.gpuUsage. Test: Tier 4 shows existing fields unchanged.
    9. Sandbox smoke test (AppImage/Flatpak/Nix): the NVML search path and fdinfo access.

    I'll file these as sub-issues once you agree with the two decisions above: whole-GPU as the headline, and "GPU: x%" as the name.

  2. zackees commented on Oct 16, 2026

    @zackees
    MemberAuthor

    Research done: result. NVML was measured on real hardware and the fdinfo spec checked. The implementation work is filed as sub-issues #1020–#1028. The two open choices (whole-GPU headline, GPU: x% label) are recorded as editable defaults in each issue's Decisions section. Measuring a second platform moved to #1022 (Windows PDH) and #1023 (Linux fdinfo).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions