victory-gpu: restore VRAM eviction under host RAM pressure and recycle alias_rt overflow tiles #2591

Manually merged
github merged 1 commit from github-bot/gh-2591 into main 2026-11-30 14:14:23 +00:00 AGit
Owner

@⁠yanggx98 on GitHub · 2026-11-29 14:44 UTC · original
yanggx98:fix/vram-eviction-and-overflow-recycle → main · +139 −26 · 2 files · 1 commits · merged 2026-11-30 14:12 UTC

What it changes

Fixes three long-session VRAM/FPS degradation issues in crates/victory-gpu:

  1. Restore mapped VRAM texture eviction under host RAM pressure (crates/victory-gpu/src/resource.rs, let_go_idle):

    • idle_sweep_policy() already sets unmapped_only = false when GPU VRAM itself is pressured so mapped idle textures can still be reclaimed.
    • However, two inner checks inside let_go_idle() still tested if host_idle.is_some() instead of if unmapped_only. As soon as host RAM dipped below residency::host_texture_idle_ms()'s threshold, every mapped placed texture and every non-placed texture hit continue even when VRAM was full, causing VRAM overflow (WDDM PCIe paging to single-digit FPS) and repeated full-table sweeps on the submit thread.
    • Changed both inner checks to if unmapped_only.
  2. Clear r.host.used when sweep_unmapped_on() evicts a streamed-out texture (crates/victory-gpu/src/resource.rs):

    • sweep_unmapped_on() detached made.take() without clearing r.host.used.store(0, Relaxed) (unlike the main let_go_idle eviction path below it), causing already-evicted textures to be re-collected, re-sorted, and re-locked on every subsequent sweep.
  3. Recycle alias_rt::OverflowPool overflow tiles (crates/victory-gpu/src/alias_rt.rs, crates/victory-gpu/src/resource.rs):

    • take_overflow_tiles() previously bump-allocated 4 MiB Tier-2 heaps monotonically and never freed or reused tiles when aliased render targets were destroyed or when try_create() fell back.
    • Added OverflowSlots (with a free list) and an RAII OverflowLease stored on HostTexture after texture (so the ID3D12Resource is dropped first after GPU fence retirement, then its overflow tiles are returned to the free list for reuse).
    • Added unit test alias_rt::tests::overflow_slots_recycle_released_tiles_without_growing_chunks.

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): RTX 4070 SUPER, Series X 1440p, DLSS + frame generation
  • Before: After extended gameplay, once host RAM pressure triggered, VRAM eviction stopped reclaiming mapped textures and FPS degraded progressively down to single digits.
  • After: Mapped VRAM eviction remains active under VRAM pressure, sweep_unmapped_on() clears used, and alias_rt overflow tiles are recycled across transient RT lifetimes.
  • 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 alias_rt, cargo test -p victory-gpu --locked idle_sweep, cargo build --release --locked -p victory, cargo xtask policy --staged)

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #2549 (complementary: bounds let_go_idle scan count and adds slot_evict backoff; does not touch host_idle.is_some() vs unmapped_only, sweep_unmapped_on used reset, or alias_rt::OverflowPool)
**@⁠yanggx98** on GitHub · 2026-11-29 14:44 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2591) `yanggx98:fix/vram-eviction-and-overflow-recycle` → `main` · +139 −26 · 2 files · 1 commits · merged 2026-11-30 14:12 UTC ## What it changes Fixes three long-session VRAM/FPS degradation issues in `crates/victory-gpu`: 1. **Restore mapped VRAM texture eviction under host RAM pressure (`crates/victory-gpu/src/resource.rs`, `let_go_idle`)**: - `idle_sweep_policy()` already sets `unmapped_only = false` when GPU VRAM itself is pressured so mapped idle textures can still be reclaimed. - However, two inner checks inside `let_go_idle()` still tested `if host_idle.is_some()` instead of `if unmapped_only`. As soon as host RAM dipped below `residency::host_texture_idle_ms()`'s threshold, every mapped placed texture and every non-placed texture hit `continue` even when VRAM was full, causing VRAM overflow (WDDM PCIe paging to single-digit FPS) and repeated full-table sweeps on the submit thread. - Changed both inner checks to `if unmapped_only`. 2. **Clear `r.host.used` when `sweep_unmapped_on()` evicts a streamed-out texture (`crates/victory-gpu/src/resource.rs`)**: - `sweep_unmapped_on()` detached `made.take()` without clearing `r.host.used.store(0, Relaxed)` (unlike the main `let_go_idle` eviction path below it), causing already-evicted textures to be re-collected, re-sorted, and re-locked on every subsequent sweep. 3. **Recycle `alias_rt::OverflowPool` overflow tiles (`crates/victory-gpu/src/alias_rt.rs`, `crates/victory-gpu/src/resource.rs`)**: - `take_overflow_tiles()` previously bump-allocated 4 MiB Tier-2 heaps monotonically and never freed or reused tiles when aliased render targets were destroyed or when `try_create()` fell back. - Added `OverflowSlots` (with a free list) and an RAII `OverflowLease` stored on `HostTexture` after `texture` (so the `ID3D12Resource` is dropped first after GPU fence retirement, then its overflow tiles are returned to the free list for reuse). - Added unit test `alias_rt::tests::overflow_slots_recycle_released_tiles_without_growing_chunks`. ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): RTX 4070 SUPER, Series X 1440p, DLSS + frame generation - Before: After extended gameplay, once host RAM pressure triggered, VRAM eviction stopped reclaiming mapped textures and FPS degraded progressively down to single digits. - After: Mapped VRAM eviction remains active under VRAM pressure, `sweep_unmapped_on()` clears `used`, and `alias_rt` overflow tiles are recycled across transient RT lifetimes. - 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 alias_rt`, `cargo test -p victory-gpu --locked idle_sweep`, `cargo build --release --locked -p victory`, `cargo xtask policy --staged`) ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #2549 (complementary: bounds `let_go_idle` scan count and adds `slot_evict` backoff; does not touch `host_idle.is_some()` vs `unmapped_only`, `sweep_unmapped_on` `used` reset, or `alias_rt::OverflowPool`)
Fixes three long-session VRAM/FPS degradation issues:

