Skip to content

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

Open
Luca121 wants to merge 1 commit into
trustno1-coder:mainfrom
Luca121:pr/vram-evict-host-pressure
Open

Luca121 wants to merge 1 commit into
trustno1-coder:mainfrom
Luca121:pr/vram-evict-host-pressure

Conversation

@Luca121

@Luca121 Luca121 commented Nov 29, 2026

Copy link
Copy Markdown

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

@github-actions github-actions Bot added memory RAM or VRAM use, out of memory, leaks pr-fix Pull request: fixes a bug labels Nov 29, 2026
@github-actions github-actions Bot changed the title [pr-fix][memory] Keep VRAM texture eviction active when host memory pressure sweep is active Keep VRAM texture eviction active when host memory pressure sweep is active Nov 29, 2026
Alxspb added a commit to Alxspb/VIctory-NVIDIA that referenced this pull request Nov 29, 2026
Upstream trustno1-coder#1763 and trustno1-coder#1772 on top of the 0.16 room hold-back, both aimed at
the same run 18772 collapse (RTX 3070 Ti: budget 7,144 MB, pool 8,199 MB,
`slEvaluateFeature: out of VRAM (39)` 2,299 times, 8-14 fps):

- trustno1-coder#1772 `idle_sweep_policy` (resource.rs:2805): the card's own idle rule
  stays in charge while the card is pressured. Before, host commit pressure
  switched the sweep to unmapped-placed-only (`host_idle.is_some()` at the
  two `continue`s), so mapped idle textures - the 146-181 MB/frame churn of
  that run - were never reclaimed however far over budget we were.
- trustno1-coder#1763 (resource.rs:3013, sampled.rs): slots the screen samples are marked
  per sweep and evicted last; over budget (`used >= budget`) the idle
  threshold drops to 3 s and the protect window shortens, and `room_line`
  minus the face headroom picks the eviction line. Its two switches are in
  the launcher's built-in settings (`apps/victory/src/play.rs:121-122`).

Both merged clean against main and clippy is quiet on
x86_64-pc-windows-msvc, bare and with `--features diagnostics`.
@KyleS98

KyleS98 commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

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).

@chaseb64

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

memory RAM or VRAM use, out of memory, leaks pr-fix Pull request: fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants