8 GB card / 16 GB RAM: prelude OOM retry, texture sweep off the frame, lighter memory line, replay cross-adapter fix #4306

Closed
github-bot wants to merge 26 commits from github-bot/gh-4305 into main AGit
Owner

@⁠leo-pansonato on GitHub · 2026-11-30 18:39 UTC · original
leo-pansonato:main → main · +1355 −887 · 37 files · 26 commits · closed without merging

What it changes

Fixes and memory relief for an 8 GB card with 16 GB of RAM (RTX 5060 Ti, i5-14600KF). On that PC the process ran out of commit, stalled on its own bookkeeping, and sometimes crashed. Every change below is on by default and needs no switch.

  • State prelude: no more crash on E_OUTOFMEMORY.
    • Before: a prelude recording that hit 0x8007000E gave up the run ("host state prelude did not record").
    • Now: the spares no list holds are freed and the prelude is recorded again on a new allocator.
    • The last commit points that retry at the plan's uploads and detiles, because they moved into the prelude plan upstream.
  • Preludes: fewer are kept on small PCs (32 instead of 256), and they are let go under memory pressure.
  • Host lists:
    • their tables are trimmed on reset;
    • the pipeline names kept per list are capped, unless pipelines are metered.
  • Texture sweep: runs on a thread of its own instead of inside the frame. It used to hold a frame for up to 1.5 s.
  • Process heaps: under memory pressure, they give back the memory they keep free.
  • Memory line (procmem):
    • named no longer counts mapped sections;
    • lists and preludes are counted;
    • the line shows Windows' own figure for the card's memory;
    • the heap census and the address-space walk run at most once a minute (VICTORY_PROCESS_MEMORY_S, default 60 s). Walking every 5 s stalled the game for 1.5–2 s each time.
    • There is also a counter of hitches.
  • Replay: resources of heaps opened from title memory are made without D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER.
    • Those heaps lose their sharing flags in a capture, so creation failed with E_INVALIDARG, and the replay then hung the device (0x887A0006).
  • Commits: 12, rebased on e1251c31.

How it was tested

  • Profile: RTX 5060 Ti 8 GB, 16 GB RAM, Series S profile, 1080p to 1440p, DLSS performance, no frame generation.
  • Runs: 300 s each with the same scripted inputs, on the same scene (the boat scene).
  • Builds compared:
    • Before: upstream 84bd61e2 with its defaults.
    • After: these commits on top of 84bd61e2, with the same defaults.
  • Before: median fps 21.5 / 22.5 / 22.8 over three runs. Two more runs stopped early: 25 s and 129 s of play, with long stretches under 1 fps. Least free RAM was 16–340 MB.
  • After: median fps 22.5 / 23.3 over two runs, both completed. Per stretch, the opening ran at 33–36 fps and the boat at 18–25 fps.
    • fps is about equal to upstream; the gain is in stability and memory.
  • Not tested: the 30-series or AMD cards, and frame generation.
  • cargo test --workspace --locked: everything this PR touches passes. Two tests fail, and they fail the same way on a clean upstream/main (e1251c31):
    • list::thin::tests::bindings_record_no_work: 47 != 49;
    • shader_cache::tests::every_switch_of_the_translator_is_in_the_key.
  • cargo clippy --workspace --all-targets --all-features --locked: none of the warnings come from these commits. The five there are in upstream lines: copystat.rs:1470, host.rs:5252, shadow.rs:7211, xmem.rs:1933, lower.rs:114.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related, partly overlapping:

    This PR does not depend on any of them; whichever lands first, I can rebase the other side.

🤖 Generated with Claude Code

