Texture sweep: the card's rule frees idle textures under RAM pressure too, backs off instead of churning, and keeps textures shown through slots #3475

Closed
github-bot wants to merge 3 commits from github-bot/gh-3475 into main AGit
Owner

@⁠nyxctura on GitHub · 2026-11-29 23:44 UTC · original
nyxctura:pr-texture → main · +1268 −13 · 4 files · 3 commits · closed without merging

Related: #1772, #3206.

What it changes

With the card over its texture budget and the PC short of RAM at the same time (normal on a 12 GB card with 32 GB of RAM), the sweep found ~7.5 GB of textures idle for 30 s and more and freed ~90 MB every 5 s. The texture queue said "no room, new textures wait" in 95 % of its reports: late and blurry textures, frame generation failing with "out of VRAM", and Windows paging.

Three commits:

  1. The card's rule is capped and backs off (resource.rs, host.rs, VICTORY_SWEEP_CAPPED). It frees no more than idle textures can give, pauses when too many of the textures it freed come back within 10 s (VICTORY_SWEEP_CAPPED_BACK_PERCENT), and slows down only when nothing is left to free. This ends the free-and-reload loop (#1772).
  2. The card's rule takes mapped idle copies under the PC's pressure too (VICTORY_SWEEP_CARD_MAPPED). A second "wholly unmapped" gate in the free loop, left over after 3246d252 changed the first one, skipped nearly every candidate whenever RAM was short. Also: copies the streamed-out pass freed no longer count as idle (VICTORY_SWEEP_STALE), and a 5-s "why kept" line says what holds the rest (VICTORY_SWEEP_WHY).
  3. Textures shown through slots are kept (resource.rs, descriptor/host.rs, VICTORY_SWEEP_HELD_GRACE_S). A texture picked by index never asks for its host copy again, so its used stamp goes stale while it is on screen. When the title moves its view to another slot, the old slot lets go before the new one is made, and a look in between freed it: the texture flickered (a character's arm, every few seconds). Copies held by a slot or list within the grace time stay, ones that came back are protected longer (VICTORY_SWEEP_BACK_PROTECT_S), and the back-off also counts bytes. VICTORY_SWEEP_BACK_WHO logs which code asked for a copy again.

Every change has its switch; =0 restores the old behaviour.

Screenshots

fps in the world, before vs with this PR:
image 6

With this PR: card under its budget, RAM free, frame generation running:
image 5

How it was tested

  • PC: RTX 5070 12 GB, Ryzen 7 7800X3D, 32 GB RAM, Windows 11 25H2.
  • Profile: Series S, 1080p → 1440p, DLSS Ultra Performance, frame generation 2x, 60 fps cap, ray tracing off.
  • Before (16.7 min in the world): "no room" in 95 % of reports, textures 1,148 MB over their line on average, 1.5 GB RAM free on average in the world (0.7 minimum), frame generation refused 13 times with "out of VRAM", 77 % of seconds with a frame over 150 ms.
  • After (7.1 min): textures 461 MB under their line, card 8.8 of 10.6 GB, 3.5 GB RAM free on average in the world (3.1 minimum), frame generation never refused, 19 % of seconds with a frame over 150 ms.
  • Flicker (commit 3): freed textures back within 10 s went from 5,675 of 101,348 (5.6 %) to 30 of 16,933 (0.2 %). With a 10 s grace it was 2.3 %; in all 64 logged cases a holder had been seen 10.1–27 s before the free, which is why the grace is set by VICTORY_SWEEP_HELD_GRACE_S (60 s used here).
  • The "after" build also had PR 3 (texture queue lock, retired objects) applied; the numbers above are ones that PR does not affect. fps went from 18.3 to 22.1 mean, but that is not this PR's alone.
  • Played on the v2026.11.29.01 base. On current main the branch builds and the victory-gpu lib suite passes (apart from every_switch_of_the_translator_is_in_the_key, which fails the same way on main without this PR).
  • cargo test passed for the crates it touches: yes. New unit tests for the back-off, capping and grace rules.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #1772.

More charts

Free RAM while playing:
free RAM

Textures in use minus their line (above 0, new textures wait):
textures vs line

All three PRs at a glance:
scorecard

🤖 Generated with Claude Code

**@⁠nyxctura** on GitHub · 2026-11-29 23:44 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3475) `nyxctura:pr-texture` → `main` · +1268 −13 · 4 files · 3 commits · closed without merging Related: #1772, #3206. ## What it changes With the card over its texture budget and the PC short of RAM at the same time (normal on a 12 GB card with 32 GB of RAM), the sweep found ~7.5 GB of textures idle for 30 s and more and freed ~90 MB every 5 s. The texture queue said "no room, new textures wait" in 95 % of its reports: late and blurry textures, frame generation failing with "out of VRAM", and Windows paging. Three commits: 1. **The card's rule is capped and backs off** (`resource.rs`, `host.rs`, `VICTORY_SWEEP_CAPPED`). It frees no more than idle textures can give, pauses when too many of the textures it freed come back within 10 s (`VICTORY_SWEEP_CAPPED_BACK_PERCENT`), and slows down only when nothing is left to free. This ends the free-and-reload loop (#1772). 2. **The card's rule takes mapped idle copies under the PC's pressure too** (`VICTORY_SWEEP_CARD_MAPPED`). A second "wholly unmapped" gate in the free loop, left over after 3246d252 changed the first one, skipped nearly every candidate whenever RAM was short. Also: copies the streamed-out pass freed no longer count as idle (`VICTORY_SWEEP_STALE`), and a 5-s "why kept" line says what holds the rest (`VICTORY_SWEEP_WHY`). 3. **Textures shown through slots are kept** (`resource.rs`, `descriptor/host.rs`, `VICTORY_SWEEP_HELD_GRACE_S`). A texture picked by index never asks for its host copy again, so its `used` stamp goes stale while it is on screen. When the title moves its view to another slot, the old slot lets go before the new one is made, and a look in between freed it: the texture flickered (a character's arm, every few seconds). Copies held by a slot or list within the grace time stay, ones that came back are protected longer (`VICTORY_SWEEP_BACK_PROTECT_S`), and the back-off also counts bytes. `VICTORY_SWEEP_BACK_WHO` logs which code asked for a copy again. Every change has its switch; `=0` restores the old behaviour. ## Screenshots **fps in the world, before vs with this PR:** ![image 6](https://raw.githubusercontent.com/nyxctura/VIctory-NVIDIA/pr-images/6-pr2-fps-chart.png) **With this PR:** card under its budget, RAM free, frame generation running: ![image 5](https://raw.githubusercontent.com/nyxctura/VIctory-NVIDIA/pr-images/5-pr2-after-in-world.jpg) ## How it was tested - **PC:** RTX 5070 12 GB, Ryzen 7 7800X3D, 32 GB RAM, Windows 11 25H2. - **Profile:** Series S, 1080p → 1440p, DLSS Ultra Performance, frame generation 2x, 60 fps cap, ray tracing off. - **Before (16.7 min in the world):** "no room" in 95 % of reports, textures 1,148 MB over their line on average, 1.5 GB RAM free on average in the world (0.7 minimum), frame generation refused 13 times with "out of VRAM", 77 % of seconds with a frame over 150 ms. - **After (7.1 min):** textures 461 MB under their line, card 8.8 of 10.6 GB, 3.5 GB RAM free on average in the world (3.1 minimum), frame generation never refused, 19 % of seconds with a frame over 150 ms. - **Flicker (commit 3):** freed textures back within 10 s went from 5,675 of 101,348 (5.6 %) to 30 of 16,933 (0.2 %). With a 10 s grace it was 2.3 %; in all 64 logged cases a holder had been seen 10.1–27 s before the free, which is why the grace is set by `VICTORY_SWEEP_HELD_GRACE_S` (60 s used here). - The "after" build also had PR 3 (texture queue lock, retired objects) applied; the numbers above are ones that PR does not affect. fps went from 18.3 to 22.1 mean, but that is not this PR's alone. - Played on the v2026.11.29.01 base. On current `main` the branch builds and the `victory-gpu` lib suite passes (apart from `every_switch_of_the_translator_is_in_the_key`, which fails the same way on `main` without this PR). - `cargo test` passed for the crates it touches: yes. New unit tests for the back-off, capping and grace rules. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #1772. ## More charts **Free RAM while playing:** ![free RAM](https://raw.githubusercontent.com/nyxctura/VIctory-NVIDIA/pr-images/9-pr2-free-ram.png) **Textures in use minus their line (above 0, new textures wait):** ![textures vs line](https://raw.githubusercontent.com/nyxctura/VIctory-NVIDIA/pr-images/10-pr2-textures-vs-line.png) **All three PRs at a glance:** ![scorecard](https://raw.githubusercontent.com/nyxctura/VIctory-NVIDIA/pr-images/11-scorecard.png) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
#1772 (3246d252) let the card's rule win while the PC's commit is short
(all session on a 32 GB host): it counted ~11.8 GB against a line of
9.27 GB and let every texture idle 1.5 s go, aiming at ~8.75 GB, out of
reach since ~7 GB of the card is not textures. Uploads per session went
6.8 -> 15.8 GB, p99 86 -> 225 ms. SWEEP_PRESS_BY_ROOM kept sweeps at
1.5 s, each settling the flights.

