victory-gpu: bound let_go_idle sweep and back off empty slot_evict pa… #2549

Merged
KleiinMoretti merged 1 commit from upstream-pr/2549 into main 2026-11-30 14:12:02 +00:00
KleiinMoretti commented 2026-11-29 14:06:29 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by KleiinMoretti on 2026-11-29T14:06:29Z.


What it changes

On titles with 100k+ live textures (such as GTA 6 on 8 GB GPUs), two texture sweep paths were causing severe CPU frame-time spikes:

  1. let_go_idle() full-table scans (crates/victory-gpu/src/resource.rs): When most != u64::MAX or idle_ms < 60_000 && !unmapped_only, let_go_idle() walked every entry in the live texture table on every submission. Unforced passes are now bounded to PART = 8192 textures and MAX_SWEEP_US = 4_000 (4 ms) using a rolling FROM cursor, while flush != 0 and VICTORY_TEXTURE_SWEEP=whole retain full scans.
  2. slot_evict() empty-pass thrashing (crates/victory-gpu/src/resource.rs): When bindless descriptors prevented evicting any slots (evicted == 0), slot_evict() still re-scanned the descriptor heap every second for zero gain. Added slot_evict_backoff_ms() + NEXT_SLOT_MS to back off 15_000 ms after an empty pass (2_000 ms when over budget with evictions, 5_000 ms otherwise; bypassed on forced flushes), plus unit test resource::tests::slot_evict_backoff_slows_empty_passes.

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): NVIDIA GeForce RTX 5060 Laptop GPU (8 GB VRAM), Series S (console=series-s), DLSS Quality (preset K), FG 2x
  • Before: looks for textures to let go averaged 94.16 ms (263.7 ms max); the heaps' records and what is swept was 47.6 ms/frame while slot_evict scanned 141,073 textures and evicted 0
  • After: looks for textures to let go averaged 3.60 ms (7.3 ms max); the heaps' records and what is swept dropped to 0.1–0.5 ms/frame
  • For shader changes, the wave sizes tested (32 and/or 64 lanes): N/A (no shader changes)
  • cargo test passed for the crates it touches: yes (cargo test -p victory-gpu --locked --lib -- resource::tests: 45 passed, 0 failed, 1 ignored; slot_evict_backoff_slows_empty_passes passed)

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5551488072 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2549). Originally posted by [KleiinMoretti](https://github.com/KleiinMoretti) on 2026-11-29T14:06:29Z. --- ## What it changes On titles with 100k+ live textures (such as GTA 6 on 8 GB GPUs), two texture sweep paths were causing severe CPU frame-time spikes: 1. **`let_go_idle()` full-table scans** (`crates/victory-gpu/src/resource.rs`): When `most != u64::MAX` or `idle_ms < 60_000 && !unmapped_only`, `let_go_idle()` walked every entry in the live texture table on every submission. Unforced passes are now bounded to `PART = 8192` textures and `MAX_SWEEP_US = 4_000` (4 ms) using a rolling `FROM` cursor, while `flush != 0` and `VICTORY_TEXTURE_SWEEP=whole` retain full scans. 2. **`slot_evict()` empty-pass thrashing** (`crates/victory-gpu/src/resource.rs`): When bindless descriptors prevented evicting any slots (`evicted == 0`), `slot_evict()` still re-scanned the descriptor heap every second for zero gain. Added `slot_evict_backoff_ms()` + `NEXT_SLOT_MS` to back off `15_000` ms after an empty pass (`2_000` ms when over budget with evictions, `5_000` ms otherwise; bypassed on forced flushes), plus unit test `resource::tests::slot_evict_backoff_slows_empty_passes`. ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): NVIDIA GeForce RTX 5060 Laptop GPU (8 GB VRAM), Series S (`console=series-s`), DLSS Quality (preset K), FG 2x - Before: `looks for textures to let go` averaged `94.16 ms` (`263.7 ms` max); `the heaps' records and what is swept` was `47.6 ms/frame` while `slot_evict` scanned 141,073 textures and evicted `0` - After: `looks for textures to let go` averaged `3.60 ms` (`7.3 ms` max); `the heaps' records and what is swept` dropped to `0.1–0.5 ms/frame` - For shader changes, the wave sizes tested (32 and/or 64 lanes): N/A (no shader changes) - `cargo test` passed for the crates it touches: yes (`cargo test -p victory-gpu --locked --lib -- resource::tests`: 45 passed, 0 failed, 1 ignored; `slot_evict_backoff_slows_empty_passes` passed) ## Checked for overlap - [ ] I searched the open pull requests for the same issue and for the files this touches.
icdmkg2 commented 2026-11-29 18:19:58 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by icdmkg2 on 2026-11-29T18:19:58Z.


An in-game data point from an 8 GB laptop. It covers this PR together with four others, so it can't attribute the gain to this one alone.

Setup: RTX 5060 Laptop GPU (8 GB), Ryzen 7 H 260 (8 cores), 32 GB, Windows 11, driver 621.24. main at 55d06914, release build, Series S, DLSS performance, VICTORY_LEVELS_ON_DEMAND=0 and VICTORY_COMMIT_FLOOR_MB=1024 in both builds (see #1411 for why). Same save (the prologue's cell), driven by a script: 60 s measured after a 30 s settle, warm shader cache, two alternating pairs.

Combo: main + #2549 + #2783 + #2647 + #2665 + #2795. These merge cleanly together. #2796, #2656, #2604 and #2587 conflict with that set, so they weren't tested.

median frame time frames >50 ms per 5 s submitting thread, ms per frame
main 60.7 / 56.7 ms 15.2 / 15.4 52 / 60
combo 49.3 / 48.6 ms 7.6 / 5.8 47 / 44

That's about 15–18 % shorter frames and half the slow frames, with no crash and no device removal. A frame capture of the combo (diagnostics build, VICTORY_CAPTURE_WORLD) matched main's brightness (mean luma 66.4 against 66.2), with no black holes.

One thing for the diagnostics build: with these merged together, --features diagnostics no longer compiles. A local timing in submit shadows host::timing() at three call sites, and copystat::log_heap_elsewhere uses an mb helper it doesn't define. Both are one-line fixes; mentioning it in case whichever lands second hits it.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7260397822 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2549#issuecomment-7260397822). Originally posted by [icdmkg2](https://github.com/icdmkg2) on 2026-11-29T18:19:58Z. --- An in-game data point from an 8 GB laptop. It covers this PR **together with four others**, so it can't attribute the gain to this one alone. **Setup:** RTX 5060 Laptop GPU (8 GB), Ryzen 7 H 260 (8 cores), 32 GB, Windows 11, driver 621.24. `main` at `55d06914`, release build, Series S, DLSS performance, `VICTORY_LEVELS_ON_DEMAND=0` and `VICTORY_COMMIT_FLOOR_MB=1024` in both builds (see #1411 for why). Same save (the prologue's cell), driven by a script: 60 s measured after a 30 s settle, warm shader cache, two alternating pairs. **Combo:** `main` + #2549 + #2783 + #2647 + #2665 + #2795. These merge cleanly together. #2796, #2656, #2604 and #2587 conflict with that set, so they weren't tested. | | median frame time | frames >50 ms per 5 s | submitting thread, ms per frame | |---|---|---|---| | `main` | 60.7 / 56.7 ms | 15.2 / 15.4 | 52 / 60 | | **combo** | **49.3 / 48.6 ms** | **7.6 / 5.8** | **47 / 44** | That's about 15–18 % shorter frames and half the slow frames, with no crash and no device removal. A frame capture of the combo (diagnostics build, `VICTORY_CAPTURE_WORLD`) matched `main`'s brightness (mean luma 66.4 against 66.2), with no black holes. One thing for the diagnostics build: with these merged together, `--features diagnostics` no longer compiles. A local `timing` in `submit` shadows `host::timing()` at three call sites, and `copystat::log_heap_elsewhere` uses an `mb` helper it doesn't define. Both are one-line fixes; mentioning it in case whichever lands second hits it.
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
trustno1-coder/VIctory-NVIDIA!2549
No description provided.