Residency: count what the pagefiles can still grow by as commit left (no false memory pressure with RAM free) #339

Open
github-bot wants to merge 1 commit from github-bot/gh-339 into main AGit
Owner

@⁠bentsignal on GitHub · 2026-11-27 21:12 UTC · original
bentsignal:residency-commit-growth → main · +161 −3 · 2 files · 1 commits · open

What this fixes

On a PC with plenty of free RAM, the layer goes into "host memory pressure" about 40 seconds into the first cutscene and stays there:

host memory pressure: limiting texture prefetch and idle upload storage ... physical_free_mib=22979 available_commit_mib=928

residency.rs reads ullAvailPageFile (commit left under the limit of the moment) and treats it as a hard wall. On Windows' default setting the pagefile is system-managed: when commit reaches the limit, Windows grows the pagefile. On this PC the limit went from 69 to 75 GB in one session. So the layer thinks it is out of memory while 20+ GB of RAM is free, and then:

  • texture prefetch drops to 16 MB a frame (prefetch_limit, critical commit), so textures picked by index arrive late;
  • the staging pool keeps no spare blocks;
  • any other code that asks pressured() / critical_commit() behaves as if memory were short.

The change

available_commit = commit left now + what the pagefiles can still grow by (commit_growth):

  • Pagefiles are read once from HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PagingFiles. A system-managed entry (no sizes, 0 0, or ?:\pagefile.sys for "automatic on all drives") may grow to 3x RAM, at least 4 GB and at most an eighth of its volume. A custom entry may grow to its own maximum.
  • The pagefiles' size now is taken as the commit limit less the RAM.
  • Growth is held to each volume's free space less 8 GB, sampled every 5 s.
  • sample_commit and refresh use it. Nothing else changes.
  • VICTORY_COMMIT_GROWTH=0 counts the limit of the moment alone, as before.
  • At the first look the log says what was found, e.g. pagefiles=["C:\ system-managed"] commit_limit_mib=70950.

A PC with a fixed pagefile (initial = max), or with no pagefile, behaves as before.

Measured

RTX 5070 Ti 16 GB, Ryzen 9 9900X, 61.6 GB RAM, 7.9 GB system-managed pagefile, Windows 11. Series X profile, 2560x1440, DLSS Quality, release build, every pipeline warmed. First cutscene from a save, keys scripted with VICTORY_KEYS.

before after
"host memory pressure" from ~40 s in, for the rest of the run never
commit left as counted 0.9-1.6 GB 0.9-1.6 GB + the growth (~100+ GB here)
texture prefetch per frame held to 16 MB not held

Late textures in that scene also came from the card's memory, which this PR doesn't touch. Black faces were still there with this change alone.

Windows itself never refused a commit in these runs; the existing E_OUTOFMEMORY back-off (allocation_error) still covers a real refusal.

Tests

  • cargo test -p victory-gpu --lib residency: 4 passed, including a new one for PagingFiles entries (?:, 0 0, custom sizes, empty).
  • cargo clippy -p victory-gpu --all-targets: no new warnings (39 on main before and after).
  • Played several 3-6 minute sessions on this branch's change, merged into our fork.

Setup

Own dump of the title. No game files are attached or quoted.

This change and its testing were done with an AI assistant (Claude Code), and the results were checked on my machine.

🤖 Generated with Claude Code

