GPU: a slow-frame report that says what bound the frame and why (guard split out to #2911) #2721
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2721
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2721"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@0xkn0wh3r3 on GitHub · 2026-11-25 18:50 UTC · original
0xkn0wh3r3:gpu/frame-budget→main· +1025 −42 · 6 files · 9 commits · openA report of each frame past 50 ms (at most one line a second, counting the others), saying what bound the frame and why in terms of any title. It also adds per-command GPU timing, which the report uses when
VICTORY_FRAME_TIMING=1.Split after review: the slow-pipeline guard that was part of this PR is now a separate opt-in PR stacked on this one (#2911). This PR drops no title work.
The
slow framelinebound: the frame's largest part, one of:GPU;outside submissions: the title's own work and the translation of its command-list calls;title memory refresh;copy-back;texture uploads;descriptor heap sync;pipeline waits.why, in a sentence. For a GPU-bound frame with timing on, it names the main kind of command and the ways of reaching memory most of the GPU time used, e.g. "80% of the timed GPU time is compute work (412 commands); 80% is in programs using title memory by address".gpu_ms,outside_ms,ours_ms,refresh_ms,copy_back_ms,uploads_ms,heap_sync_ms,pipeline_waits_ms, andsubmissions.VICTORY_FRAME_TIMING=1:gpu_by_kind: compute, mesh, indirect compute and indirect mesh, each with its time and count;gpu_by_trait: time per way programs reach memory;slowest: the three slowest commands with their group counts and traits.Cost
Overlap
VICTORY_GPU_TIMING, diagnostics) overlap with the timing.Tests
frame_budget:cargo test -p victory-gpu --lib: everything passes exceptdynamic_slots_are_held_until_releasedandlists_share_a_table_and_copies_keep_their_views, which fail the same way on main on NVIDIA (fixed by #2121).frame::tests::waits_end_on_ticks_and_count_framesfailed once in a full run and passed alone (a 50 ms timing assertion).--features diagnostics.Not run with the title.
The report named the frame's time, ours, the GPU's and pipeline waits, and the slowest commands by their shader hashes: enough to see that a frame was slow, not what made it so. It now splits the frame into its parts and names the largest as what bound it, with why: - our work around submissions, each phase on its own: descriptor heap sync (and evictions), texture uploads, refreshing host copies of title memory, and copy-back of what shaders wrote; - the GPU's; - pipeline waits; - the rest ("outside submissions"): the title's own work on its threads and the translation of its command-list calls as it makes them. With the guard on, the GPU's part is broken down by kind of command (compute, mesh, and their indirect forms: time and count) and by how the commands' programs reach memory: title memory by address through the page table (whose writes set bitmap bits with atomics), write marks through views, views picked from the heap, view addresses read. The slowest commands are described the same way, with their group counts: "600 ms compute 1024x1x1 groups [title memory by address] [compute ..]". A GPU-bound frame's why reads, for example, "80% of the timed GPU time is compute work (412 commands); 80% is in programs using title memory by address". Nothing in it depends on a particular title. The phases are a few Instant reads per submission and relaxed atomic adds, as before; with the guard off nothing is timed or locked.f3578e3) into gpu/frame-budget 1bf3f89ff0@DrDarkDK on GitHub · 2026-11-25 18:57 UTC · original
The guard checks
skips()inState::bindwhile recording. If one closed list with a slow dispatch is submitted three times and exceeds the limit each time, the pipeline is banned. Submitting that same list a fourth time still runs the dispatch because submission reuses the recorded commands without callingbindagain.Could the warning and PR description say the guard skips newly recorded commands? Resubmitting a closed list after its pipeline is banned would make a focused regression test for that boundary.
AI-assisted with Codex.
@kotekompotek on GitHub · 2026-11-25 19:00 UTC · original
Well-instrumented and honest about the trade-off (fences/copies still run so nothing waits forever; the warn names the pipeline once). Two design points worth a second look:
Strikes are counted per command, not per frame - a pipeline backing three timed commands that each exceed the limit is banned after a single frame. If the intent is 'slow three times across frames', consider one strike per frame per pipeline.
Default-on with a hard 100 ms cutoff permanently drops pipelines on genuinely slow hosts (a world frame is ~1 s on current main). Missing output is arguably better than a device reset, but a banned compute pipeline's results are gone for the whole session - a counter of consecutive over-limit frames (so one-off spikes like shader-compile hitch doesn't accrue) might ban less aggressively. VICTORY_SLOW_PIPELINES=0 escape hatch is good.
skips()/ANY_BANNED fast-path and the per-list timestamp cap (1024, resolved at close) look right; skipped counting inside the mutex is correct.
@0xkn0wh3r3 on GitHub · 2026-11-25 19:08 UTC · original
Thanks both. Fixed in
de01ee6.@DrDarkDK Agreed: the ban is checked when commands are recorded, not when they are submitted. The warning, module docs and description now say that draws and dispatches recorded after the ban are dropped, and that lists recorded before it still run the pipeline when resubmitted.
draw::tests::a_banned_pipeline_is_dropped_from_lists_recorded_after_the_banpins this throughState::bindon the host GPU:Submission itself is unchanged.
@kotekompotek Both points are done:
Only pipelines timed in a frame are tracked. New tests cover three slow commands in one frame (no ban), slow, quick, slow, slow (no ban), and three slow frames in a row (banned when the third frame ends). One consequence is now in the description: strikes are tallied at presents, so work never followed by a present bans nothing.
@oni-swr on GitHub · 2026-11-25 19:41 UTC · original
Independent WARP/CPU verification for head
de01ee6568against origin/main13f91caee2. State check: open, non-draft, clean merge-tree; no oni-swr comment found.Environment: Windows x64, Rust 1.98.1 (48a229cea 2026-09-01), Windows SDK dxil.dll 10.0.26100.0 (file version 1.8.2502.11); WARP/D3D12 WARP env vars set; CARGO_TARGET_DIR=D:\victory-warp-2720-target.
Commands/results:
Review: the frame-level strikes and pre-recorded-list boundary match the documented behavior; no additional blocker found.
Not tested: physical GPU, retail title/game behavior, release build. AI disclosure: Codex (gpt-6-luna).
@fuzeofficlal on GitHub · 2026-11-25 19:46 UTC · original
Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and code review of
de01ee6(on13f91ca):Verification (
rustc 1.98.1MSVC)cargo xtask policy: 185 files ok;cargo clippy --locked -p victory-gpu --all-targets(default &--features diagnostics): 0 warnings.frame_budget::tests6 passed, 0 failed (including real GPUtimed_dispatches_measure_their_gpu_time);draw::tests::a_banned_pipeline_is_dropped_from_lists_recorded_after_the_ban1 passed.VICTORY_D3D12_WARP=1):cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1-> 205 passed, 0 failed, 1 ignored.Review Notes
saturating_sub,frequency.max(1), 512-command cap per list,ANY_BANNEDrelaxed fast path,HostList::resetclearingtimed).VICTORY_SLOW_PIPELINEScurrently defaults on (is_none_or(|v| v != "0")), meaning every non-diagnosticsrelease build lazily allocates a 1024-entry timestamp query heap + 8 KiB readback buffer perHostListexecuting compute/mesh/indirect dispatches and callsGetTimestampFrequency()+Map/Unmapon everyHost::execute(). Even withVICTORY_SLOW_PIPELINES=0,submitted()/waited()/presented()still take the globalSTATEmutex.@0xkn0wh3r3 on GitHub · 2026-11-25 20:15 UTC · original
Thanks @fuzeofficlal, and thanks @oni-swr for the WARP run and the negative control. Both points are addressed in
ecb7640.Cost. With
VICTORY_SLOW_PIPELINES=0nothing is timed:Map;The slow-frame report stays on, but it needs no GPU timing and takes no lock; its tallies are atomics.
With the guard on:
This also fixed a real bug: before, every executed list made a heap. On an RTX 5070 Ti, in a release build:
That's about 0.45 µs per timed command, mostly the GPU writing the timestamps. Recording costs about 0.25 µs per timed command. So the guard stays on by default; the table is in the description.
Permanent bans:
The retry and the re-ban are each logged once. New tests cover the warm-up, the retry and re-ban through to the cap, a retried pipeline that is now quick staying allowed, and the off path never taking the lock or making a heap.
@Marvisak on GitHub · 2026-11-25 23:19 UTC · original · edited 2026-11-26 02:19 UTC
Automated triage for the maintainers.
Thanks, both earlier points are addressed: the slow-pipeline guard is now the separate opt-in #2911, and this PR no longer drops title work. What remains is the slow-frame report (
crates/victory-gpu/src/frame_budget.rs) and an opt-in per-command timing (VICTORY_FRAME_TIMING=1,HostList::time_start/time_endinhost.rs, hooked into dispatches, mesh draws and indirect dispatch/mesh indraw.rs). With the switch off this is counters only, which is behaviour-neutral by my reading.Still needs work, for one concrete reason:
mainalready has per-command GPU timestamps underVICTORY_GPU_TIMINGinhost.rs(the timed-list path aroundHost::executeand theEndQuery/ResolveQueryDatacode), documented in the README switch table. This PR adds a second, parallel timestamp mechanism with its own query heaps and readback (≈1,000 lines in total). What would change the verdict:gpu_by_kind/gpu_by_trait/slowestbreakdown on the existingVICTORY_GPU_TIMINGtimestamps, or explain in the PR why they cannot serve (and then make the two switches one), andcrate::switch::onlike the otherVICTORY_*switches (frame_budget::timingcompares to"1"by hand).CI (
check) passes.Generated by Claude Code
@0xkn0wh3r3 on GitHub · 2026-11-26 00:01 UTC · original
Both points are addressed in
1252f747.VICTORY_SLOW_PIPELINES=1, so no title work is dropped by default.VICTORY_FRAME_TIMING=1. The module comment and constant rationales are trimmed to say what the code does. The description names #130 and #1735 and how this relates to them.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.