Keep VRAM texture eviction active when host memory pressure sweep is active #1772

Manually merged
github merged 1 commit from github-bot/gh-1772 into main 2026-11-29 08:20:59 +00:00 AGit
Owner

@⁠Luca121 on GitHub · 2026-11-29 00:01 UTC · original
Luca121:pr/vram-evict-host-pressure → main · +53 −16 · 1 files · 1 commits · merged 2026-11-29 08:16 UTC

What it changes

Fixes a bug in let_go_idle() (crates/victory-gpu/src/resource.rs, introduced in 91cd117) where host memory pressure completely short-circuits VRAM texture eviction:

  • residency::host_texture_idle_ms() returns Some(1_000) or Some(5_000) whenever host RAM/commit headroom is below min(RAM/4, 16 GiB) — which is almost continuously true on 16 GB and 32 GB PCs running GTA VI.
  • Previously, match host_idle { Some(ms) => (ms, u64::MAX), None => ... } bypassed vram_keep_below(...) and vram_idle_ms(...) whenever host_idle.is_some(), forcing most = u64::MAX (never building by_age), scanning only PART = 8192 textures, and skipping every mapped texture (if !unmapped { continue; }) — even though the comment at line 2740 explicitly states that mapped textures should still follow the card's rule.
  • It also passed the clobbered host_idle (1_000 ms) into slot_evict(memory, idle_ms, IDLE_FRAMES) instead of the card's idle_ms.
  • Extracted idle_sweep_policy(host_idle, card_rule) -> (idle_ms, most, unmapped_only) so that:
    • When the card itself is pressured (card_most != u64::MAX || card_idle < 60_000), VRAM eviction stays active (unmapped_only = false) using card_rule.
    • When only host memory is pressured, the unmapped-only sweep runs using host_idle as intended.
    • slot_evict always receives card_rule.0 rather than host_idle.

