victory-gpu: eliminate 60 ms let_go_idle sweep stutter, lock-free watch/pending hot paths & recording contention fixes #3502

Closed
github-bot wants to merge 11 commits from github-bot/gh-3502 into main AGit
Owner

@⁠Rulemore on GitHub · 2026-11-30 00:08 UTC · original
Rulemore:pr/gpu-cpu-stutter → main · +1292 −336 · 17 files · 11 commits · closed without merging

Summary

This PR focuses on CPU hot-path, lock-contention, and periodic stutter reductions in victory-gpu (based cleanly on v2026.11.29.05 / 41adb551), preserving all existing upstream defaults and behavior.

Key Changes

  1. Eliminate resource::let_go_idle() 60 ms Sweep Stutter & Passive BufferSweep (resource.rs, shadow.rs, descriptor/host.rs, draw.rs, host.rs)
    • Avoids holding hot locks / redundant per-resource work during periodic sweeps, bringing resource::let_go_idle() from 22.89 ms avg / 59.9 ms max → 1.83 ms avg / 3.5 ms max (12.5× faster).
    • Adds shadow::find_passive so background BufferSweep passes do not advance Shadow::used / Shadow::frames on cold bindless slots.
    • Reduces contention in parallel refreshes (try_wide_each_scoped with NESTED_LONG fallback), dropping CPU refresh time from 15.5 ms → 10.6 ms.
  2. Lock-Free watch & shadow Hot Paths (watch.rs, shadow.rs, host.rs, host/card_steps.rs, descriptor.rs)
    • Adds an inline seqlock for watch::OWNED (with RwLock overflow fallback) and lock-free PageEpochs::try_parts_since fast path before falling back to journal().
    • Wires ahead_snap into Shadow::nothing_new_with and fixes read-only lock usage.
    • Adds atomic pending_bounds min/max fast-path on Shadow to skip locking pending for disjoint ranges, batches constant_slots_part, removes per-call allocations in card_steps::plan_with, and sifts ranges in place.
  3. Command Recording, Transitions & Relay Throughput (host.rs, list.rs, draw.rs, pipeline.rs, streamline.rs, descriptor/host.rs, memory.rs)
    • Caches HostList COM interfaces and returns HostPipeline directly from prepare.
    • Uses AddressHash for HostList states/twins, RwLock for SHADERS, deduplicates LIVE PSOs, and avoids redundant GetDesc calls in transitions.
    • Batches per-draw texture transitions, wires quiet_waits/barstat into narrow barriers, and skips redundant TextureQueue insert/remove churn on table reads (QueueBatch::LIMIT = 256).
    • Optimizes stale_pages to O(P + log W), caches in_buffer, offloads relay land() to late_helper, caches VICTORY_DLSS_RANGE, gates SEEN lock, and properly retires fg_rect buffers.

Measurements (RTX 4070 SUPER, release build)

  • resource::let_go_idle() sweep spikes: 22.89 ms avg / 59.9 ms max → 1.83 ms avg / 3.5 ms max (−92% stutter).
  • CPU refresh time per frame: 15.5 ms → 10.6–11.2 ms.

Verification

  • cargo test -p victory-gpu --lib -- --test-threads=1 (including new tests owned_seqlock_tracks_ranges_and_overflow_fallback, page_epochs_lockfree_parts_since_handles_single_multi_and_whole, pending_bounds_tracks_widening_and_narrowing, and find_passive_preserves_idle_timestamp_while_find_advances_it): 925 passed, 0 failed.
  • cargo xtask policy --staged: passed on all modified files.
