fix(host): return to REALTIME GPU priority by default on Windows #488

Merged
enricobuehler merged 5 commits from fix/realtime-gpu-priority-default into main 2026-09-01 09:57:13 +00:00
Owner

Symptom

Field report (Seenko, 2026-09-01 diagnostics, RTX 4090, 4K@120 HDR AV1 500 Mbps): under a GPU-saturating game the stream collapses — ~25 fps delivered of a 60 fps game, client-reported encoder latency ~70 ms. Capping the game's fps restores a perfect stream; the same box streams fine under Sunshine.

Diagnosis

The diagnostics show feed-scheduling contention, the exact mechanism in punktfunk-planning/design/gpu-contention-investigation.md:

  • Observed source period collapsed to 34–42 ms — only ~24–29 fps of real frames reached the capture ring; the loss is upstream of NVENC (the ASIC sat near-idle).
  • Repeated encode behind cadence + IDD pipeline depth escalated 1→2 (GPU contention); the escalation's queue offset is most of the reported 70 ms.
  • GPU-priority posture … rt_gpu_driver=off (default) rt_gpu_host=high (default) — neither REALTIME lever engaged.

Sunshine/OBS hold D3DKMT_SCHEDULINGPRIORITYCLASS_REALTIME, so their feed work preempts the game. Our 2026-08 downgrade to HIGH/off (after an RX 9070 XT A/B blamed REALTIME for the AMD metronomic capture stall) turned out not to be the AMD fix either — confirmed metronome cases kept arriving with the downgrade shipped, so that A/B recorded attenuation, not attribution.

Change

  • Host process class defaults to REALTIME (PUNKTFUNK_GPU_PRIORITY_CLASS, now off|normal|high|realtime). The auto gated-upgrade mode, HAGS probe, and VRAM monitor thread are deleted (−~300 lines).
  • vdisplay swap-chain REALTIME raise (IddCx IddCxSetRealtimeGPUPriority) defaults on; the PFVD_RT_GPU off/thread/realtime ladder is deleted. Opt-out PFVD_NO_RT_GPU remains and is now also read from the machine environment, so setx /M + a device restart applies without a reboot.
  • Stall-triage prose and docs no longer tell AMD boxes to clear the priority defaults first: display-stack suspects lead, the priority A/B is a last resort documented as masking.

Risks / expected behavior

  • The local game measurably loses fps under load when the host preempts it — by design; the remote view is the product.
  • REALTIME + NVIDIA + HAGS + near-full VRAM is a documented NVENC hang (Sunshine ships a downgrade path for it). PUNKTFUNK_GPU_PRIORITY_CLASS=high is the escape hatch; the removed VRAM auto-gate was the complexity we chose to drop.
  • Verified: rustfmt + check-writing clean, no dangling references repo-wide. Windows compile is CI-gated (cross-check from macOS fails on a cmake/MSVC dep before reaching our code).
## Symptom Field report (Seenko, 2026-09-01 diagnostics, RTX 4090, 4K@120 HDR AV1 500 Mbps): under a GPU-saturating game the stream collapses — ~25 fps delivered of a 60 fps game, client-reported encoder latency ~70 ms. Capping the game's fps restores a perfect stream; the same box streams fine under Sunshine. ## Diagnosis The diagnostics show feed-scheduling contention, the exact mechanism in `punktfunk-planning/design/gpu-contention-investigation.md`: - Observed source period collapsed to 34–42 ms — only ~24–29 fps of real frames reached the capture ring; the loss is upstream of NVENC (the ASIC sat near-idle). - Repeated `encode behind cadence` + `IDD pipeline depth escalated 1→2 (GPU contention)`; the escalation's queue offset is most of the reported 70 ms. - `GPU-priority posture … rt_gpu_driver=off (default) rt_gpu_host=high (default)` — neither REALTIME lever engaged. Sunshine/OBS hold `D3DKMT_SCHEDULINGPRIORITYCLASS_REALTIME`, so their feed work preempts the game. Our 2026-08 downgrade to HIGH/off (after an RX 9070 XT A/B blamed REALTIME for the AMD metronomic capture stall) turned out not to be the AMD fix either — confirmed metronome cases kept arriving with the downgrade shipped, so that A/B recorded attenuation, not attribution. ## Change - Host process class defaults to REALTIME (`PUNKTFUNK_GPU_PRIORITY_CLASS`, now `off|normal|high|realtime`). The `auto` gated-upgrade mode, HAGS probe, and VRAM monitor thread are deleted (−~300 lines). - vdisplay swap-chain REALTIME raise (IddCx `IddCxSetRealtimeGPUPriority`) defaults on; the `PFVD_RT_GPU` off/thread/realtime ladder is deleted. Opt-out `PFVD_NO_RT_GPU` remains and is now also read from the machine environment, so `setx /M` + a device restart applies without a reboot. - Stall-triage prose and docs no longer tell AMD boxes to clear the priority defaults first: display-stack suspects lead, the priority A/B is a last resort documented as masking. ## Risks / expected behavior - The local game measurably loses fps under load when the host preempts it — by design; the remote view is the product. - REALTIME + NVIDIA + HAGS + near-full VRAM is a documented NVENC hang (Sunshine ships a downgrade path for it). `PUNKTFUNK_GPU_PRIORITY_CLASS=high` is the escape hatch; the removed VRAM auto-gate was the complexity we chose to drop. - Verified: rustfmt + check-writing clean, no dangling references repo-wide. Windows compile is CI-gated (cross-check from macOS fails on a cmake/MSVC dep before reaching our code).
enricobuehler added 3 commits 2026-09-01 09:49:07 +00:00
Under a GPU-saturating game the stream collapsed: capture delivered
~25 fps of a 60 fps game and reported encode latency hit 70 ms while
NVENC sat near-idle. The HIGH/off defaults from the 2026-08 AMD stall
triage left every feed leg waiting behind the game's render queue, and
the AMD stall reports they were meant to fix kept coming.