1. resource::let_go_idle: check unmapped_only instead of host_idle.is_some()
   when deciding whether to restrict eviction to unmapped placed textures.
   idle_sweep_policy() already sets unmapped_only = false when GPU VRAM is
   pressured, but the inner checks still tested host_idle.is_some(), which
   disabled all mapped VRAM texture eviction whenever host RAM dipped below
   its threshold.
2. resource::let_go_idle (sweep_unmapped_on): clear r.host.used when evicting
   a streamed-out placed texture so subsequent sweeps do not re-collect,
   re-sort, and re-lock already-evicted entries.
3. alias_rt::OverflowPool: add a free list (OverflowSlots) and RAII
   OverflowLease attached to HostTexture (dropped after texture) so overflow
   tiles are returned and reused instead of monotonically allocating 4 MiB
   Tier-2 heaps.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 14:45:01 +00:00
Author
Owner

@⁠dyshay on GitHub · 2026-11-29 15:40 UTC · original

Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch janus-prs). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with --profile diag --features diagnostics, and the CPU tests of the touched crates pass. Runs on an RTX 4090 are queued (Series X 1440p, and Series S with ray tracing, DLSS Quality). Frame times will follow here.

**@⁠dyshay** on GitHub · 2026-11-29 15:40 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2591#issuecomment-7258272623) Merged into our fork's integration branch for testing ([dyshay/VIctory-NVIDIA](https://github.com/dyshay/VIctory-NVIDIA/tree/janus-prs), branch `janus-prs`). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with `--profile diag --features diagnostics`, and the CPU tests of the touched crates pass. Runs on an RTX 4090 are queued (Series X 1440p, and Series S with ray tracing, DLSS Quality). Frame times will follow here.
Author
Owner

@⁠LenoreSlate on GitHub · 2026-11-29 21:39 UTC · original

A/B on a 12 GB Ampere card: VRAM stays under budget for the whole session

Setup

  • GPU: GeForce RTX 3060 12 GB (Ampere), driver 621.40; DXGI budget reported ≈ 11.0–11.1 GB
  • CPU / RAM / OS: i5-13400F (6 P + 4 E cores), 32 GB, Windows 11 (native, not Proton)
  • Profile: Series X, DLSS Performance 1080p → 1440p, frame generation ×3 (DLSS FG through the MFG Unlocker, since Ampere has no native FG)
  • Builds: cargo build --release --locked -p victory, each in its own worktree and target dir
    • before: our fork's main
    • after: the same main + this PR only (d17fd452, merged with no conflict; the diff against main is only alias_rt.rs and resource.rs)
  • Run: same save, same route (first mission, flying the plane back to the marina), same apps open. The switch lines of the two logs are identical apart from the exe path.

