GPU: an opt-in slow-pipeline guard, VICTORY_SLOW_PIPELINES=1 (stacked on #2721) #2909

Open
0xkn0wh3r3 wants to merge 12 commits from upstream-pr/2911 into main
0xkn0wh3r3 commented 2026-11-25 23:50:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T23:50:13Z.


Stacked on #2721, the slow-frame report; only the last commit is new. Split out of #2721 after review.

With VICTORY_SLOW_PIPELINES=1 (off by default, because it drops title work), compute dispatches and mesh draws are timed. A pipeline is dropped when one of its commands goes over the limit (VICTORY_SLOW_PIPELINE_MS, 100 ms) in 3 frames in a row, not counting its first 10 frames.

  • Draws and dispatches of it recorded from then on are dropped (State::bind).
  • After 60 s it is tried again. Each later ban doubles, up to 16 minutes, and a frame within the limit lifts it.
  • Lists recorded before a ban still run its commands.

The point: a submission can't be stopped once it runs, and one the host takes 2 s for resets the device. The cost is that what the dropped pipeline computes is missing; each ban and retry is logged.

Tests

  • No strikes during a pipeline's first frames; slow commands within one frame count as a single strike.
  • A frame within the limit clears the strikes; three slow frames in a row ban the pipeline.
  • Bans end and double; a pipeline that is quick when tried again stays allowed.
  • A ban made through the global calls is seen by skips.
  • With the guard off, timed commands strike nothing.
  • draw::tests::a_banned_pipeline_is_dropped_from_lists_recorded_after_the_ban checks on the host GPU that a list recorded before the ban still runs it, and one recorded after doesn't.
  • Clippy is clean, with and without --features diagnostics. The two NVIDIA heap-limit failures that #2121 fixes also happen on main.

Not run with the title.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6616178065 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2911). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T23:50:13Z. --- Stacked on #2721, the slow-frame report; only the last commit is new. Split out of #2721 after review. With `VICTORY_SLOW_PIPELINES=1` (off by default, because it drops title work), compute dispatches and mesh draws are timed. A pipeline is dropped when one of its commands goes over the limit (`VICTORY_SLOW_PIPELINE_MS`, 100 ms) in 3 frames in a row, not counting its first 10 frames. - Draws and dispatches of it recorded from then on are dropped (`State::bind`). - After 60 s it is tried again. Each later ban doubles, up to 16 minutes, and a frame within the limit lifts it. - Lists recorded before a ban still run its commands. The point: a submission can't be stopped once it runs, and one the host takes 2 s for resets the device. The cost is that what the dropped pipeline computes is missing; each ban and retry is logged. ## Tests - No strikes during a pipeline's first frames; slow commands within one frame count as a single strike. - A frame within the limit clears the strikes; three slow frames in a row ban the pipeline. - Bans end and double; a pipeline that is quick when tried again stays allowed. - A ban made through the global calls is seen by `skips`. - With the guard off, timed commands strike nothing. - `draw::tests::a_banned_pipeline_is_dropped_from_lists_recorded_after_the_ban` checks on the host GPU that a list recorded before the ban still runs it, and one recorded after doesn't. - Clippy is clean, with and without `--features diagnostics`. The two NVIDIA heap-limit failures that #2121 fixes also happen on main. Not run with the title.
kotekompotek commented 2026-11-26 00:03:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T23:52:59Z.

Review: COMMENTED