**@⁠leo-pansonato** on GitHub · 2026-11-30 18:39 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4305) `leo-pansonato:main` → `main` · +1355 −887 · 37 files · 26 commits · closed without merging ## What it changes Fixes and memory relief for an 8 GB card with 16 GB of RAM (RTX 5060 Ti, i5-14600KF). On that PC the process ran out of commit, stalled on its own bookkeeping, and sometimes crashed. Every change below is on by default and needs no switch. - **State prelude: no more crash on E_OUTOFMEMORY.** - Before: a prelude recording that hit `0x8007000E` gave up the run ("host state prelude did not record"). - Now: the spares no list holds are freed and the prelude is recorded again on a new allocator. - The last commit points that retry at the plan's uploads and detiles, because they moved into the prelude plan upstream. - **Preludes:** fewer are kept on small PCs (32 instead of 256), and they are let go under memory pressure. - **Host lists:** - their tables are trimmed on reset; - the pipeline names kept per list are capped, unless pipelines are metered. - **Texture sweep:** runs on a thread of its own instead of inside the frame. It used to hold a frame for up to 1.5 s. - **Process heaps:** under memory pressure, they give back the memory they keep free. - **Memory line (`procmem`):** - `named` no longer counts mapped sections; - lists and preludes are counted; - the line shows Windows' own figure for the card's memory; - the heap census and the address-space walk run at most once a minute (`VICTORY_PROCESS_MEMORY_S`, default 60 s). Walking every 5 s stalled the game for 1.5–2 s each time. - There is also a counter of hitches. - **Replay:** resources of heaps opened from title memory are made without `D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER`. - Those heaps lose their sharing flags in a capture, so creation failed with `E_INVALIDARG`, and the replay then hung the device (`0x887A0006`). - **Commits:** 12, rebased on `e1251c31`. ## How it was tested - **Profile:** RTX 5060 Ti 8 GB, 16 GB RAM, Series S profile, 1080p to 1440p, DLSS performance, no frame generation. - **Runs:** 300 s each with the same scripted inputs, on the same scene (the boat scene). - **Builds compared:** - Before: upstream `84bd61e2` with its defaults. - After: these commits on top of `84bd61e2`, with the same defaults. - **Before:** median fps 21.5 / 22.5 / 22.8 over three runs. Two more runs stopped early: 25 s and 129 s of play, with long stretches under 1 fps. Least free RAM was 16–340 MB. - **After:** median fps 22.5 / 23.3 over two runs, both completed. Per stretch, the opening ran at 33–36 fps and the boat at 18–25 fps. - fps is about equal to upstream; the gain is in stability and memory. - **Not tested:** the 30-series or AMD cards, and frame generation. - **`cargo test --workspace --locked`:** everything this PR touches passes. Two tests fail, and they fail the same way on a clean `upstream/main` (`e1251c31`): - `list::thin::tests::bindings_record_no_work`: `47 != 49`; - `shader_cache::tests::every_switch_of_the_translator_is_in_the_key`. - **`cargo clippy --workspace --all-targets --all-features --locked`:** none of the warnings come from these commits. The five there are in upstream lines: `copystat.rs:1470`, `host.rs:5252`, `shadow.rs:7211`, `xmem.rs:1933`, `lower.rs:114`. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related, partly overlapping: - #4205: procmem `named` count; - #2783 and #2877: the 5 s address-space walk; - #3858, #3578, #4138: texture sweep pacing or threading; - #4042 and #1397: prelude recording. This PR does not depend on any of them; whichever lands first, I can rebase the other side. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
On an 8 GB card with 16 GB of RAM the PC's memory shared with the card
reaches the system's budget (7.45 GB there) and `list.Close()` of a
state prelude fails with 0x8007000E, which ended the run ("a host state
prelude did not record"). As upload buffers already do, the spares no
list holds are freed and the prelude is recorded once more, on a new
allocator, before the run is given up. Detilings the first recording
noted for the submission are forgotten so the second records them too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each kept prelude is a command allocator and a list of the driver's
memory (about 2.9 MB at creation, more once the allocator grew), and the
pool of 256 was trimmed only by its cap. Now VICTORY_PRELUDES_KEPT, else
32 on a PC of less than 24 GiB of RAM (256 above), and the sweep under
the PC's memory pressure keeps 16, letting the oldest allocators go, as
it already does for idle lists.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The title's mapped section pages are not in the private bytes
(PagefileUsage), yet "named" added them: on a 16 GB PC it hid 6.9 GB of
what the layer and the driver hold. The line now also gives host lists,
preludes alive and kept, and idle lists trimmed, the driver's memory no
other counter shows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- VICTORY_WINDOWS_BAR_PERCENT (80 by default, 50 to 97): up to what share
  of the card's budget in use a window is made in card memory the CPU
  maps. At 80 an 8 GB card, filled to the textures' line (90), kept every
  window in the PC's memory and its shaders read them across the bus; with
  the textures' line lowered a line above it gives the windows that room.
- VICTORY_PROCESS_HEAPS=2: at most once a minute the memory line walks the
  heaps' blocks in use and gives the largest heaps and size classes, to
  tell what holds 3.4 GB of heaps on a 16 GB PC.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The layer's heap held 3.3 GB in 3.6 million blocks on a 16 GB PC, with
600 MB more committed and free, while the PC had 3 to 50 MB of RAM free
and paged. Under the PC's memory pressure, at most every ten seconds,
HeapSetInformation(HeapOptimizeResources) on every heap gives the free
memory back (VICTORY_HEAP_OPTIMIZE=0: not).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A list's tables kept their largest recording's room through every reset;
they now give it back when it is over four times what was used. Pipeline
names per list stop at 24 unless the card meter is on. Measured: the
process heap 3270 -> 3214 MB (less than estimated; the rest is elsewhere).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
resource::let_go_idle ran once a second on the submitting thread: 18 ms a
look on average and up to 1.5 s on a 16 GB PC, all of it frame time. It
decides by idle time and holders, not by thread, so it now runs on
victory-texture-sweep (VICTORY_SWEEP_THREAD=0: as before).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The card meter is on by default, so the cap of 1b62ef99 never applied;
it now lifts only with VICTORY_CARD_METER_PIPELINES=1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
HeapSummary holds each heap's lock while it counts; with 3.6 million
blocks, at every process-memory line (5 s) it froze the title 1.5-2 s:
37 frames over 500 ms in three minutes of play, 4-10 without it.
scripts/lowmem/hitches.ps1 counts long frames in a log and their gaps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The heaps are made without their sharing flags, so the cross-adapter
buffer the renderer port opens title memory as was refused (0x80070057)
and the frame then lost the card (0x887A0006). Replayed after the fix: a
prison cutscene frame takes 12.9 ms on an RTX 5060 Ti, where the live
frame took 46.7.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
76,000 regions took 340-500 ms (at times 1.1 s) every five seconds, and
the layer's own GetWriteWatch, VirtualProtect and VirtualAlloc calls wait
behind it; a diagnostics timeline showed a present waiting in
VirtualQuery. VICTORY_PROCESS_MEMORY_S sets the period (60). Lowmem
bench: frames over 250 ms after two minutes 10.1-10.6 s against 12.5-15.1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The upload list and the detiles moved into the prelude plan upstream; the
E_OUTOFMEMORY retry now reads them from there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 18:39:56 +00:00
The five warnings were in upstream lines (host.rs, xmem.rs, copystat.rs,
shadow.rs, lower.rs); with -D warnings they failed CI's clippy step.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot closed this pull request 2026-12-01 18:50:12 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:44 UTC · original

Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:44 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4305#issuecomment-7321449933) Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

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!4306
No description provided.