GPU: a slow-frame report that says what bound the frame and why (guard split out to #2911) #2719
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T18:50:22Z.
A 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. Its GPU breakdown is built on the existing per-command timestamps of
VICTORY_GPU_TIMING; this PR adds no timestamp mechanism and no switch.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". With timing off it says which switches turn it on.gpu_ms,outside_ms,ours_ms,refresh_ms,copy_back_ms,uploads_ms,heap_sync_ms,pipeline_waits_ms, andsubmissions.VICTORY_GPU_TIMING=1andVICTORY_D3D12_DRED=1(diagnostics builds):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.Timing: reuses
VICTORY_GPU_TIMINGHostList::note_timedinstead ofnote_op: the same note and timestamp as before, plus, when timing is on, a label (kind, groups, memory traits, pipeline).Host::executereads each list's existing timestamps (HostList::times, factored out ofslowest) and hands the labelled commands' times to the report. A command's time is from its timestamp to the next noted command's, as in the existingGPU ... ms/framelines.crate::switch::on(the existinghost::timing, now also visible to the report). The README row forVICTORY_GPU_TIMINGsays what it adds toslow framelines.VICTORY_FRAME_TIMING,HostList::time_start/time_end, the second query heap and read-back per list, the timestamp-frequency cache, and thetimestampshelper split out of the diagnostics code.main's diagnostics timing code is unchanged apart from thetimessplit and the label.Cost
VICTORY_GPU_TIMINGalready costs (each list run on its own, a timestamp per noted command); the labels are made only when timing is on.Size
main.frame_budget.rsis 750 lines, 294 of them tests;host.rs+95 / −13;draw.rs+27 / −5.Overlap
VICTORY_GPU_TIMING.Tests
frame_budget:note_timedare timed by the existing timestamps: a dispatch of a long loop measures far longer than one of a short loop, each under its label. Negative control: recording the label against the next note makes it fail.cargo test -p victory-gpu --lib: 234 passed, 2 failed, 1 ignored. With--features diagnostics: 249 passed, 2 failed, 1 ignored (skippinghost::present_plane_tests::compositor_failure_presents_primary_in_the_same_frame, which crashes the test process onmaintoo). The two failures aredynamic_slots_are_held_until_releasedandlists_share_a_table_and_copies_keep_their_views, which fail the same way onmainon NVIDIA.cargo clippy --workspace --all-targets -- -D warnings, with and without--all-features, andcargo clippy -p victory-gpu --all-targets --features diagnostics -- -D warnings: clean.cargo xtask policy: ok.Not run with the title.
Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T18:57:52Z.
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.
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T19:00:05Z.
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.
Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T19:09:20Z.
Review: APPROVED
No description provided.
Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T19:08:42Z.
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.
Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T19:41:32Z.
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).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T19:46:17Z.
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.Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T20:15:45Z.
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.
[PR #2721] GPU: report frames past the budget, and stop running pipelines too slow for itto [PR #2721] GPU: a slow-frame report that says what bound the frame and why (guard split out to #2911)Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:19:42Z.
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
Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T00:01:23Z.
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.Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-27T06:58:11Z.
Thanks. Reworked in
9fa2126(one commit, rebased on main63bcca4).Second timestamp mechanism: gone. The breakdown now comes from the existing
VICTORY_GPU_TIMINGtimestamps.VICTORY_FRAME_TIMING,HostList::time_start/time_end, the second query heap and read-back per list, and the frequency cache.HostList::note_timedinstead ofnote_op. It records the same note and timestamp, plus a label (kind, groups, memory traits) when timing is on.Host::executereads the lists' existing timestamps and passes the labelled commands' times toframe_budget::ran. To do that,HostList::timesis split out ofslowest; the rest of the diagnostics timing code is unchanged.gpu_by_kind,gpu_by_traitandslowesttherefore needVICTORY_GPU_TIMING=1withVICTORY_D3D12_DRED=1in a diagnostics build. With timing off, and in release builds, the report keeps only its counters.Switch: only
VICTORY_GPU_TIMINGis left. The report reads it throughhost::timing(), which usescrate::switch::on; nothing compares to"1"by hand any more.README: the
VICTORY_GPU_TIMINGrow now also says it adds GPU time per kind of command and memory trait, and the slowest commands, toslow framelines.The diff is now +910 / −19 (was +1,025 / −42). Most of it is
frame_budget.rs(750 lines, 294 of them tests).#2911 (the slow-pipeline guard) was stacked on the old head and used the per-command timing removed here. Once this one is decided, it needs reworking on top of the reused timestamps, not just a rebase. I'll do that then, or close it if the guard isn't wanted.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.