VICTORY_SWEEP_CAPPED (on; =0: v2026.11.29.01 exactly):
- when copies idle VICTORY_SWEEP_CAPPED_IDLE_S (30) cannot cover the
  card's gap, only they go (all of them at most), never one used within
  that time;
- a copy that came back from the card's rule is not its victim for 5 min;
- when VICTORY_SWEEP_CAPPED_BACK_PERCENT (10) or more of what it let go
  in 20 s (16 at least) came back within 10 s, the card's rule pauses for
  VICTORY_SWEEP_CAPPED_PAUSE_S (60) (pattern of commit-fix 6524f1f5);
- a sweep that let go under VICTORY_SWEEP_CAPPED_USEFUL_MB (64): the next
  one behind flights waits VICTORY_SWEEP_EVERY_MS (15 s), pressed or not.
A 5-second line: textures let go by the card rule and MB, back within
10 s, sweeps run / by the card rule / capped / paused / unproductive.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Root cause of "7.5 GB idle 30 s+, 90 MB let go in 5 s": with the PC's
memory low (host_texture_idle_ms Some: 1.4 GB free in the 2026-11-29 run)
the card rule's look still asked every copy to be placed and wholly
unmapped before it went (0efd23e3 keyed it on host_idle; 3246d252 moved
the earlier check to unmapped_only but missed this one). Mapped idle
copies, nearly all of them, were passed by while the card was 3 GB over
its aim.

