GPU: a slow-frame report that says what bound the frame and why (guard split out to #2911) #2719

Open
0xkn0wh3r3 wants to merge 1 commit from upstream-pr/2721 into main
0xkn0wh3r3 commented 2026-11-25 18:50:22 +00:00 (Migrated from github.com)

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 frame line

  • bound: 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.
  • Each part's time: gpu_ms, outside_ms, ours_ms, refresh_ms, copy_back_ms, uploads_ms, heap_sync_ms, pipeline_waits_ms, and submissions.
  • With VICTORY_GPU_TIMING=1 and VICTORY_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_TIMING

  • Dispatches, mesh draws and indirect dispatches/mesh draws are noted with HostList::note_timed instead of note_op: the same note and timestamp as before, plus, when timing is on, a label (kind, groups, memory traits, pipeline).
  • After a submission, Host::execute reads each list's existing timestamps (HostList::times, factored out of slowest) 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 existing GPU ... ms/frame lines.
  • The switch is read with crate::switch::on (the existing host::timing, now also visible to the report). The README row for VICTORY_GPU_TIMING says what it adds to slow frame lines.
  • Removed: VICTORY_FRAME_TIMING, HostList::time_start/time_end, the second query heap and read-back per list, the timestamp-frequency cache, and the timestamps helper split out of the diagnostics code. main's diagnostics timing code is unchanged apart from the times split and the label.

Cost

  • The report: a few relaxed atomic adds per submission and swaps at a present. No lock, no GPU work. With timing off (and in every release build) that is all it does.
  • Timing: as VICTORY_GPU_TIMING already costs (each list run on its own, a timestamp per noted command); the labels are made only when timing is on.

Size

  • Before: 6 files, +1,025 / −42 against main.
  • Now: 7 files, +910 / −19. Of that, frame_budget.rs is 750 lines, 294 of them tests; host.rs +95 / −13; draw.rs +27 / −5.

Overlap

  • #130 (opt-in profiler) overlaps with the timing. This report runs in release builds without timing and names causes; the per-command breakdown comes from VICTORY_GPU_TIMING.

Tests

  • frame_budget:
    • the report starts over at each present, reports a slow frame and only counts the others within a second;
    • a frame names the part that bound it;
    • a GPU-bound frame names its main kind of command and its memory traits, and says how to turn timing on when it is off;
    • a frame keeps its slowest commands;
    • with timing off, no breakdown is kept;
    • (diagnostics) commands noted with note_timed are 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 (skipping host::present_plane_tests::compositor_failure_presents_primary_in_the_same_frame, which crashes the test process on main too). The two failures are dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views, which fail the same way on main on NVIDIA.
  • cargo clippy --workspace --all-targets -- -D warnings, with and without --all-features, and cargo clippy -p victory-gpu --all-targets --features diagnostics -- -D warnings: clean. cargo xtask policy: ok.

Not run with the title.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5497224585 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2721). Originally posted by [0xkn0wh3r3](https://github.com/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 frame` line - **`bound`:** 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. - **Each part's time:** `gpu_ms`, `outside_ms`, `ours_ms`, `refresh_ms`, `copy_back_ms`, `uploads_ms`, `heap_sync_ms`, `pipeline_waits_ms`, and `submissions`. - **With `VICTORY_GPU_TIMING=1` and `VICTORY_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_TIMING` - Dispatches, mesh draws and indirect dispatches/mesh draws are noted with `HostList::note_timed` instead of `note_op`: the same note and timestamp as before, plus, when timing is on, a label (kind, groups, memory traits, pipeline). - After a submission, `Host::execute` reads each list's existing timestamps (`HostList::times`, factored out of `slowest`) 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 existing `GPU ... ms/frame` lines. - The switch is read with `crate::switch::on` (the existing `host::timing`, now also visible to the report). The README row for `VICTORY_GPU_TIMING` says what it adds to `slow frame` lines. - **Removed:** `VICTORY_FRAME_TIMING`, `HostList::time_start`/`time_end`, the second query heap and read-back per list, the timestamp-frequency cache, and the `timestamps` helper split out of the diagnostics code. `main`'s diagnostics timing code is unchanged apart from the `times` split and the label. ## Cost - **The report:** a few relaxed atomic adds per submission and swaps at a present. No lock, no GPU work. With timing off (and in every release build) that is all it does. - **Timing:** as `VICTORY_GPU_TIMING` already costs (each list run on its own, a timestamp per noted command); the labels are made only when timing is on. ## Size - Before: 6 files, +1,025 / −42 against `main`. - Now: 7 files, +910 / −19. Of that, `frame_budget.rs` is 750 lines, 294 of them tests; `host.rs` +95 / −13; `draw.rs` +27 / −5. ## Overlap - #130 (opt-in profiler) overlaps with the timing. This report runs in release builds without timing and names causes; the per-command breakdown comes from `VICTORY_GPU_TIMING`. ## Tests - `frame_budget`: - the report starts over at each present, reports a slow frame and only counts the others within a second; - a frame names the part that bound it; - a GPU-bound frame names its main kind of command and its memory traits, and says how to turn timing on when it is off; - a frame keeps its slowest commands; - with timing off, no breakdown is kept; - (diagnostics) commands noted with `note_timed` are 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 (skipping `host::present_plane_tests::compositor_failure_presents_primary_in_the_same_frame`, which crashes the test process on `main` too). The two failures are `dynamic_slots_are_held_until_released` and `lists_share_a_table_and_copies_keep_their_views`, which fail the same way on `main` on NVIDIA. - `cargo clippy --workspace --all-targets -- -D warnings`, with and without `--all-features`, and `cargo clippy -p victory-gpu --all-targets --features diagnostics -- -D warnings`: clean. `cargo xtask policy`: ok. Not run with the title.
DrDarkDK commented 2026-11-25 19:06:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T18:57:52Z.


The guard checks skips() in State::bind while 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 calling bind again.

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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171639124 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2721#issuecomment-7171639124). Originally posted by [DrDarkDK](https://github.com/DrDarkDK) on 2026-11-25T18:57:52Z. --- The guard checks `skips()` in `State::bind` while 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 calling `bind` again. 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 commented 2026-11-25 19:06:43 +00:00 (Migrated from github.com)

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:

  1. 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.

  2. 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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171687260 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2721#issuecomment-7171687260). Originally posted by [kotekompotek](https://github.com/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: 1. 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. 2. 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.
DrDarkDK commented 2026-11-25 20:05:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T19:09:20Z.

Review: APPROVED


No description provided.

<!-- greyfinch-sync:Marvisak/VIctory:review:6063439071 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2721#pullrequestreview-6063439071). Originally posted by [DrDarkDK](https://github.com/DrDarkDK) on 2026-11-25T19:09:20Z. **Review:** APPROVED --- _No description provided._
0xkn0wh3r3 commented 2026-11-25 20:06:07 +00:00 (Migrated from github.com)

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_ban pins this through State::bind on the host GPU:

  • a list closed before the ban writes again when resubmitted;
  • a list recorded after the ban has no dispatch.

Submission itself is unchanged.

@kotekompotek Both points are done:

  • Per frame: strikes now count frames (present to present). Any number of over-limit commands from one pipeline in a frame is one strike.
  • Consecutive frames: a frame in which all of the pipeline's timed commands keep to the limit clears its strikes, so a one-off hitch such as a shader compile doesn't add up. Three over-limit frames in a row ban it. A frame in which the pipeline isn't timed leaves its strikes alone.

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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171878741 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2721#issuecomment-7171878741). Originally posted by [0xkn0wh3r3](https://github.com/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_ban` pins this through `State::bind` on the host GPU: - a list closed before the ban writes again when resubmitted; - a list recorded after the ban has no dispatch. Submission itself is unchanged. **@kotekompotek** Both points are done: - **Per frame:** strikes now count frames (present to present). Any number of over-limit commands from one pipeline in a frame is one strike. - **Consecutive frames:** a frame in which all of the pipeline's timed commands keep to the limit clears its strikes, so a one-off hitch such as a shader compile doesn't add up. Three over-limit frames in a row ban it. A frame in which the pipeline isn't timed leaves its strikes alone. 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 commented 2026-11-25 20:06:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T19:41:32Z.


Independent WARP/CPU verification for head de01ee6568 against origin/main 13f91caee2. 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:

  • Baseline: cargo test --locked -p victory-gpu --lib — 195 passed, 0 failed, 1 ignored; cargo clippy --locked -p victory-gpu --all-targets -- -D warnings — pass.
  • PR: cargo test --locked -p victory-gpu frame_budget::tests:: — 6 passed; cargo test --locked -p victory-gpu --lib — 202 passed, 0 failed, 1 ignored; cargo clippy --locked -p victory-gpu --all-targets -- -D warnings — pass; same Clippy command with --features diagnostics — pass.
  • Negative control: disabled timestamp start in time_start; timed_dispatches_measure_their_gpu_time failed as expected.

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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7172640664 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2721#issuecomment-7172640664). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-25T19:41:32Z. --- Independent WARP/CPU verification for head de01ee6568f652b6dc80d2e43bb27d74b149f1dd against origin/main 13f91caee25f2fdf2c062be5f7a27f058e51cbca. 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: - Baseline: cargo test --locked -p victory-gpu --lib — 195 passed, 0 failed, 1 ignored; cargo clippy --locked -p victory-gpu --all-targets -- -D warnings — pass. - PR: cargo test --locked -p victory-gpu frame_budget::tests:: — 6 passed; cargo test --locked -p victory-gpu --lib — 202 passed, 0 failed, 1 ignored; cargo clippy --locked -p victory-gpu --all-targets -- -D warnings — pass; same Clippy command with --features diagnostics — pass. - Negative control: disabled timestamp start in time_start; timed_dispatches_measure_their_gpu_time failed as expected. 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 commented 2026-11-25 20:06:23 +00:00 (Migrated from github.com)

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 (on 13f91ca):

Verification (rustc 1.98.1 MSVC)

  • cargo xtask policy: 185 files ok; cargo clippy --locked -p victory-gpu --all-targets (default & --features diagnostics): 0 warnings.
  • RTX 5090: frame_budget::tests 6 passed, 0 failed (including real GPU timed_dispatches_measure_their_gpu_time); draw::tests::a_banned_pipeline_is_dropped_from_lists_recorded_after_the_ban 1 passed.
  • WARP (VICTORY_D3D12_WARP=1): cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1 -> 205 passed, 0 failed, 1 ignored.

Review Notes

  • Arithmetic and concurrency mechanics look clean (saturating_sub, frequency.max(1), 512-command cap per list, ANY_BANNED relaxed fast path, HostList::reset clearing timed).
  • Design points for maintainers to weigh:
    • VICTORY_SLOW_PIPELINES currently defaults on (is_none_or(|v| v != "0")), meaning every non-diagnostics release build lazily allocates a 1024-entry timestamp query heap + 8 KiB readback buffer per HostList executing compute/mesh/indirect dispatches and calls GetTimestampFrequency() + Map/Unmap on every Host::execute(). Even with VICTORY_SLOW_PIPELINES=0, submitted()/waited()/presented() still take the global STATE mutex.
    • Banning after 3 consecutive >100 ms frames is currently permanent with no cooldown or warmup grace period, which could permanently silence legitimate slow pipelines on slower GPUs or WARP.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7172744296 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2721#issuecomment-7172744296). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T19:46:17Z. --- Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and code review of `de01ee6` (on `13f91ca`): ### Verification (`rustc 1.98.1` MSVC) - `cargo xtask policy`: **185 files ok**; `cargo clippy --locked -p victory-gpu --all-targets` (default & `--features diagnostics`): **0 warnings**. - **RTX 5090:** `frame_budget::tests` **6 passed, 0 failed** (including real GPU `timed_dispatches_measure_their_gpu_time`); `draw::tests::a_banned_pipeline_is_dropped_from_lists_recorded_after_the_ban` **1 passed**. - **WARP (`VICTORY_D3D12_WARP=1`):** `cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1` -> **205 passed, 0 failed, 1 ignored**. ### Review Notes - Arithmetic and concurrency mechanics look clean (`saturating_sub`, `frequency.max(1)`, 512-command cap per list, `ANY_BANNED` relaxed fast path, `HostList::reset` clearing `timed`). - **Design points for maintainers to weigh:** - `VICTORY_SLOW_PIPELINES` currently defaults **on** (`is_none_or(|v| v != "0")`), meaning every non-`diagnostics` release build lazily allocates a 1024-entry timestamp query heap + 8 KiB readback buffer per `HostList` executing compute/mesh/indirect dispatches and calls `GetTimestampFrequency()` + `Map`/`Unmap` on every `Host::execute()`. Even with `VICTORY_SLOW_PIPELINES=0`, `submitted()`/`waited()`/`presented()` still take the global `STATE` mutex. - Banning after 3 consecutive >100 ms frames is currently permanent with no cooldown or warmup grace period, which could permanently silence legitimate slow pipelines on slower GPUs or WARP.
0xkn0wh3r3 commented 2026-11-25 21:03:04 +00:00 (Migrated from github.com)

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=0 nothing is timed:

  • no timestamps, query heap, read-back or Map;
  • the guard's lock is never taken, just one relaxed atomic load.

The slow-frame report stays on, but it needs no GPU timing and takes no lock; its tallies are atomics.

With the guard on:

  • a list makes its heap only at its first timed command, and keeps it across resets;
  • only lists that timed something are read back;
  • the timestamp frequency is cached.

This also fixed a real bug: before, every executed list made a heap. On an RTX 5070 Ti, in a release build:

guard off guard on
execute a list of 64 back-to-back dispatches 132–137 µs 161–166 µs
execute a list with nothing timed 132–136 µs 133–136 µs

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:

  • A pipeline takes no strikes in its first 10 frames.
  • A ban lasts 60 s, and then the pipeline is tried again.
  • If it is still over the limit for 3 frames in a row, the ban doubles, up to 16 min.
  • One frame within the limit keeps it allowed.

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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7173410955 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2721#issuecomment-7173410955). Originally posted by [0xkn0wh3r3](https://github.com/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=0` nothing is timed: - no timestamps, query heap, read-back or `Map`; - the guard's lock is never taken, just one relaxed atomic load. The slow-frame report stays on, but it needs no GPU timing and takes no lock; its tallies are atomics. With the guard on: - a list makes its heap only at its first timed command, and keeps it across resets; - only lists that timed something are read back; - the timestamp frequency is cached. This also fixed a real bug: before, every executed list made a heap. On an RTX 5070 Ti, in a release build: | | guard off | guard on | |---|---|---| | execute a list of 64 back-to-back dispatches | 132–137 µs | 161–166 µs | | execute a list with nothing timed | 132–136 µs | 133–136 µs | 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:** - A pipeline takes no strikes in its first 10 frames. - A ban lasts 60 s, and then the pipeline is tried again. - If it is still over the limit for 3 frames in a row, the ban doubles, up to 16 min. - One frame within the limit keeps it allowed. 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.
upstream-sync changed title from [PR #2721] GPU: report frames past the budget, and stop running pipelines too slow for it to [PR #2721] GPU: a slow-frame report that says what bound the frame and why (guard split out to #2911) 2026-11-26 00:02:11 +00:00
Marvisak commented 2026-11-26 00:03:24 +00:00 (Migrated from github.com)

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_end in host.rs, hooked into dispatches, mesh draws and indirect dispatch/mesh in draw.rs). With the switch off this is counters only, which is behaviour-neutral by my reading.

Still needs work, for one concrete reason: main already has per-command GPU timestamps under VICTORY_GPU_TIMING in host.rs (the timed-list path around Host::execute and the EndQuery/ResolveQueryData code), 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:

  • build the gpu_by_kind / gpu_by_trait / slowest breakdown on the existing VICTORY_GPU_TIMING timestamps, or explain in the PR why they cannot serve (and then make the two switches one), and
  • document whichever switch remains in the README table and read it with crate::switch::on like the other VICTORY_* switches (frame_budget::timing compares to "1" by hand).

CI (check) passes.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177413786 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2721#issuecomment-7177413786). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T23:19:42Z. --- <!-- victory-triage v1 head=16aa2a49b7f8c4725f9ee4cce1580eb3f6f0eb9f verdict=needs-work at=2026-11-26T02:19:00Z --> 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_end` in `host.rs`, hooked into dispatches, mesh draws and indirect dispatch/mesh in `draw.rs`). With the switch off this is counters only, which is behaviour-neutral by my reading. Still **needs work**, for one concrete reason: `main` already has per-command GPU timestamps under `VICTORY_GPU_TIMING` in `host.rs` (the timed-list path around `Host::execute` and the `EndQuery`/`ResolveQueryData` code), 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: - build the `gpu_by_kind` / `gpu_by_trait` / `slowest` breakdown on the existing `VICTORY_GPU_TIMING` timestamps, or explain in the PR why they cannot serve (and then make the two switches one), and - document whichever switch remains in the README table and read it with `crate::switch::on` like the other `VICTORY_*` switches (`frame_budget::timing` compares to `"1"` by hand). CI (`check`) passes. --- _Generated by [Claude Code](https://claude.ai/code)_
0xkn0wh3r3 commented 2026-11-26 00:03:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T00:01:23Z.


Both points are addressed in 1252f747.

  • Guard: split out into #2911 (stacked on this one) and now opt-in. It does nothing unless VICTORY_SLOW_PIPELINES=1, so no title work is dropped by default.
  • Scope: this PR is now the slow-frame report only. Per-command GPU timing is opt-in with 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.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7178309592 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2721#issuecomment-7178309592). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T00:01:23Z. --- Both points are addressed in 1252f747. - **Guard:** split out into #2911 (stacked on this one) and now opt-in. It does nothing unless `VICTORY_SLOW_PIPELINES=1`, so no title work is dropped by default. - **Scope:** this PR is now the slow-frame report only. Per-command GPU timing is opt-in with `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.
0xkn0wh3r3 commented 2026-11-27 06:58:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-27T06:58:11Z.


Thanks. Reworked in 9fa2126 (one commit, rebased on main 63bcca4).

Second timestamp mechanism: gone. The breakdown now comes from the existing VICTORY_GPU_TIMING timestamps.

  • Removed: VICTORY_FRAME_TIMING, HostList::time_start/time_end, the second query heap and read-back per list, and the frequency cache.
  • Dispatches, mesh draws and indirect dispatch/mesh now call HostList::note_timed instead of note_op. It records the same note and timestamp, plus a label (kind, groups, memory traits) when timing is on.
  • After a submission, Host::execute reads the lists' existing timestamps and passes the labelled commands' times to frame_budget::ran. To do that, HostList::times is split out of slowest; the rest of the diagnostics timing code is unchanged.
  • gpu_by_kind, gpu_by_trait and slowest therefore need VICTORY_GPU_TIMING=1 with VICTORY_D3D12_DRED=1 in a diagnostics build. With timing off, and in release builds, the report keeps only its counters.

Switch: only VICTORY_GPU_TIMING is left. The report reads it through host::timing(), which uses crate::switch::on; nothing compares to "1" by hand any more.

README: the VICTORY_GPU_TIMING row now also says it adds GPU time per kind of command and memory trait, and the slowest commands, to slow frame lines.

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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7212015880 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2721#issuecomment-7212015880). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-27T06:58:11Z. --- Thanks. Reworked in 9fa2126 (one commit, rebased on main 63bcca4). **Second timestamp mechanism: gone.** The breakdown now comes from the existing `VICTORY_GPU_TIMING` timestamps. - Removed: `VICTORY_FRAME_TIMING`, `HostList::time_start`/`time_end`, the second query heap and read-back per list, and the frequency cache. - Dispatches, mesh draws and indirect dispatch/mesh now call `HostList::note_timed` instead of `note_op`. It records the same note and timestamp, plus a label (kind, groups, memory traits) when timing is on. - After a submission, `Host::execute` reads the lists' existing timestamps and passes the labelled commands' times to `frame_budget::ran`. To do that, `HostList::times` is split out of `slowest`; the rest of the diagnostics timing code is unchanged. - `gpu_by_kind`, `gpu_by_trait` and `slowest` therefore need `VICTORY_GPU_TIMING=1` with `VICTORY_D3D12_DRED=1` in a diagnostics build. With timing off, and in release builds, the report keeps only its counters. **Switch:** only `VICTORY_GPU_TIMING` is left. The report reads it through `host::timing()`, which uses `crate::switch::on`; nothing compares to `"1"` by hand any more. **README:** the `VICTORY_GPU_TIMING` row now also says it adds GPU time per kind of command and memory trait, and the slowest commands, to `slow frame` lines. 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.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2721:upstream-pr/2721'
git switch 'upstream-pr/2721'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/2721'
git switch 'upstream-pr/2721'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2721'
git switch 'upstream-pr/2721'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2721'
git switch 'main'
git merge --squash 'upstream-pr/2721'
git switch 'main'
git merge --ff-only 'upstream-pr/2721'
git switch 'main'
git merge 'upstream-pr/2721'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!2719
No description provided.