**@⁠bentsignal** on GitHub · 2026-11-27 21:12 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/339) `bentsignal:residency-commit-growth` → `main` · +161 −3 · 2 files · 1 commits · open ## What this fixes On a PC with plenty of free RAM, the layer goes into "host memory pressure" about 40 seconds into the first cutscene and stays there: ``` host memory pressure: limiting texture prefetch and idle upload storage ... physical_free_mib=22979 available_commit_mib=928 ``` `residency.rs` reads `ullAvailPageFile` (commit left under the limit of the moment) and treats it as a hard wall. On Windows' default setting the pagefile is system-managed: when commit reaches the limit, Windows grows the pagefile. On this PC the limit went from 69 to 75 GB in one session. So the layer thinks it is out of memory while 20+ GB of RAM is free, and then: - texture prefetch drops to 16 MB a frame (`prefetch_limit`, critical commit), so textures picked by index arrive late; - the staging pool keeps no spare blocks; - any other code that asks `pressured()` / `critical_commit()` behaves as if memory were short. ## The change `available_commit` = commit left now + what the pagefiles can still grow by (`commit_growth`): - Pagefiles are read once from `HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PagingFiles`. A system-managed entry (no sizes, `0 0`, or `?:\pagefile.sys` for "automatic on all drives") may grow to 3x RAM, at least 4 GB and at most an eighth of its volume. A custom entry may grow to its own maximum. - The pagefiles' size now is taken as the commit limit less the RAM. - Growth is held to each volume's free space less 8 GB, sampled every 5 s. - `sample_commit` and `refresh` use it. Nothing else changes. - `VICTORY_COMMIT_GROWTH=0` counts the limit of the moment alone, as before. - At the first look the log says what was found, e.g. `pagefiles=["C:\ system-managed"] commit_limit_mib=70950`. A PC with a fixed pagefile (initial = max), or with no pagefile, behaves as before. ## Measured RTX 5070 Ti 16 GB, Ryzen 9 9900X, 61.6 GB RAM, 7.9 GB system-managed pagefile, Windows 11. Series X profile, 2560x1440, DLSS Quality, release build, every pipeline warmed. First cutscene from a save, keys scripted with `VICTORY_KEYS`. | | before | after | |---|---|---| | "host memory pressure" | from ~40 s in, for the rest of the run | never | | commit left as counted | 0.9-1.6 GB | 0.9-1.6 GB + the growth (~100+ GB here) | | texture prefetch per frame | held to 16 MB | not held | Late textures in that scene also came from the card's memory, which this PR doesn't touch. Black faces were still there with this change alone. Windows itself never refused a commit in these runs; the existing `E_OUTOFMEMORY` back-off (`allocation_error`) still covers a real refusal. ## Tests - `cargo test -p victory-gpu --lib residency`: 4 passed, including a new one for `PagingFiles` entries (`?:`, `0 0`, custom sizes, empty). - `cargo clippy -p victory-gpu --all-targets`: no new warnings (39 on `main` before and after). - Played several 3-6 minute sessions on this branch's change, merged into our fork. ## Setup Own dump of the title. No game files are attached or quoted. This change and its testing were done with an AI assistant (Claude Code), and the results were checked on my machine. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Windows grows a system-managed pagefile (its default) when commit reaches the
limit of the moment, up to three times the RAM (at least 4 GB, at most an
eighth of its volume), and a custom one up to its maximum. Counting only the
limit of the moment, the layer declared host memory pressure with 0.9 GB left
to commit while 23 GB of RAM was free (RTX 5070 Ti, 61.6 GB RAM, a 7.9 GB
system-managed pagefile that Windows grew to 13 GB in the same run), then held
texture prefetch to 16 MB a frame and kept no spare staging blocks.

Growth is read from the PagingFiles registry value and held to the free space
of each pagefile's volume less 8 GB; VICTORY_COMMIT_GROWTH=0 counts the limit
of the moment alone, as before.

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

@⁠jebaczydow on GitHub · 2026-11-27 22:45 UTC · original

On a PC where Windows manages the pagefile, pagefiles() returned no entries here, and the log read:

pagefiles: commit can grow beyond the limit of the moment (VICTORY_COMMIT_GROWTH=0: not counted) pagefiles=[] commit_limit_mib=39028

The value on that PC is a REG_SZ, not a REG_MULTI_SZ:

> reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v PagingFiles
    PagingFiles    REG_SZ    ?:\pagefile.sys

RegGetValueW with RRF_RT_REG_MULTI_SZ alone refuses a REG_SZ. Accepting both types in the two calls fixes it:

-    use windows_sys::Win32::System::Registry::{HKEY_LOCAL_MACHINE, RRF_RT_REG_MULTI_SZ, RegGetValueW};
+    use windows_sys::Win32::System::Registry::{HKEY_LOCAL_MACHINE, RRF_RT_REG_MULTI_SZ, RRF_RT_REG_SZ, RegGetValueW};
+    let types = RRF_RT_REG_SZ | RRF_RT_REG_MULTI_SZ;
@@ (both RegGetValueW calls)
-            RRF_RT_REG_MULTI_SZ,
+            types,

With that change, the same PC logged:

pagefiles: commit can grow beyond the limit of the moment (VICTORY_COMMIT_GROWTH=0: not counted) pagefiles=["C:\ system-managed"] commit_limit_mib=43138

Windows 11 (10.0.26300), 31.6 GB RAM, system-managed pagefile on C:.

**@⁠jebaczydow** on GitHub · 2026-11-27 22:45 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/339#issuecomment-7229599733) On a PC where Windows manages the pagefile, `pagefiles()` returned no entries here, and the log read: ``` pagefiles: commit can grow beyond the limit of the moment (VICTORY_COMMIT_GROWTH=0: not counted) pagefiles=[] commit_limit_mib=39028 ``` The value on that PC is a `REG_SZ`, not a `REG_MULTI_SZ`: ``` > reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v PagingFiles PagingFiles REG_SZ ?:\pagefile.sys ``` `RegGetValueW` with `RRF_RT_REG_MULTI_SZ` alone refuses a `REG_SZ`. Accepting both types in the two calls fixes it: ```diff - use windows_sys::Win32::System::Registry::{HKEY_LOCAL_MACHINE, RRF_RT_REG_MULTI_SZ, RegGetValueW}; + use windows_sys::Win32::System::Registry::{HKEY_LOCAL_MACHINE, RRF_RT_REG_MULTI_SZ, RRF_RT_REG_SZ, RegGetValueW}; + let types = RRF_RT_REG_SZ | RRF_RT_REG_MULTI_SZ; @@ (both RegGetValueW calls) - RRF_RT_REG_MULTI_SZ, + types, ``` With that change, the same PC logged: ``` pagefiles: commit can grow beyond the limit of the moment (VICTORY_COMMIT_GROWTH=0: not counted) pagefiles=["C:\ system-managed"] commit_limit_mib=43138 ``` Windows 11 (10.0.26300), 31.6 GB RAM, system-managed pagefile on C:.
Author
Owner