Scoped review: opt-in drop of pipelines measured too slow happens at record time (closed lists keep the commands — replay isn't corrupted), and per-op timing via time_start/time_end feeds the decision. One thing to double-check on the base: skipping a draw entirely also skips its resource transitions/barriers the prelude planned — if the next draw assumed the dropped one's final states, a skip could need a state repair; worth confirming the planner handles mid-list holes.

<!-- greyfinch-sync:Marvisak/VIctory:review:6066645208 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2911#pullrequestreview-6066645208). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T23:52:59Z. **Review:** COMMENTED --- Scoped review: opt-in drop of pipelines measured too slow happens at record time (closed lists keep the commands — replay isn't corrupted), and per-op timing via time_start/time_end feeds the decision. One thing to double-check on the base: skipping a draw entirely also skips its resource transitions/barriers the prelude planned — if the next draw assumed the dropped one's final states, a skip could need a state repair; worth confirming the planner handles mid-list holes.
fuzeofficlal commented 2026-11-26 01:03:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T00:04:07Z.

Review: COMMENTED


Verified head 7abc8fc3 (stacked on #2721) cleanly merged onto origin/main (63bcca43) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + D3D12 WARP + VICTORY_D3D12_DEBUG=1).

Code & Concurrency Review

  • Zero-overhead default path: With VICTORY_SLOW_PIPELINES off (and VICTORY_FRAME_TIMING != 1), skips() and timing() stay lock-free relaxed atomic checks without allocating query heaps/readback buffers or taking GUARD. Timestamp deltas safely use saturating_sub and frequency.max(1).
  • Observations / Suggestions (non-blocking):
    1. Stale log hint (crates/victory-gpu/src/frame_budget.rs:584, test L1136): The !timed message still reads "GPU work (commands are not timed with VICTORY_SLOW_PIPELINES=0)". Now that timing is split out behind VICTORY_FRAME_TIMING=1, pointing users to VICTORY_FRAME_TIMING=1 avoids nudging someone who only wants command timings to turn on the drop guard.
    2. Lock contention while any pipeline is banned (frame_budget.rs:471, 492-501): Once ANY_BANNED flips true (for 60s–16m), every recording thread takes the global Mutex<Option<Guard>> on every State::bind (even for unbanned pipelines), contending with ran() / presented(). Using an RwLock (read lock in skips()) would keep parallel list recording uncontended.
    3. Timestamp overlap attribution: Keeping the guard opt-in by default is the right call since non-barrier overlapping GPU commands can attribute a heavy neighbor's timestamp span to a lightweight pipeline.

Local Verification (VICTORY_D3D12_DEBUG=1)

  • RTX 5090: frame_budget::tests 15/15, draw::tests 21/21 (including a_banned_pipeline_is_dropped_from_lists_recorded_after_the_ban), pipeline:: 21/21, host::tests (non-descriptor) 12/12.
  • WARP (--features diagnostics): frame_budget::tests 15/15, draw::tests::a_banned_pipeline_is_dropped_from_lists_recorded_after_the_ban 1/1.
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --features diagnostics) & cargo test -p xtask --locked (6/6, policy ok): clean.
<!-- greyfinch-sync:Marvisak/VIctory:review:6066729223 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2911#pullrequestreview-6066729223). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T00:04:07Z. **Review:** COMMENTED --- Verified head `7abc8fc3` (stacked on `#2721`) cleanly merged onto `origin/main` (`63bcca43`) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + D3D12 WARP + `VICTORY_D3D12_DEBUG=1`). ### Code & Concurrency Review - **Zero-overhead default path**: With `VICTORY_SLOW_PIPELINES` off (and `VICTORY_FRAME_TIMING != 1`), `skips()` and `timing()` stay lock-free relaxed atomic checks without allocating query heaps/readback buffers or taking `GUARD`. Timestamp deltas safely use `saturating_sub` and `frequency.max(1)`. - **Observations / Suggestions (non-blocking)**: 1. **Stale log hint (`crates/victory-gpu/src/frame_budget.rs:584`, test `L1136`)**: The `!timed` message still reads `"GPU work (commands are not timed with VICTORY_SLOW_PIPELINES=0)"`. Now that timing is split out behind `VICTORY_FRAME_TIMING=1`, pointing users to `VICTORY_FRAME_TIMING=1` avoids nudging someone who only wants command timings to turn on the drop guard. 2. **Lock contention while any pipeline is banned (`frame_budget.rs:471, 492-501`)**: Once `ANY_BANNED` flips true (for 60s–16m), every recording thread takes the global `Mutex<Option<Guard>>` on every `State::bind` (even for unbanned pipelines), contending with `ran()` / `presented()`. Using an `RwLock` (read lock in `skips()`) would keep parallel list recording uncontended. 3. **Timestamp overlap attribution**: Keeping the guard opt-in by default is the right call since non-barrier overlapping GPU commands can attribute a heavy neighbor's timestamp span to a lightweight pipeline. ### Local Verification (`VICTORY_D3D12_DEBUG=1`) - **RTX 5090**: `frame_budget::tests` **15/15**, `draw::tests` **21/21** (including `a_banned_pipeline_is_dropped_from_lists_recorded_after_the_ban`), `pipeline::` **21/21**, `host::tests` (non-descriptor) **12/12**. - **WARP (`--features diagnostics`)**: `frame_budget::tests` **15/15**, `draw::tests::a_banned_pipeline_is_dropped_from_lists_recorded_after_the_ban` **1/1**. - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default and `--features diagnostics`) & `cargo test -p xtask --locked` (`6/6`, policy ok): clean.
0xkn0wh3r3 commented 2026-11-26 01:04:09 +00:00 (Migrated from github.com)

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


@fuzeofficlal thanks, both notes are addressed:

  1. Log hint: the message for commands that aren't timed now reads "commands are timed with VICTORY_FRAME_TIMING=1". It lives in the report, so the fix is in #2721 (16aa2a49), merged into this branch.
  2. Lock while a pipeline is banned: skips() now reads the banned names from an RwLock and never takes the guard's mutex (0f845952). The set is rewritten only when bans change. a_banned_pipeline_is_skipped now asserts that skips() takes no guard lock.

The guard stays opt-in (VICTORY_SLOW_PIPELINES=1). The frame budget tests and clippy, with and without diagnostics, pass.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7178928393 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2911#issuecomment-7178928393). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T00:36:17Z. --- @fuzeofficlal thanks, both notes are addressed: 1. **Log hint:** the message for commands that aren't timed now reads "commands are timed with VICTORY_FRAME_TIMING=1". It lives in the report, so the fix is in #2721 (16aa2a49), merged into this branch. 2. **Lock while a pipeline is banned:** `skips()` now reads the banned names from an `RwLock` and never takes the guard's mutex (0f845952). The set is rewritten only when bans change. `a_banned_pipeline_is_skipped` now asserts that `skips()` takes no guard lock. The guard stays opt-in (`VICTORY_SLOW_PIPELINES=1`). The frame budget tests and clippy, with and without `diagnostics`, pass.
Marvisak commented 2026-11-26 03:05:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T02:20:51Z.


Automated triage for the maintainers.

Needs work (unchanged). Thanks for stating the purpose: the guard keeps the device from being reset when one submission takes about 2 s, and gives up the banned pipeline's output to do it. The head has not changed, so this still carries all of #2721. Please rebase once #2721 is settled, so the diff is only frame_budget.rs and the skips check in draw.rs State::bind.

Whether to ship a switch that drops the title's work is still the maintainer's call. Note also that #2936 traced a loading-time device removal to missing title memory in the page table (memory::CAPACITY), not to a slow pipeline as such. Evidence that the guard's case still happens once that kind of cause is fixed would help the decision.

CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7180716038 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2911#issuecomment-7180716038). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T02:20:51Z. --- <!-- victory-triage v1 head=0f84595274d6af8115d79f0a167435c7161f920e verdict=needs-work at=2026-11-26T07:23:36Z --> Automated triage for the maintainers. **Needs work (unchanged).** Thanks for stating the purpose: the guard keeps the device from being reset when one submission takes about 2 s, and gives up the banned pipeline's output to do it. The head has not changed, so this still carries all of #2721. Please rebase once #2721 is settled, so the diff is only `frame_budget.rs` and the `skips` check in `draw.rs` `State::bind`. Whether to ship a switch that drops the title's work is still the maintainer's call. Note also that #2936 traced a loading-time device removal to missing title memory in the page table (`memory::CAPACITY`), not to a slow pipeline as such. Evidence that the guard's case still happens once that kind of cause is fixed would help the decision. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
0xkn0wh3r3 commented 2026-11-26 07:01:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T06:42:25Z.


Understood. I'll rebase this onto main once #2721 lands or closes, so the diff is only the guard. To answer what it's for: it's a way to keep the device alive, not a diagnostic or a frame-rate tool. A submission can't be stopped once it runs, and one that takes the host about 2 s resets the device, which ends the run. The guard trades the dropped pipeline's output (logged per ban and retry) for a run that keeps going. That's why it's off by default and needs VICTORY_SLOW_PIPELINES=1.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7184700462 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2911#issuecomment-7184700462). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T06:42:25Z. --- Understood. I'll rebase this onto main once #2721 lands or closes, so the diff is only the guard. To answer what it's for: it's a way to keep the device alive, not a diagnostic or a frame-rate tool. A submission can't be stopped once it runs, and one that takes the host about 2 s resets the device, which ends the run. The guard trades the dropped pipeline's output (logged per ban and retry) for a run that keeps going. That's why it's off by default and needs `VICTORY_SLOW_PIPELINES=1`.
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/2911:upstream-pr/2911'
git switch 'upstream-pr/2911'

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/2911'
git switch 'upstream-pr/2911'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2911'
git switch 'upstream-pr/2911'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2911'
git switch 'main'
git merge --squash 'upstream-pr/2911'
git switch 'main'
git merge --ff-only 'upstream-pr/2911'
git switch 'main'
git merge 'upstream-pr/2911'
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!2909
No description provided.