- VICTORY_SWEEP_CARD_MAPPED (on): only the PC's rule alone asks for
  wholly unmapped memory (only_unmapped_go); =0 as before.
- VICTORY_SWEEP_STALE (on): the streamed-out pass, and any look finding
  no copy, clears the use stamp, as the card rule does: copies let go
  there stayed in every limited look and their bytes in "idle 30 s+".
- VICTORY_SWEEP_RETRY_SOON (on): a sweep is unproductive (slow cadence)
  only when, besides letting go under 64 MB, it found under 64 MB held
  just for a while (lists not reset, lock busy).
- VICTORY_SWEEP_WHY (on): per-reason counts and bytes of limited looks
  ("texture sweep, why kept ... in 5 s") and every 15 s a census of what
  holds the idle copies (lists, title slots, slots past the title range,
  other references) with slot eviction's last need ("texture sweep, who
  holds the idle copies").

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Root cause of the flicker (textures let go while in use): draws pick
textures by index through slots made long before, and nothing stamps
those uses (`used` is refreshed only when a host copy is asked for).
Only the slot's reference kept the copy. When the title moved a view to
another slot, the old slot let go of it at once, the new one was made
later (a placed view waits for a draw or the texture pass), and a card
rule look in between (since f943761e also over mapped copies) found the
copy idle since the first slot was made and held by nothing, let it go,
and it showed the stand-in until made and uploaded again.

- VICTORY_SWEEP_HELD_GRACE_S (10; 0: off): a copy a look finds held by a
  list or a slot is noted held; a title slot's write notes the texture it
  shows and the one it showed (placed views looked up only, never made).
  The sweep does not let go a copy held within that time (and 4 frames);
  "held lately (slots, lists)" in the why line.
- VICTORY_SWEEP_BACK_PROTECT_S (1800; 0: 300 s as any return): a copy
  back within 10 s of the card's rule letting it go is kept from it that
  long.