How it was tested

  • GPU and profile: RTX 4070 Ti 12 GB, 32 GB RAM, Windows 11 — Series S (626 Balanced & 720 Quality) and Series X (1440 Performance), DLSS 2x Frame Generation.
  • Before: On a 32 GB RAM / 12 GB VRAM system, host_texture_idle_ms() stayed Some(...) throughout gameplay, disabling mapped VRAM texture eviction once VRAM crossed the room line and pushing usage to 10.6/10.7 GB VRAM + 9–10 GB shared spill.
  • After: VRAM texture eviction stays active under simultaneous host-RAM and VRAM pressure; VRAM remains bounded around 8.5–8.9 / 10.8 GB across extended open-world + driving sessions.
  • For shader changes, the wave sizes tested: N/A (no shader changes).
  • cargo test passed for the crates it touches: yes (cargo test --locked -p victory-gpu --lib -- --test-threads=4 — 551 passed, 0 failed, including new unit test idle_sweep_policy_keeps_vram_eviction_active_under_host_pressure).

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #1473, #1348, #1551, #1562 (none of them remove the match host_idle short-circuit in let_go_idle; in particular, #1562's eviction changes inside the None => arm are also silently bypassed without this fix).
**@⁠Luca121** on GitHub · 2026-11-29 00:01 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1772) `Luca121:pr/vram-evict-host-pressure` → `main` · +53 −16 · 1 files · 1 commits · merged 2026-11-29 08:16 UTC ## What it changes Fixes a bug in `let_go_idle()` (`crates/victory-gpu/src/resource.rs`, introduced in `91cd117`) where host memory pressure completely short-circuits VRAM texture eviction: - `residency::host_texture_idle_ms()` returns `Some(1_000)` or `Some(5_000)` whenever host RAM/commit headroom is below `min(RAM/4, 16 GiB)` — which is almost continuously true on 16 GB and 32 GB PCs running GTA VI. - Previously, `match host_idle { Some(ms) => (ms, u64::MAX), None => ... }` bypassed `vram_keep_below(...)` and `vram_idle_ms(...)` whenever `host_idle.is_some()`, forcing `most = u64::MAX` (never building `by_age`), scanning only `PART = 8192` textures, and skipping **every mapped texture** (`if !unmapped { continue; }`) — even though the comment at line 2740 explicitly states that mapped textures should still follow the card's rule. - It also passed the clobbered `host_idle` (`1_000 ms`) into `slot_evict(memory, idle_ms, IDLE_FRAMES)` instead of the card's `idle_ms`. - Extracted `idle_sweep_policy(host_idle, card_rule) -> (idle_ms, most, unmapped_only)` so that: - When the card itself is pressured (`card_most != u64::MAX || card_idle < 60_000`), VRAM eviction stays active (`unmapped_only = false`) using `card_rule`. - When only host memory is pressured, the unmapped-only sweep runs using `host_idle` as intended. - `slot_evict` always receives `card_rule.0` rather than `host_idle`. ## How it was tested - **GPU and profile:** RTX 4070 Ti 12 GB, 32 GB RAM, Windows 11 — Series S (`626` Balanced & `720` Quality) and Series X (`1440` Performance), DLSS 2x Frame Generation. - **Before:** On a 32 GB RAM / 12 GB VRAM system, `host_texture_idle_ms()` stayed `Some(...)` throughout gameplay, disabling mapped VRAM texture eviction once VRAM crossed the room line and pushing usage to `10.6/10.7 GB` VRAM + `9–10 GB` shared spill. - **After:** VRAM texture eviction stays active under simultaneous host-RAM and VRAM pressure; VRAM remains bounded around `8.5–8.9 / 10.8 GB` across extended open-world + driving sessions. - **For shader changes, the wave sizes tested:** N/A (no shader changes). - **`cargo test` passed for the crates it touches:** yes (`cargo test --locked -p victory-gpu --lib -- --test-threads=4` — 551 passed, 0 failed, including new unit test `idle_sweep_policy_keeps_vram_eviction_active_under_host_pressure`). ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #1473, #1348, #1551, #1562 (none of them remove the `match host_idle` short-circuit in `let_go_idle`; in particular, `#1562`'s eviction changes inside the `None =>` arm are also silently bypassed without this fix).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 00:04:31 +00:00
Author
Owner

@⁠KyleS98 on GitHub · 2026-11-29 03:07 UTC · original

Tested in game, and it does what it says. I had found the same fault from the other end and was about to send the same change when I found this one, which was here first. So here is the evidence instead.

Where I met it. A report in a fork of this tree (KyleS98/VIctory-Neo#7): RX 6900 XT 16 GB beside 32 GB of RAM, 3.8 GB of commit left when the world loaded. no room, new textures wait in 169 of the session's 243 five-second lines, from the ninth minute to the end, with 15,000 to 32,000 textures waiting; black walls in the player's clip, and trees that come and go.

How it was tried here. RTX 3090 Ti 24 GB (616.92), Ryzen 9 9950X3D, 64 GB, Windows 11 26200. A PC like that does not get into the state on its own, so it was made to: VICTORY_VRAM_BUDGET_MB=11000 for the card, and for the PC's memory a small test switch in residency::headroom() that caps what it reports (VICTORY_HOST_ROOM_MB=3700). Series S, DLSS off, no frame generation, builder off; a new game through the opening into the prologue's cell, hands off, 300 s, after one run to make the route's shaders. (VICTORY_CACHE_CORES=0 VICTORY_SUBMIT_CORE=0 too: the placement of #1093 stalls on this processor, which is another matter.)

Build the texture queue's room Frames a second in the cell
d4b5d517, this pull request's base, with the test switch no room in 41 of 58 lines, from the middle of the opening to the end 29 to 31
this pull request (3246d252) with the test switch room in 58 of 58 30 to 31

No error line and no device loss in either.

The same on today's main (568c5e5d), with the change done as two passes (the PC's pass, then the card's own; a flush stays the card's pass alone): no room in 34 of 57 lines before; after, room in 56 of 58 (the other two at the line itself), with 48,134 copies (5,110 MB) let go where 18,359 (2,629 MB) went before. That version is on KyleS98/VIctory-NVIDIA, branch pr/sweep-card-rule (bf4ce318), in case it saves a rebase: this pull request conflicts with main since the flush (F7 and F8) went into let_go_idle. It is not a competing pull request and I will not open one.