**@⁠Rulemore** on GitHub · 2026-11-30 00:08 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3502) `Rulemore:pr/gpu-cpu-stutter` → `main` · +1292 −336 · 17 files · 11 commits · closed without merging ## Summary This PR focuses on CPU hot-path, lock-contention, and periodic stutter reductions in `victory-gpu` (based cleanly on `v2026.11.29.05` / `41adb551`), preserving all existing upstream defaults and behavior. ### Key Changes 1. **Eliminate `resource::let_go_idle()` 60 ms Sweep Stutter & Passive `BufferSweep` (`resource.rs`, `shadow.rs`, `descriptor/host.rs`, `draw.rs`, `host.rs`)** - Avoids holding hot locks / redundant per-resource work during periodic sweeps, bringing `resource::let_go_idle()` from **22.89 ms avg / 59.9 ms max → 1.83 ms avg / 3.5 ms max (12.5× faster)**. - Adds `shadow::find_passive` so background `BufferSweep` passes do not advance `Shadow::used` / `Shadow::frames` on cold bindless slots. - Reduces contention in parallel refreshes (`try_wide_each_scoped` with `NESTED_LONG` fallback), dropping CPU refresh time from **15.5 ms → 10.6 ms**. 2. **Lock-Free `watch` & `shadow` Hot Paths (`watch.rs`, `shadow.rs`, `host.rs`, `host/card_steps.rs`, `descriptor.rs`)** - Adds an inline seqlock for `watch::OWNED` (with `RwLock` overflow fallback) and lock-free `PageEpochs::try_parts_since` fast path before falling back to `journal()`. - Wires `ahead_snap` into `Shadow::nothing_new_with` and fixes read-only lock usage. - Adds atomic `pending_bounds` min/max fast-path on `Shadow` to skip locking `pending` for disjoint ranges, batches `constant_slots_part`, removes per-call allocations in `card_steps::plan_with`, and sifts ranges in place. 3. **Command Recording, Transitions & Relay Throughput (`host.rs`, `list.rs`, `draw.rs`, `pipeline.rs`, `streamline.rs`, `descriptor/host.rs`, `memory.rs`)** - Caches `HostList` COM interfaces and returns `HostPipeline` directly from `prepare`. - Uses `AddressHash` for `HostList` states/twins, `RwLock` for `SHADERS`, deduplicates `LIVE` PSOs, and avoids redundant `GetDesc` calls in transitions. - Batches per-draw texture transitions, wires `quiet_waits`/`barstat` into narrow barriers, and skips redundant `TextureQueue` insert/remove churn on table reads (`QueueBatch::LIMIT = 256`). - Optimizes `stale_pages` to `O(P + log W)`, caches `in_buffer`, offloads relay `land()` to `late_helper`, caches `VICTORY_DLSS_RANGE`, gates `SEEN` lock, and properly retires `fg_rect` buffers. ### Measurements (RTX 4070 SUPER, release build) - `resource::let_go_idle()` sweep spikes: **22.89 ms avg / 59.9 ms max → 1.83 ms avg / 3.5 ms max** (−92% stutter). - CPU refresh time per frame: **15.5 ms → 10.6–11.2 ms**. ### Verification - `cargo test -p victory-gpu --lib -- --test-threads=1` (including new tests `owned_seqlock_tracks_ranges_and_overflow_fallback`, `page_epochs_lockfree_parts_since_handles_single_multi_and_whole`, `pending_bounds_tracks_widening_and_narrowing`, and `find_passive_preserves_idle_timestamp_while_find_advances_it`): **925 passed, 0 failed**. - `cargo xtask policy --staged`: passed on all modified files.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 00:11:40 +00:00
Author
Owner

@⁠DoubleD17 on GitHub · 2026-11-30 01:01 UTC · original

We ran a test of this PR on an 8-core Zen 3. Here it was slower, and one frame showed vegetation missing.

Setup:

  • Ryzen 7 5800X (8 cores), RTX 5070 12 GB, 64 GB RAM, Windows 11;
  • Series X, 1440p, DLSS Performance, frame generation and ray tracing off;
  • this PR merged locally onto main 41adb551 (the merge only adds this PR's own commits), against 41adb551 itself;
  • a warm-up run per build, then 150 s runs alternating base / PR, two rounds;
  • every run starts from the same save, restored before each run;
  • figures are medians of the 5 s host lines.

We also ran a picture check: a burst of 10 captures a second at the end of each run, looked at frame by frame.

preparing refresh fps (mean) one-frame defects
base 41adb551 62.7 / 62.1 ms 21.2 / 20.9 ms 13.4 / 13.7 0 / 0 of 80
this PR 73.1 / 70.7 ms 23.4 / 22.9 ms 12.2 / 12.3 1 / 0 of 80
  • About +9.5 ms of preparing a frame (+15 %) and about -10 % fps on this machine, in both rounds. Refresh time went up too, not down.
  • One frame with vegetation missing: in one PR run the palm trees and a potted plant near the camera are gone for a single frame, and back in the next. We haven't seen that in any base run: 0 in 160 frames here, and 0 in about 1,400 frames of main runs today. One case is thin evidence. But this PR changes when idle resources are let go (let_go_idle, the passive BufferSweep), and a resource released while a frame still uses it would look like this.

If parts of this have switches, we can A/B them one at a time on this machine.

AI Assisted

**@⁠DoubleD17** on GitHub · 2026-11-30 01:01 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3502#issuecomment-7265777705) We ran a test of this PR on an 8-core Zen 3. Here it was slower, and one frame showed vegetation missing. **Setup:** - Ryzen 7 5800X (8 cores), RTX 5070 12 GB, 64 GB RAM, Windows 11; - Series X, 1440p, DLSS Performance, frame generation and ray tracing off; - this PR merged locally onto main 41adb551 (the merge only adds this PR's own commits), against 41adb551 itself; - a warm-up run per build, then 150 s runs alternating base / PR, two rounds; - every run starts from the same save, restored before each run; - figures are medians of the 5 s host lines. We also ran a picture check: a burst of 10 captures a second at the end of each run, looked at frame by frame. | | preparing | refresh | fps (mean) | one-frame defects | |---|---|---|---|---| | base 41adb551 | 62.7 / 62.1 ms | 21.2 / 20.9 ms | 13.4 / 13.7 | 0 / 0 of 80 | | this PR | **73.1 / 70.7 ms** | 23.4 / 22.9 ms | 12.2 / 12.3 | 1 / 0 of 80 | - **About +9.5 ms of preparing a frame (+15 %) and about -10 % fps** on this machine, in both rounds. Refresh time went up too, not down. - **One frame with vegetation missing:** in one PR run the palm trees and a potted plant near the camera are gone for a single frame, and back in the next. We haven't seen that in any base run: 0 in 160 frames here, and 0 in about 1,400 frames of main runs today. One case is thin evidence. But this PR changes when idle resources are let go (let_go_idle, the passive BufferSweep), and a resource released while a frame still uses it would look like this. If parts of this have switches, we can A/B them one at a time on this machine. AI Assisted
github-bot closed this pull request 2026-12-01 18:58:27 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!3502
No description provided.