On this machine host RAM and VRAM are both pressured at the same time (≈ 27.5 GB committed of 32 GB, ≈ 6.7 GB of shared GPU memory), so this is the case where host_idle.is_some() was blocking mapped eviction while the card itself was full.

Results (first 27 min of each run, the length of the shorter one)

before after
card VRAM in use, median 10 061 MB 9 153 MB (−908 MB)
card VRAM in use, p90 / max 11 717 / 11 789 MB 10 023 / 10 050 MB
time over the DXGI budget 36 % 0 %
time at ≥ 88 % of the budget 57 % 20 %
Streamline Exceeded VRAM budget warnings 4 943 0
shared GPU memory, mean 6 741 MB 6 619 MB
host memory committed, mean 27 771 MB 26 461 MB
FPS median / p10 (host: N fps lines) 9.9 / 7.1 9.8 / 6.4

The run with the PR went on to 35 min and never went over the budget (max 10 050 MB, 0 Streamline budget warnings over the whole run).

VRAM in use over time (mean per 5-minute slice):

minutes before after
0–5 5 995 MB 5 311 MB
5–10 9 004 MB 8 921 MB
10–15 9 952 MB 9 058 MB
15–20 11 131 MB (54 % of the time over budget) 9 224 MB
20–25 11 635 MB (100 % over) 9 678 MB
25–30 11 728 MB (100 % over) 9 911 MB
30–35 n/a 10 019 MB

Without the PR, VRAM climbs steadily and sits above the budget from about minute 17 onwards. With it, VRAM levels off around 10 GB. This matches the long-session description in the PR.

What I could not confirm

  • No FPS gain on this card. The median is unchanged and the p10 is slightly lower (7.1 → 6.4). That could be textures being refilled after eviction, or simply run-to-run noise: one run each, so not conclusive. FPS here is bound by other things (≈ 225 draws dropped per frame on this machine in earlier runs).
  • Overflow-tile recycling (alias_rt). The physical-page transient RT aliasing active line is only logged in the first minutes (before: physical_mb=376 overflow_tiles=339 at ≈ 4 min, then no more lines), so the logs can't show whether the overflow pool stops growing over a long session. The VRAM numbers above are most likely dominated by the unmapped_only fix.