- VICTORY_SWEEP_CAPPED_BACK_PERCENT default 3 (was 10), and
  VICTORY_SWEEP_BACK_BY_BYTES (on): the back-off also pauses when that
  share of the bytes came back.
- VICTORY_SWEEP_BACK_WHO (on): copies back within 10 s are counted by the
  place that asked for them again (track_caller), the first 64 logged with
  how idle they were and how long since a holder was seen; every 30 s a
  "who asked again" line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 23:49:11 +00:00
Author
Owner

@⁠advxrsary on GitHub · 2026-11-30 20:03 UTC · original

@⁠nyxctura I think I see the flicker that your third commit describes, on current main. Could you rebase this pull request on main?

What I see. Objects are drawn white for exactly one frame: plants, a palm trunk, a whole flowering tree, bushes. The frame before and the frame after are correct. In play it looks like the object flickers or disappears.

How I found it. I used a diagnostics build with VICTORY_CAPTURE_WORLD_SECONDS=20,200,1, so every presented frame was saved. Then I compared each frame with its neighbours. A blink is a block that is the same in frames k-1 and k+1, but different in frame k. Most of the strongest blinks in about 500 frames were this white object.

What I ruled out.

Check Result
Dropped draws (diagnostics drop reasons) Only the structure builder stages and two programs left out on purpose. No geometry.
Slot eviction (VICTORY_SLOT_EVICT line) 0 textures, 0 slots put back to waiting
More view slots for the title (VICTORY_DYNAMIC_SLOTS=262144, 737,855 title slots instead of 606,783) The white frames stay
First bind of a new pipeline near the blink Not for every blink

This matches what your commit 3 says: a view moves to another slot, the old slot lets go of it, and a sweep finds the copy idle before the new slot is made.

Why I cannot test it now. I tried to merge it on main 84bd61e2. There are 9 conflicts in resource.rs, descriptor.rs and descriptor/host.rs, because main has rewritten the sweep since then. I did not want to resolve the sweep logic by guessing.

Setup: RTX 5080 16 GB, driver 621.24, Ryzen 7 9800X3D, Windows 11. Series X, 2560x1440 output, DLSS performance, frame generation x3, ray tracing off. Main 84bd61e2 with #3918 and my light commits (#4348). None of them touch the sweep.

When it is rebased, I will run the same capture and post the blink counts before and after.

**@⁠advxrsary** on GitHub · 2026-11-30 20:03 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3475#issuecomment-7290338715) @⁠nyxctura I think I see the flicker that your third commit describes, on current main. Could you rebase this pull request on main? **What I see.** Objects are drawn white for exactly one frame: plants, a palm trunk, a whole flowering tree, bushes. The frame before and the frame after are correct. In play it looks like the object flickers or disappears. **How I found it.** I used a diagnostics build with `VICTORY_CAPTURE_WORLD_SECONDS=20,200,1`, so every presented frame was saved. Then I compared each frame with its neighbours. A blink is a block that is the same in frames k-1 and k+1, but different in frame k. Most of the strongest blinks in about 500 frames were this white object. **What I ruled out.** | Check | Result | |---|---| | Dropped draws (diagnostics drop reasons) | Only the structure builder stages and two programs left out on purpose. No geometry. | | Slot eviction (`VICTORY_SLOT_EVICT` line) | 0 textures, 0 slots put back to waiting | | More view slots for the title (`VICTORY_DYNAMIC_SLOTS=262144`, 737,855 title slots instead of 606,783) | The white frames stay | | First bind of a new pipeline near the blink | Not for every blink | This matches what your commit 3 says: a view moves to another slot, the old slot lets go of it, and a sweep finds the copy idle before the new slot is made. **Why I cannot test it now.** I tried to merge it on main 84bd61e2. There are 9 conflicts in `resource.rs`, `descriptor.rs` and `descriptor/host.rs`, because main has rewritten the sweep since then. I did not want to resolve the sweep logic by guessing. **Setup:** RTX 5080 16 GB, driver 621.24, Ryzen 7 9800X3D, Windows 11. Series X, 2560x1440 output, DLSS performance, frame generation x3, ray tracing off. Main 84bd61e2 with #3918 and my light commits (#4348). None of them touch the sweep. When it is rebased, I will run the same capture and post the blink counts before and after.
github-bot closed this pull request 2026-12-01 18:58:33 +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!3475
No description provided.