@⁠1tsethan on GitHub · 2026-11-27 23:01 UTC · original

Independent Windows validation of PR #339.

Tested commit: e8e2dfcd718a2d1c7b6f1be58b9e9d120cc2980c.

cargo test --locked -p victory-gpu residency:: -- --nocapture --test-threads=1

Exit: 0.

  • test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 456 filtered out; finished in 0.00s

Coverage here is existing residency tests including pagefile parsing, not empirical allocation/headroom behavior under low disk space or pagefile growth.

Independent verification with OpenAI Codex assistance. Windows 11 Pro build 26200; Rust 1.98.1 MSVC; Windows SDK libraries from Microsoft.Windows.SDK.CPP.x64 10.0.28000.2957. Test harness used an RTX 3070 Ti / AMD integrated-GPU host; adapter identity was not captured for every test. These are focused checks on the stated PR commit, not gameplay, FPS, or a merged-main integration result.

**@⁠1tsethan** on GitHub · 2026-11-27 23:01 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/339#issuecomment-7229804405) Independent Windows validation of PR #339. Tested commit: `e8e2dfcd718a2d1c7b6f1be58b9e9d120cc2980c`. `cargo test --locked -p victory-gpu residency:: -- --nocapture --test-threads=1` Exit: **0**. - test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 456 filtered out; finished in 0.00s Coverage here is existing residency tests including pagefile parsing, not empirical allocation/headroom behavior under low disk space or pagefile growth. Independent verification with OpenAI Codex assistance. Windows 11 Pro build 26200; Rust 1.98.1 MSVC; Windows SDK libraries from Microsoft.Windows.SDK.CPP.x64 10.0.28000.2957. Test harness used an RTX 3070 Ti / AMD integrated-GPU host; adapter identity was not captured for every test. These are focused checks on the stated PR commit, not gameplay, FPS, or a merged-main integration result. <!-- victory-native-validation-20261128 -->
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-28 02:01 UTC · original

Independent local verification (Windows, Rust 1.100.0/MSVC, no game data):

  • PR #339 at head e8e2dfcd718a2d1c7b6f1be58b9e9d120cc2980c, single-commit parent/base 0f0ada19095979e2192d1b5a98bb5297cf4d53ea.
  • cargo test --locked -p victory-gpu --lib -- residency::tests::pagefile_entries_say_their_volume_and_largest_size --exact --test-threads=1 --quiet → 1 passed, 0 failed, 459 filtered, exit 0.
  • git grep -F for the test name on the base returned no hits (test is new on this PR); git diff --check 0f0ada19 HEAD clean (2 files, +161/-3).
  • Used a per-worktree CARGO_TARGET_DIR (never shared) with CARGO_BUILD_JOBS=2; local clone is shallow so the PR's single-commit parent was used as base instead of a merge-base.
  • Only the named synthetic test was replayed; full workspace suite and clippy were not run locally (no clippy component on this toolchain). Pre-existing compiler warnings present.
  • GPU/driver: N/A (CPU-only residency test). No game data, assets, extracted shaders, DRM or decrypt involved.

AI-assisted (Hy4 flash).

**@⁠cloph-dsp** on GitHub · 2026-11-28 02:01 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/339#issuecomment-7232071925) Independent local verification (Windows, Rust 1.100.0/MSVC, no game data): - PR #339 at head `e8e2dfcd718a2d1c7b6f1be58b9e9d120cc2980c`, single-commit parent/base `0f0ada19095979e2192d1b5a98bb5297cf4d53ea`. - `cargo test --locked -p victory-gpu --lib -- residency::tests::pagefile_entries_say_their_volume_and_largest_size --exact --test-threads=1 --quiet` → 1 passed, 0 failed, 459 filtered, exit 0. - `git grep -F` for the test name on the base returned no hits (test is new on this PR); `git diff --check 0f0ada19 HEAD` clean (2 files, +161/-3). - Used a per-worktree `CARGO_TARGET_DIR` (never shared) with `CARGO_BUILD_JOBS=2`; local clone is shallow so the PR's single-commit parent was used as base instead of a merge-base. - Only the named synthetic test was replayed; full workspace suite and clippy were not run locally (no clippy component on this toolchain). Pre-existing compiler warnings present. - GPU/driver: N/A (CPU-only residency test). No game data, assets, extracted shaders, DRM or decrypt involved. AI-assisted (Hy4 flash).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/339/head:github-bot/gh-339'
git switch 'github-bot/gh-339'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-339'
git switch 'github-bot/gh-339'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-339'
git switch 'github-bot/gh-339'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-339'
git switch 'main'
git merge --squash 'github-bot/gh-339'
git switch 'main'
git merge --ff-only 'github-bot/gh-339'
git switch 'main'
git merge 'github-bot/gh-339'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.