Crashes (one sample each, not attributable to the PR)

  • before: ended after 27 min with a host command list did not close (Paramètre incorrect. (0x80070057)). An earlier 3-minute attempt with the same build ended the same way. This is the known crash (#3098, #2639, #452).
  • after: ended after 35 min with DXGI_ERROR_DEVICE_HUNG (0x887A0005) (Streamline: We've lost the Device). Our side reports the submitting thread preparing a submission of 13 lists, nothing of ours running on the card, pipeline library idle. VRAM was ≈ 10 GB, under budget. I have not seen this hang before on this machine, but with a single run I can't tie it to this change. I'll report back if it shows up again with the PR.

Code review

I read the full diff. It has no network, process, dependency or build-script changes. Notes:

  • unmapped_only instead of host_idle.is_some(): with VRAM pressured, mapped placed textures now go through the normal made.take() path with a blocking lock(). That is the same as the pre-existing no-host-pressure path, so I see no new contention.
  • OverflowLease lifetime: every path that lets a HostTexture go passes it whole to host::retire(), so the lease (and the tiles' return to the free list) waits for the running submissions. release_overflow_tiles takes STATE, and no early return None in try_create holds STATE at that point, so there is no self-deadlock. The failure path in take_overflow_tiles gives the tiles back before ST_OVERFLOW is counted, so the stats stay balanced.
  • Minor: overflow heaps are reused but never freed, so the pool stops growing but does not shrink. That is consistent with the description.

Tests

  • cargo test --locked -p victory-gpu --lib on our main + this PR: 915 passed, 1 failed (host::uav_pool::tests::host_list_uav_pool_lifecycle_retire_trim_and_info_queue). Rerun alone with --test-threads=1, it passed 3 times out of 3. It shares the global UAV pool stats with other tests, and this PR doesn't touch uav_pool.rs.
  • Release build clean.

Verdict from this machine: 👍 for the VRAM part. It does what it says, and VRAM stays under budget for a 35-minute session on a 12 GB card. I measured no FPS improvement here.

**@⁠LenoreSlate** on GitHub · 2026-11-29 21:39 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2591#issuecomment-7263044235) ## A/B on a 12 GB Ampere card: VRAM stays under budget for the whole session ### Setup - **GPU:** GeForce RTX 3060 12 GB (Ampere), driver 621.40; DXGI budget reported ≈ 11.0–11.1 GB - **CPU / RAM / OS:** i5-13400F (6 P + 4 E cores), 32 GB, Windows 11 (native, not Proton) - **Profile:** Series X, DLSS Performance 1080p → 1440p, frame generation ×3 (DLSS FG through the MFG Unlocker, since Ampere has no native FG) - **Builds:** `cargo build --release --locked -p victory`, each in its own worktree and target dir - **before:** our fork's `main` - **after:** the same `main` + this PR only (`d17fd452`, merged with no conflict; the diff against `main` is only `alias_rt.rs` and `resource.rs`) - **Run:** same save, same route (first mission, flying the plane back to the marina), same apps open. The switch lines of the two logs are identical apart from the exe path. On this machine host RAM and VRAM are both pressured at the same time (≈ 27.5 GB committed of 32 GB, ≈ 6.7 GB of shared GPU memory), so this is the case where `host_idle.is_some()` was blocking mapped eviction while the card itself was full. ### Results (first 27 min of each run, the length of the shorter one) | | before | after | |---|---|---| | card VRAM in use, median | 10 061 MB | **9 153 MB** (−908 MB) | | card VRAM in use, p90 / max | 11 717 / 11 789 MB | **10 023 / 10 050 MB** | | time over the DXGI budget | 36 % | **0 %** | | time at ≥ 88 % of the budget | 57 % | 20 % | | Streamline `Exceeded VRAM budget` warnings | 4 943 | **0** | | shared GPU memory, mean | 6 741 MB | 6 619 MB | | host memory committed, mean | 27 771 MB | 26 461 MB | | FPS median / p10 (`host: N fps` lines) | 9.9 / 7.1 | 9.8 / 6.4 | The run with the PR went on to 35 min and never went over the budget (max 10 050 MB, 0 Streamline budget warnings over the whole run). **VRAM in use over time** (mean per 5-minute slice): | minutes | before | after | |---|---|---| | 0–5 | 5 995 MB | 5 311 MB | | 5–10 | 9 004 MB | 8 921 MB | | 10–15 | 9 952 MB | 9 058 MB | | 15–20 | 11 131 MB (54 % of the time over budget) | 9 224 MB | | 20–25 | 11 635 MB (100 % over) | 9 678 MB | | 25–30 | 11 728 MB (100 % over) | 9 911 MB | | 30–35 | n/a | 10 019 MB | Without the PR, VRAM climbs steadily and sits above the budget from about minute 17 onwards. With it, VRAM levels off around 10 GB. This matches the long-session description in the PR. ### What I could not confirm - **No FPS gain on this card.** The median is unchanged and the p10 is slightly lower (7.1 → 6.4). That could be textures being refilled after eviction, or simply run-to-run noise: one run each, so not conclusive. FPS here is bound by other things (≈ 225 draws dropped per frame on this machine in earlier runs). - **Overflow-tile recycling (`alias_rt`).** The `physical-page transient RT aliasing active` line is only logged in the first minutes (before: `physical_mb=376 overflow_tiles=339` at ≈ 4 min, then no more lines), so the logs can't show whether the overflow pool stops growing over a long session. The VRAM numbers above are most likely dominated by the `unmapped_only` fix. ### Crashes (one sample each, not attributable to the PR) - **before:** ended after 27 min with `a host command list did not close (Paramètre incorrect. (0x80070057))`. An earlier 3-minute attempt with the same build ended the same way. This is the known crash (#3098, #2639, #452). - **after:** ended after 35 min with `DXGI_ERROR_DEVICE_HUNG (0x887A0005)` (Streamline: `We've lost the Device`). Our side reports the submitting thread *preparing* a submission of 13 lists, nothing of ours running on the card, pipeline library idle. VRAM was ≈ 10 GB, under budget. I have not seen this hang before on this machine, but with a single run I can't tie it to this change. I'll report back if it shows up again with the PR. ### Code review I read the full diff. It has no network, process, dependency or build-script changes. Notes: - `unmapped_only` instead of `host_idle.is_some()`: with VRAM pressured, mapped placed textures now go through the normal `made.take()` path with a blocking `lock()`. That is the same as the pre-existing no-host-pressure path, so I see no new contention. - `OverflowLease` lifetime: every path that lets a `HostTexture` go passes it whole to `host::retire()`, so the lease (and the tiles' return to the free list) waits for the running submissions. `release_overflow_tiles` takes `STATE`, and no early `return None` in `try_create` holds `STATE` at that point, so there is no self-deadlock. The failure path in `take_overflow_tiles` gives the tiles back before `ST_OVERFLOW` is counted, so the stats stay balanced. - Minor: overflow heaps are reused but never freed, so the pool stops growing but does not shrink. That is consistent with the description. ### Tests - `cargo test --locked -p victory-gpu --lib` on our `main` + this PR: 915 passed, 1 failed (`host::uav_pool::tests::host_list_uav_pool_lifecycle_retire_trim_and_info_queue`). Rerun alone with `--test-threads=1`, it passed 3 times out of 3. It shares the global UAV pool stats with other tests, and this PR doesn't touch `uav_pool.rs`. - Release build clean. **Verdict from this machine:** 👍 for the VRAM part. It does what it says, and VRAM stays under budget for a 35-minute session on a 12 GB card. I measured no FPS improvement here.
Author
Owner

@⁠Freeman022026 on GitHub · 2026-11-30 13:53 UTC · original

Tested in a 57-minute soak on a 64 GB RAM system (Ryzen 7 7800X3D, RTX 4090 24 GB, driver 621.14, Windows 11, Series X profile, 2560x1440, DLSS Performance, 2x Frame Generation, RT off), alongside #2486 and VICTORY_WAIT_RESIDENT=textures, VICTORY_RESIDENCY_HIGH=1, VICTORY_SAMPLED_EVICT=1, VICTORY_SWEEP_AHEAD=1.

Without this PR (61-minute baseline on the same machine), once free system RAM fell below 16 GiB, let_go_idle stopped evicting mapped textures. Peak VRAM climbed to 21,412 MB against a 20,723 MB budget, looks for textures to let go averaged 73.72 ms across 3,124 sweeps (longest 151.6 ms), median frame_times longest was 177.8 ms (179.1 ms in active gameplay seconds), and Streamline logged 2,517 frame generation resets over 100 ms.

With this PR applied over 57 minutes (0 crashes), peak VRAM stayed at 17,336 MB against a 20,713 MB budget, looks for textures to let go averaged 2.93 ms across 3,100 sweeps (longest 19.0 ms), median frame_times longest dropped to 51.9 ms (52.5 ms in active gameplay), and Streamline frame generation resets over 100 ms dropped from 2,517 to 169.

**@⁠Freeman022026** on GitHub · 2026-11-30 13:53 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2591#issuecomment-7280527351) Tested in a 57-minute soak on a 64 GB RAM system (Ryzen 7 7800X3D, RTX 4090 24 GB, driver 621.14, Windows 11, Series X profile, 2560x1440, DLSS Performance, 2x Frame Generation, RT off), alongside #2486 and `VICTORY_WAIT_RESIDENT=textures`, `VICTORY_RESIDENCY_HIGH=1`, `VICTORY_SAMPLED_EVICT=1`, `VICTORY_SWEEP_AHEAD=1`. Without this PR (61-minute baseline on the same machine), once free system RAM fell below 16 GiB, `let_go_idle` stopped evicting mapped textures. Peak VRAM climbed to 21,412 MB against a 20,723 MB budget, `looks for textures to let go` averaged 73.72 ms across 3,124 sweeps (longest 151.6 ms), median `frame_times` `longest` was 177.8 ms (179.1 ms in active gameplay seconds), and Streamline logged 2,517 frame generation resets over 100 ms. With this PR applied over 57 minutes (0 crashes), peak VRAM stayed at 17,336 MB against a 20,713 MB budget, `looks for textures to let go` averaged 2.93 ms across 3,100 sweeps (longest 19.0 ms), median `frame_times` `longest` dropped to 51.9 ms (52.5 ms in active gameplay), and Streamline frame generation resets over 100 ms dropped from 2,517 to 169.
github manually merged commit 1f1ef68c05 into main 2026-11-30 14:14:23 +00:00
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!2591
No description provided.