Pin the host process class to REALTIME (the auto gate and its VRAM
monitor are removed) and re-enable the vdisplay swap-chain REALTIME
raise by default (the PFVD_RT_GPU ladder is removed; PFVD_NO_RT_GPU is
now also read from the machine env so the opt-out applies without a
reboot). Downgrades stay one knob per layer for the AMD metronome A/B.
check-writing flags comment blocks of six lines or more that a diff
opens; the priority-default revert opened two.
docs(windows): reframe priority downgrade as masking the AMD stall
ci / bun-nix (pull_request) Successful in 23s
ci / docs-site (pull_request) Successful in 57s
ci / web (pull_request) Successful in 1m7s
ci / docs-drift (pull_request) Failing after 1m7s
macos-host / check (pull_request) Successful in 1m9s
windows-drivers / probe-and-proto (pull_request) Successful in 1m14s
ci / rust-arm64 (pull_request) Failing after 1m19s
windows-drivers / driver-build (pull_request) Successful in 1m54s
ci / rust (pull_request) Failing after 6m24s
android / android (pull_request) Successful in 6m45s
d99a2ec11b
Confirmed metronomic-stall cases kept arriving after the 2026-08
priority downgrade shipped, so the A/B that blamed REALTIME recorded
attenuation, not attribution. Stop telling AMD triage to clear the
priority defaults first; the display-stack suspects lead again and the
priority A/B is a last resort that masks at most.
enricobuehler added 2 commits 2026-09-01 09:56:35 +00:00
The Rust 1.96 clippy image denies the manual zero-check-then-divide
pattern (manual_checked_ops) under -D warnings, so the arm64 clippy
lane fails on main and on every PR branched from it.
docs(gamescope): document PUNKTFUNK_GAMESCOPE_ISOLATE
ci / docs-site (pull_request) Successful in 55s
ci / bun-nix (pull_request) Successful in 53s
ci / web (pull_request) Successful in 1m34s
ci / docs-drift (pull_request) Successful in 38s
ci / rust-arm64 (pull_request) Successful in 3m42s
android / android (pull_request) Successful in 8m37s
windows-client / client (arm64, --no-default-features, aarch64-pc-windows-msvc, C:\t-a64) (pull_request) Successful in 2m46s
ci / rust (pull_request) Successful in 13m29s
windows-client / client (x64, , x86_64-pc-windows-msvc, C:\t) (pull_request) Successful in 6m25s
windows-drivers / probe-and-proto (pull_request) Successful in 19s
windows-drivers / driver-build (pull_request) Successful in 1m30s
apple / swift (pull_request) Successful in 2m6s
apple / distribute (pull_request) Skipped
apple / screenshots (pull_request) Skipped
macos-host / check (pull_request) Successful in 1m12s
d93184d911
The knob shipped in #485 neither documented in docs-site nor added to
the undocumented-env baseline, so the docs-drift ratchet fails every
PR. Document it: it is a user-facing escape hatch, not an internal
knob.
enricobuehler merged commit 389b58e82c into main 2026-09-01 09:57:13 +00:00
enricobuehler deleted branch fix/realtime-gpu-priority-default 2026-09-01 09:57:15 +00:00
Sign in to join this conversation.