One difference between the two, for whoever merges. Here, while the card is pressured the unmapped-only pass does not run (the card's rule takes those copies too, once they are idle 1.5 or 5 s), and while it is not, the PC's rule runs alone, so the card's ten-minute rule is not asked meanwhile. With two passes both always run. I saw nothing between them in these runs.

Who else may have it: #1580 (an 8 GB card with 16 GB of RAM, "no room" for good) reads like this state. VICTORY_HOST_TEXTURE_SWEEP=0 on a current build turns the PC's rule off, and would tell.

AI-assisted (Claude Code, Claude Fable 5.2).

**@⁠KyleS98** on GitHub · 2026-11-29 03:07 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1772#issuecomment-7249859444) Tested in game, and it does what it says. I had found the same fault from the other end and was about to send the same change when I found this one, which was here first. So here is the evidence instead. **Where I met it.** A report in a fork of this tree (KyleS98/VIctory-Neo#7): RX 6900 XT 16 GB beside 32 GB of RAM, 3.8 GB of commit left when the world loaded. `no room, new textures wait` in 169 of the session's 243 five-second lines, from the ninth minute to the end, with 15,000 to 32,000 textures waiting; black walls in the player's clip, and trees that come and go. **How it was tried here.** RTX 3090 Ti 24 GB (616.92), Ryzen 9 9950X3D, 64 GB, Windows 11 26200. A PC like that does not get into the state on its own, so it was made to: `VICTORY_VRAM_BUDGET_MB=11000` for the card, and for the PC's memory a small test switch in `residency::headroom()` that caps what it reports (`VICTORY_HOST_ROOM_MB=3700`). Series S, DLSS off, no frame generation, builder off; a new game through the opening into the prologue's cell, hands off, 300 s, after one run to make the route's shaders. (`VICTORY_CACHE_CORES=0 VICTORY_SUBMIT_CORE=0` too: the placement of #1093 stalls on this processor, which is another matter.) | Build | `the texture queue's room` | Frames a second in the cell | |---|---|---| | `d4b5d517`, this pull request's base, with the test switch | **no room in 41 of 58 lines**, from the middle of the opening to the end | 29 to 31 | | this pull request (`3246d252`) with the test switch | **room in 58 of 58** | 30 to 31 | No error line and no device loss in either. **The same on today's `main`** (`568c5e5d`), with the change done as two passes (the PC's pass, then the card's own; a flush stays the card's pass alone): no room in 34 of 57 lines before; after, room in 56 of 58 (the other two at the line itself), with 48,134 copies (5,110 MB) let go where 18,359 (2,629 MB) went before. That version is on KyleS98/VIctory-NVIDIA, branch `pr/sweep-card-rule` (`bf4ce318`), in case it saves a rebase: this pull request conflicts with `main` since the flush (F7 and F8) went into `let_go_idle`. It is not a competing pull request and I will not open one. **One difference between the two,** for whoever merges. Here, while the card is pressured the unmapped-only pass does not run (the card's rule takes those copies too, once they are idle 1.5 or 5 s), and while it is not, the PC's rule runs alone, so the card's ten-minute rule is not asked meanwhile. With two passes both always run. I saw nothing between them in these runs. **Who else may have it:** #1580 (an 8 GB card with 16 GB of RAM, "no room" for good) reads like this state. `VICTORY_HOST_TEXTURE_SWEEP=0` on a current build turns the PC's rule off, and would tell. AI-assisted (Claude Code, Claude Fable 5.2).
Author
Owner

@⁠chaseb64 on GitHub · 2026-11-29 03:18 UTC · original

I tested #1772 on an RTX 4070 at the cell-window checkpoint using its parent d4b5d51 and its submitted head 3246d25. Both diagnostics builds included one log line per texture sweep. Each completed run used an isolated copy of the same save and cache, Series X at 1440p, DLSS Performance, the 80% texture-room setting, and a 120-second stationary interval. Both runs had 2× frame generation selected. Streamline reported it off for every present in both measured intervals. The host and VRAM pressure occurred with the system-reported memory budgets, without the test caps used in the earlier RTX 3090 Ti run.

Stationary measurement Parent PR head
Median process-private memory 30,023 MiB 27,641 MiB
Median local VRAM usage 11,380 MiB 9,152 MiB
Median DXGI local budget 10,886 MiB 10,698 MiB
Samples over local budget 23 of 23 0 of 23
Median memory for filled texture copies 5,585 MiB 2,809 MiB
Streamline over-budget warnings 2,399 0
Frames over 50 ms 1,005 of 2,384 (42.2%) 187 of 2,706 (6.9%)
Frames over 100 ms 46 14
Textures recreated between the first and last memory sample 38 (13 MiB) 94 (9 MiB)

All 93 baseline sweeps used the host-pressure policy. All 101 sweeps on the PR head selected GPU eviction while host pressure was active, releasing 418 texture copies during that interval. Both captures showed the character at the cell window. One startup attempt on each build hit the same null-write crash before the checkpoint and was excluded. The PR's focused policy test passed.

This is one completed run per build at a stationary checkpoint. It measures memory pressure and frame times in that scene. Longer-session growth and texture recreation during movement still need testing. Both builds also predate the upstream change that recognizes Streamline's over-budget return as a recorded upscale.

I used OpenAI Codex to build and instrument both revisions, run the comparison, and write this report.

**@⁠chaseb64** on GitHub · 2026-11-29 03:18 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1772#issuecomment-7249971528) I tested #1772 on an RTX 4070 at the cell-window checkpoint using its parent `d4b5d51` and its submitted head `3246d25`. Both diagnostics builds included one log line per texture sweep. Each completed run used an isolated copy of the same save and cache, Series X at 1440p, DLSS Performance, the 80% texture-room setting, and a 120-second stationary interval. Both runs had 2× frame generation selected. Streamline reported it off for every present in both measured intervals. The host and VRAM pressure occurred with the system-reported memory budgets, without the test caps used in the earlier RTX 3090 Ti run. | Stationary measurement | Parent | PR head | | --- | ---: | ---: | | Median process-private memory | 30,023 MiB | 27,641 MiB | | Median local VRAM usage | 11,380 MiB | 9,152 MiB | | Median DXGI local budget | 10,886 MiB | 10,698 MiB | | Samples over local budget | 23 of 23 | 0 of 23 | | Median memory for filled texture copies | 5,585 MiB | 2,809 MiB | | Streamline over-budget warnings | 2,399 | 0 | | Frames over 50 ms | 1,005 of 2,384 (42.2%) | 187 of 2,706 (6.9%) | | Frames over 100 ms | 46 | 14 | | Textures recreated between the first and last memory sample | 38 (13 MiB) | 94 (9 MiB) | All 93 baseline sweeps used the host-pressure policy. All 101 sweeps on the PR head selected GPU eviction while host pressure was active, releasing 418 texture copies during that interval. Both captures showed the character at the cell window. One startup attempt on each build hit the same null-write crash before the checkpoint and was excluded. The PR's focused policy test passed. This is one completed run per build at a stationary checkpoint. It measures memory pressure and frame times in that scene. Longer-session growth and texture recreation during movement still need testing. Both builds also predate the upstream change that recognizes Streamline's over-budget return as a recorded upscale. I used OpenAI Codex to build and instrument both revisions, run the comparison, and write this report.
Author
Owner

@⁠amazedturnip on GitHub · 2026-11-29 05:38 UTC · original

Tested on RTX 5070 Ti 16 GB / 32 GB RAM under real host-RAM pressure (pressured=true). Keeping VRAM eviction active alongside host pressure sweeps worked cleanly without hangs or stale texture views.

**@⁠amazedturnip** on GitHub · 2026-11-29 05:38 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1772#issuecomment-7251376553) Tested on RTX 5070 Ti 16 GB / 32 GB RAM under real host-RAM pressure (pressured=true). Keeping VRAM eviction active alongside host pressure sweeps worked cleanly without hangs or stale texture views.
Author
Owner

@⁠eleboucher on GitHub · 2026-11-29 06:07 UTC · original

PC result: RTX 4070 Ti SUPER 16 GB, Ryzen 7 9800X3D, 16 GB RAM (the PC-RAM sweep is on all the time here: "the PC has 400-700 MB free"), Windows 11, native 1440p, VICTORY_BVH_BUILDER=1 VICTORY_ACTIVATE_RAYS=1 VICTORY_CARD_CPU_HEAP=1 VICTORY_WINDOW_GROW=1, diagnostics build of main 568c5e5d plus this PR (merged over a few others; one conflict in let_go_idle with a flush branch, resolved by making the flush an arm of card_rule), 10-minute runs, medians after 200 s.

fps texture queue's room ... no room, new textures wait
without this PR 24.8 90 of 109 reports; the line sits at 14488 MB with 14761 MB in use
with this PR 21.8 (screen captures on in this run, which cost fps) 0 of 103; 13243 MB against the 14488 MB line at the end
with this PR + VICTORY_SLOT_EVICT=1 25.3 2 of 111
with this PR + VICTORY_SLOT_EVICT=1 VICTORY_SAMPLED_MARKS=1 VICTORY_SAMPLED_EVICT=1 7.6 (card waits ~65 ms a frame) 0 of 79

Without the PR the texture copy passes that "made none for lack of room" grew by about 4000 every 2 minutes; with it, 58 in the whole run. In screen captures of the same scenes, a high-frequency detail measure (Laplacian variance per 128x128 tile) is 1.7x the run without the PR, i.e. the textures that used to wait now arrive. No crash or device loss in these runs. The sampled-eviction combination is clearly worse on this machine.

**@⁠eleboucher** on GitHub · 2026-11-29 06:07 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1772#issuecomment-7251666650) PC result: RTX 4070 Ti SUPER 16 GB, Ryzen 7 9800X3D, 16 GB RAM (the PC-RAM sweep is on all the time here: "the PC has 400-700 MB free"), Windows 11, native 1440p, `VICTORY_BVH_BUILDER=1 VICTORY_ACTIVATE_RAYS=1 VICTORY_CARD_CPU_HEAP=1 VICTORY_WINDOW_GROW=1`, diagnostics build of main 568c5e5d plus this PR (merged over a few others; one conflict in `let_go_idle` with a flush branch, resolved by making the flush an arm of `card_rule`), 10-minute runs, medians after 200 s. | | fps | `texture queue's room ... no room, new textures wait` | |---|---|---| | without this PR | 24.8 | 90 of 109 reports; the line sits at 14488 MB with 14761 MB in use | | with this PR | 21.8 (screen captures on in this run, which cost fps) | 0 of 103; 13243 MB against the 14488 MB line at the end | | with this PR + `VICTORY_SLOT_EVICT=1` | 25.3 | 2 of 111 | | with this PR + `VICTORY_SLOT_EVICT=1 VICTORY_SAMPLED_MARKS=1 VICTORY_SAMPLED_EVICT=1` | 7.6 (card waits ~65 ms a frame) | 0 of 79 | Without the PR the texture copy passes that "made none for lack of room" grew by about 4000 every 2 minutes; with it, 58 in the whole run. In screen captures of the same scenes, a high-frequency detail measure (Laplacian variance per 128x128 tile) is 1.7x the run without the PR, i.e. the textures that used to wait now arrive. No crash or device loss in these runs. The sampled-eviction combination is clearly worse on this machine.
github manually merged commit dd8ac7f5e0 into main 2026-11-29 08:20:59 +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!1772
No description provided.