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

Merged
bentsignal merged 1 commit from upstream-pr/339 into main 2026-11-29 08:17:00 +00:00
bentsignal commented 2026-11-27 21:12:57 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by bentsignal on 2026-11-27T21:12:57Z.


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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5533166197 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/339). Originally posted by [bentsignal](https://github.com/bentsignal) on 2026-11-27T21:12:57Z. --- ## 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)
jebaczydow commented 2026-11-27 22:45:58 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by jebaczydow on 2026-11-27T22:45:58Z.


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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7229599733 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/339#issuecomment-7229599733). Originally posted by [jebaczydow](https://github.com/jebaczydow) on 2026-11-27T22:45:58Z. --- 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:.
1tsethan commented 2026-11-27 23:01:06 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by 1tsethan on 2026-11-27T23:01:06Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7229804405 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/339#issuecomment-7229804405). Originally posted by [1tsethan](https://github.com/1tsethan) on 2026-11-27T23:01:06Z. --- 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 -->
cloph-dsp commented 2026-11-28 02:01:08 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by cloph-dsp on 2026-11-28T02:01:08Z.


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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7232071925 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/339#issuecomment-7232071925). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-28T02:01:08Z. --- 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).
KruIN689 commented 2026-11-28 10:41:49 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by KruIN689 on 2026-11-28T10:41:49Z.


I tested this PR in game. The PC has an RTX 5080 (driver 621.24), 47 GB of RAM and Windows 11. The pagefile is system-managed (PagingFiles is REG_MULTI_SZ ?:\pagefile.sys) and was 16 GB at the start. I used the release build of #822's head with this commit cherry-picked on top. The game is my own copy. Series X profile, 1440p, DLSS Quality.

Detection: at start the log read pagefiles=["C:\\ system-managed"] commit_limit_mib=64696, so the ?: entry is found.

One 11-minute session. I sampled every 10 s from outside the process (Win32_PerfFormattedData_PerfOS_Memory, the process's private bytes):

  • The game's private commit was 27 GB from the first minute and peaked at 32.9 GB. System commit peaked at 65.3 GB.
  • Commit left under the limit of the moment, which is what residency.rs counted before this PR: 3.3–3.9 GB from minute 1 on, at its lowest 0.7 GB.
    • That is at or under the 4 GB entry threshold of next_pressure for almost the whole session.
    • The exit threshold is 6 GB, so the old code would have stayed pressured.
  • Windows grew the pagefile 16 → 18 → 19 GB, and the commit limit went from 63.2 to 66.2 GB. No allocation was refused. Free RAM stayed at 5.2 GB or more.
  • With this PR: no "host memory pressure" line in the whole session.
  • An earlier 19-minute session without this PR (same PC, slightly older base) logged host memory pressure ... physical_free_mib=7749 available_commit_mib=4091 and stayed there.

Note on the REG_SZ report above: pagefiles() asks only for RRF_RT_REG_MULTI_SZ. Here the value is REG_MULTI_SZ, so it worked, but that matches the earlier report that a REG_SZ value gives an empty list. Asking for RRF_RT_REG_SZ | RRF_RT_REG_MULTI_SZ should cover both, since the split('\0') that follows already handles a single string.

Not tested:

  • A session long enough for the pagefile to reach its cap, and a nearly full disk.
  • Whether textures look different; the late-texture warnings were about the same in both builds.

AI use: Claude Code (Claude Opus 5.5) built and ran this, sampled and analyzed the numbers, and drafted this comment. I read it before posting.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7238062480 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/339#issuecomment-7238062480). Originally posted by [KruIN689](https://github.com/KruIN689) on 2026-11-28T10:41:49Z. --- I tested this PR in game. The PC has an RTX 5080 (driver 621.24), 47 GB of RAM and Windows 11. The pagefile is system-managed (`PagingFiles` is `REG_MULTI_SZ` `?:\pagefile.sys`) and was 16 GB at the start. I used the release build of #822's head with this commit cherry-picked on top. The game is my own copy. Series X profile, 1440p, DLSS Quality. **Detection:** at start the log read `pagefiles=["C:\\ system-managed"] commit_limit_mib=64696`, so the `?:` entry is found. **One 11-minute session.** I sampled every 10 s from outside the process (`Win32_PerfFormattedData_PerfOS_Memory`, the process's private bytes): - The game's private commit was 27 GB from the first minute and peaked at 32.9 GB. System commit peaked at 65.3 GB. - Commit left under the limit of the moment, which is what `residency.rs` counted before this PR: 3.3–3.9 GB from minute 1 on, at its lowest 0.7 GB. - That is at or under the 4 GB entry threshold of `next_pressure` for almost the whole session. - The exit threshold is 6 GB, so the old code would have stayed pressured. - Windows grew the pagefile 16 → 18 → 19 GB, and the commit limit went from 63.2 to 66.2 GB. No allocation was refused. Free RAM stayed at 5.2 GB or more. - With this PR: no "host memory pressure" line in the whole session. - An earlier 19-minute session without this PR (same PC, slightly older base) logged `host memory pressure ... physical_free_mib=7749 available_commit_mib=4091` and stayed there. **Note on the REG_SZ report above:** `pagefiles()` asks only for `RRF_RT_REG_MULTI_SZ`. Here the value is `REG_MULTI_SZ`, so it worked, but that matches the earlier report that a `REG_SZ` value gives an empty list. Asking for `RRF_RT_REG_SZ | RRF_RT_REG_MULTI_SZ` should cover both, since the `split('\0')` that follows already handles a single string. **Not tested:** - A session long enough for the pagefile to reach its cap, and a nearly full disk. - Whether textures look different; the late-texture warnings were about the same in both builds. AI use: Claude Code (Claude Opus 5.5) built and ran this, sampled and analyzed the numbers, and drafted this comment. I read it before posting.
futurepro62 commented 2026-11-28 20:44:46 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by futurepro62 on 2026-11-28T20:44:46Z.


Tested on main 9300875 + this PR. System: RTX 5070 Ti 16 GB (driver 621.40), Ryzen 7 9800X3D (SMT on, 16 threads), 32 GB DDR5, Windows 11 build 26300, pagefile C: 32–64 GB (custom). Title 1.0.2.1. Script launcher, mode 6, Series X, DLSS + DLSS frame generation 4x. Built from source.. Output 3840x2160 + DLSS Performance.

Detection works on a custom pagefile (MEASURED):

INFO victory_gpu::residency: pagefiles: commit can grow beyond the limit of the moment (VICTORY_COMMIT_GROWTH=0: not counted) pagefiles=["C:\\ up to 65536 MB"] commit_limit_mib=64627

Before → after, the same kind of scene (MEASURED). Before:

WARN victory_gpu::residency: host memory pressure: limiting texture prefetch and idle upload storage ... physical_free_mib=2986 available_commit_mib=7921 ...

After:

WARN victory_gpu::residency: host memory pressure: limiting texture prefetch and idle upload storage ... physical_free_mib=2832 available_commit_mib=42042 ...

Commit is now counted correctly (7.9 → 42 GB). On a 32 GB PC the warning still comes about one minute into each session. The cause is now the physical-RAM test (physical <= 3 GiB in next_pressure, READ IN CODE): the game holds ~24–28 GB private. So with 32 GB this PR removes the commit half of the trigger, but not the warning itself. No errors and no crashes in the sessions so far.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7245509096 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/339#issuecomment-7245509096). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-28T20:44:46Z. --- Tested on main `9300875` + this PR. System: RTX 5070 Ti 16 GB (driver 621.40), Ryzen 7 9800X3D (SMT on, 16 threads), 32 GB DDR5, Windows 11 build 26300, pagefile C: 32–64 GB (custom). Title 1.0.2.1. Script launcher, mode 6, Series X, DLSS + DLSS frame generation 4x. Built from source.. Output 3840x2160 + DLSS Performance. **Detection works on a custom pagefile** (MEASURED): ``` INFO victory_gpu::residency: pagefiles: commit can grow beyond the limit of the moment (VICTORY_COMMIT_GROWTH=0: not counted) pagefiles=["C:\\ up to 65536 MB"] commit_limit_mib=64627 ``` **Before → after, the same kind of scene** (MEASURED). Before: ``` WARN victory_gpu::residency: host memory pressure: limiting texture prefetch and idle upload storage ... physical_free_mib=2986 available_commit_mib=7921 ... ``` After: ``` WARN victory_gpu::residency: host memory pressure: limiting texture prefetch and idle upload storage ... physical_free_mib=2832 available_commit_mib=42042 ... ``` Commit is now counted correctly (7.9 → 42 GB). On a 32 GB PC the warning still comes about one minute into each session. The cause is now the physical-RAM test (`physical <= 3 GiB` in `next_pressure`, READ IN CODE): the game holds ~24–28 GB private. So with 32 GB this PR removes the commit half of the trigger, but not the warning itself. No errors and no crashes in the sessions so far.
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
trustno1-coder/VIctory-NVIDIA!339
No description provided.