Skip to content

memguard: count pagefile growth as commit left, as residency does - #2392

Merged
trustno1-coder merged 1 commit into
trustno1-coder:mainfrom
Brillanc3:fix/memguard-commit-growth
Nov 30, 2026
Merged

trustno1-coder merged 1 commit into
trustno1-coder:mainfrom
Brillanc3:fix/memguard-commit-growth

Conversation

@Brillanc3

Copy link
Copy Markdown
Contributor

Fixes #2385

What it changes

The memory guard (memguard.rs, 60a08ef) read the commit left from ullAvailPageFile, the commit limit of the moment. With a system-managed pagefile that limit sits only a few GB above the commit while the world loads, so the guard stayed at its 4096 MB floor and put off about 1,330 compiles per run: their draws were dropped and the game ran at 0.1-0.2 fps (details and logs in #2385).

memguard::figures_now() now takes residency::available_commit(), the limit of the moment plus what the pagefiles may still grow by (held to the free space of their volume less 8 GB; VICTORY_COMMIT_GROWTH=0 keeps the limit alone). The residency pass and the memory guard now count commit the same way (#339). available_commit becomes pub(crate); nothing else changes (floors, defaults, VICTORY_COMMIT_FLOOR_MB, VICTORY_COMPILE_MEMORY).

The guard still protects against the ptxas fatal: Memory allocation failure case it was written for: on a PC whose pagefiles cannot grow (fixed size, or a full volume) the figure is the same as before.

How it was tested

  • GPU and profile: RTX 5080 16 GB (driver 617.42), 32 GB RAM, Windows 11 26200, system-managed pagefile; Series X, 3440x1440 output (with native_1440p: size UI pool for fixed 2560x1440 targets on non-16:9 monitors #2060), DLSS Quality, frame generation auto, no ray tracing.
  • Before: 1,325-1,354 0x8007000e refusals from the guard per run, free_commit_mb=3929, 0.1-0.2 fps from the world load on (three runs, 1440p and 4K).
  • After (default floors): free_commit_mb=80761; no commit refusal, 6 compiles put off by the physical-memory soft floor only, 30 0x8007000e; 5-18 fps in the world over 3 minutes. Still below the menus' 144 fps on this PC (free physical memory ~1.6 GB at ~29 GB committed), which this PR does not claim to fix.
  • cargo test --locked -p victory-gpu --lib -- memguard compilemem pipeline::make: 46 passed.
  • cargo clippy -p victory-gpu --all-targets --no-deps -- -D warnings reports the same 28 + 25 errors on main without this change, none in the two files touched.

Checked for overlap

🤖 Generated with Claude Code

The memory guard read the commit left from ullAvailPageFile, the limit of
the moment. With a system-managed pagefile that limit sits a few GB above
the commit during the world load, so the guard stayed at its 4096 MB floor:
1,325 to 1,354 driver compiles put off in each of three runs (RTX 5080,
32 GB RAM, Series X, 1440p and 4K), their draws dropped, 0.1 to 0.2 fps,
while residency::available_commit saw 83 GB that could still be committed.

figures_now now takes residency::available_commit (the limit of the moment
plus what the pagefiles may still grow by, held to their volume's free
space less 8 GB; VICTORY_COMMIT_GROWTH=0 keeps the limit alone), so both
passes count commit the same way (trustno1-coder#339).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the pr-fix Pull request: fixes a bug label Nov 29, 2026
@github-actions github-actions Bot changed the title [pr-fix] memguard: count pagefile growth as commit left, as residency does memguard: count pagefile growth as commit left, as residency does Nov 29, 2026
@DrDarkDK

Copy link
Copy Markdown

I tested clean origin/main (829188e9) against this PR’s exact head (3ae5f5c8) on Windows 11 with an RTX 4070 Ti, Ryzen 9 7900X, and a system-managed pagefile. #2392 was the only code difference. Both runs used the same launch settings and loaded about 5,100 host pipelines from cache. I observed CPU usage near 100% on both builds.

Gameplay metric 829188e9 3ae5f5c8
Commit-floor compile deferrals logged, first 55 s At least 4 0
Median draws per frame, first 55 s 10,499 10,493
Median rendered FPS, first 55 s 12.75 13.8
Median rendered FPS, seconds 20–55 14.8 14.1

On main, the guard reported 290–1,173 MB of commit headroom when it deferred compiles. Around world load in that same run, residency reported about 77,000 MiB of available commit after counting potential pagefile growth.

The paired run reproduces the reported guard behavior on main and shows zero commit-floor deferrals on the PR build. The FPS comparison changes direction with the sampling window, so I can’t draw a performance conclusion from this pair.

AI-assisted with Codex.

@fainty0

fainty0 commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Review: Request changes

PR #2392 makes compile admission and residency use the same commit-headroom estimate (crates/victory-gpu/src/memguard.rs:115, crates/victory-gpu/src/residency.rs:22–23,201,301). This addresses the mismatch behind #2385, but the optional-work estimate is too optimistic for the hard compile gate.

  1. Don't treat potential expansion as available commit (crates/victory-gpu/src/memguard.rs:103,115). Microsoft documents allocation failures from slow automatic pagefile growth. A system-managed file can grow subject to policy and available disk space; a fixed file cannot. Use estimated growth for soft scheduling (for example, serialise compiles below the normal floor), but require a conservative immediate-commit minimum before starting the driver compile. Describe the result as an estimate, not a promise.
  2. Preserve process limits (crates/victory-gpu/src/residency.rs:22–23,69–85). Per Microsoft, ullAvailPageFile is current process commit headroom in bytes, not free pagefile space; ullTotalPageFile can be process-capped. With 16 GiB RAM, a fixed 4 GiB file and a 16 GiB process cap, subtracting RAM yields a fictitious zero-byte file and can credit 4 GiB of non-existent growth. Use active pagefile sizes for growth and don't credit growth against process/job quotas. System-wide headroom is (CommitLimit − CommitTotal) × PageSize; CommitPeak is historical. The existing byte arithmetic is consistent; the MB knobs use MiB.
  3. Reconcile growth with fresh samples and apply caps per volume (crates/victory-gpu/src/residency.rs:64–87). Adding cached growth to fresh headroom double-counts expansion already reflected in the current limit for up to five seconds. The aggregate cap also allows disk space on a fixed-file volume to fund estimated growth on another, full volume.

Coverage and style: No new regression tests. The admission tests at crates/victory-gpu/src/memguard.rs:181–239 take precomputed headroom; crates/victory-gpu/src/residency.rs:403–411 checks parsing only. Add GPU/game-free tests for fixed files, quotas, per-volume limits, growth between samples and growth disabled. Why-docs fit the house style; no new unsafe, title-thread unwrap() or assets. VICTORY_COMMIT_GROWTH inherits a direct env read at crates/victory-gpu/src/residency.rs:41; use toggled! if changing that path.

Windows Clippy (829188e → 3ae5f5c): Both gates fail on both refs. --keep-going reports 5 → 5 default, 4 → 4 all-features; 0 added, 0 removed. Focused GPU checks report the same 30 default and 13 all-features GPU locations on both refs, none in changed files.

Policy: cargo xtask policy --staged passed for both changed files.

Not verified: Windows tests (not run; no Windows), live pagefile behaviour, claimed performance improvement, full all-features GPU or HLE linting.

@fainty0 fainty0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Request changes

PR #2392 makes compile admission and residency use the same commit-headroom estimate (crates/victory-gpu/src/memguard.rs:115, crates/victory-gpu/src/residency.rs:22–23,201,301). This addresses the mismatch behind #2385, but the optional-work estimate is too optimistic for the hard compile gate.

  1. Don't treat potential expansion as available commit (crates/victory-gpu/src/memguard.rs:103,115). Microsoft documents allocation failures from slow automatic pagefile growth. A system-managed file can grow subject to policy and available disk space; a fixed file cannot. Use estimated growth for soft scheduling (for example, serialise compiles below the normal floor), but require a conservative immediate-commit minimum before starting the driver compile. Describe the result as an estimate, not a promise.
  2. Preserve process limits (crates/victory-gpu/src/residency.rs:22–23,69–85). Per Microsoft, ullAvailPageFile is current process commit headroom in bytes, not free pagefile space; ullTotalPageFile can be process-capped. With 16 GiB RAM, a fixed 4 GiB file and a 16 GiB process cap, subtracting RAM yields a fictitious zero-byte file and can credit 4 GiB of non-existent growth. Use active pagefile sizes for growth and don't credit growth against process/job quotas. System-wide headroom is (CommitLimit − CommitTotal) × PageSize; CommitPeak is historical. The existing byte arithmetic is consistent; the MB knobs use MiB.
  3. Reconcile growth with fresh samples and apply caps per volume (crates/victory-gpu/src/residency.rs:64–87). Adding cached growth to fresh headroom double-counts expansion already reflected in the current limit for up to five seconds. The aggregate cap also allows disk space on a fixed-file volume to fund estimated growth on another, full volume.

Coverage and style: No new regression tests. The admission tests at crates/victory-gpu/src/memguard.rs:181–239 take precomputed headroom; crates/victory-gpu/src/residency.rs:403–411 checks parsing only. Add GPU/game-free tests for fixed files, quotas, per-volume limits, growth between samples and growth disabled. Why-docs fit the house style; no new unsafe, title-thread unwrap() or assets. VICTORY_COMMIT_GROWTH inherits a direct env read at crates/victory-gpu/src/residency.rs:41; use toggled! if changing that path.

Windows Clippy (829188e → 3ae5f5c): Both gates fail on both refs. --keep-going reports 5 → 5 default, 4 → 4 all-features; 0 added, 0 removed. Focused GPU checks report the same 30 default and 13 all-features GPU locations on both refs, none in changed files.

Policy: cargo xtask policy --staged passed for both changed files.

Not verified: Windows tests (not run; no Windows), live pagefile behaviour, claimed performance improvement, full all-features GPU or HLE linting.

@dyshay

dyshay commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch janus-prs). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with --profile diag --features diagnostics, and the CPU tests of the touched crates pass. Runs on an RTX 4090 are queued (Series X 1440p, and Series S with ray tracing, DLSS Quality). Frame times will follow here.

@dyshay

dyshay commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

We hit this independently on an RTX 4090, Series X profile at 1440p with ray tracing (64 GB RAM, system-managed page file). Two things combined:

  • The guard saw 2–4 GB of commit left, while the page file could still grow by about 70 GB. It put off every new compile.
  • The screen-pass wait slept for its whole budget although the compile had been put off. Every frame took 10 s (0.1 fps for the whole run, 245 compiles put off).

Our fix does the same two things as #2188 and #2392 together: the wait ends when the compile is put off, and the guard counts what the page file can still grow by. It is in dyshay/VIctory-NVIDIA. Same scene and settings, measured on the card:

median p95 compiles put off 10 s screen waits
before ~10,000 ms ~10,080 ms 4,000+ 23
after 69.6 ms 277 ms 2 0

So the change is confirmed on a second machine. The tests that reproduce the wait (10 s before, immediate after) are in our commit 06ff9b27 if you want them.

@nick0451

Copy link
Copy Markdown

Independent confirmation: I wrote the same 2-line change last night (same figures_now() → residency::available_commit(&m), available_commit made pub(crate)) and tested it on another configuration, so I'll back this one rather than open a duplicate. Report with the bisect on #1625.

PC: RTX 3090 24 GB, i9-14900K, 32 GB RAM, Windows 11, system-managed pagefile, Series S. Other programs held most of the commit (~15 GB of a 73 GB limit free with the game not running). Every start was a fresh executable name and hash, on the same frozen save.

build fresh starts reaching the world hr=0x8007000e pipeline failures
main 568c5e5 yes (54 s) 0
main 829188e9 no (stuck at the title 5 min; layer private 4 → 18.6 GB) 3,070
main 829188e9, VICTORY_COMPILE_MEMORY=0 2 / 2 0
main 829188e9 + this change 2 / 2 (58-64 s) 25-32 early, then it recovers (6-7 compiles put off per start)

The 23 memguard/compilemem/residency tests passed with it. Clippy has nothing on the changed lines.

🤖 Generated with Claude Code

@L-696

L-696 commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Additional Windows 11 laptop test on RTX 4060 Laptop (8 GB), i7-13650HX and 32 GB RAM. Baseline was v2026.11.29.01 (829188e). The comparison build applied #2392 to memguard.rs and residency.rs. Both used Series X, fixed 2560×1440 output, DLSS Performance, DLSS FG 2× and BVH requested.

Run Host PSO failures Outcome
Release, about 1m38s 28 × 0x8007000E (21 compute, 7 mesh) Device removed (0x887A0005)
Local #2392, first gameplay run 1 × 0x8007000E (compute) No device removal observed
Local #2392, two subsequent runs with descriptor/eviction settings varied 0 in each final summary No device removal observed

The route and cache state were not strictly matched. These are observed counts, not evidence that the patch fixes device removal. Movement-triggered material corruption still repros (#2464).

@frame18studios

Copy link
Copy Markdown

A/B confirmation on v2026.11.29.01 (RTX 5070 Ti Laptop, ~32 GB RAM, Series X, 2560x1440, DLSS Balanced). The GPU code in our local build has only this change on top of the release; memguard.rs/residency.rs are byte-identical to this PR's head 3ae5f5c8 (same patch-id), so this is a confirmation rather than a competing implementation.

Stock official exe 0D3DAE51870BAD44AA529C9FDDD762A513D677FF8D08147134968BA7ED67DFFD:

  • free_commit_mb fell 3866 -> 1098 -> 382, reason "the commit left would fall under its floor".
  • The final refusal line was 46 host pipelines failed (3 compute, 13 graphics, 30 mesh), all 0x8007000e, retried=0, 0 shaders do not translate.
  • Displayed FPS (MSI Afterburner) was 10-15, later around 30 with high latency. The last gameplay host line was 9.8 fps, 101.9 ms/frame.

With this patch:

  • free_commit_mb stayed around 69100; there were no commit-floor deferrals in the log, only the startup line.
  • The final refusal line was 0 host pipelines failed (none), 0 shaders do not translate.
  • Gameplay host lines were 10.7-20.4 fps (last 17.9 fps, 56.0 ms/frame); displayed FPS was 15 with drops to 8.

The two runs are not a controlled FPS comparison: frame generation was x4 in the stock run and off in the patched run (the saved menu setting had changed), so please read the pipeline-refusal counts as the A/B result. The exposure/negative-colour pulse and texture artefacts came from a separate local shader-fold patch, which has been reverted; this change does not touch shader translation or presentation.

VICTORY_COMMIT_GROWTH=0 still gives the old, momentary-limit-only accounting. This confirms the stall in #2385: with roughly 3.9 GB under the momentary limit, compiles were refused even while RAM and pagefile headroom were available.

ea0099 added a commit to ea0099/VIctory-AMD that referenced this pull request Nov 29, 2026
- No native AA carried from an older Series S picture to Series X; the
  start names the upscale mode; F1 saves the mode with a console change.
- Idle textures are let go when the card is full, under host memory
  pressure too (from upstream PR trustno1-coder#2591).
- FSR 3 frame generation's presenter sleeps and waits for its fence
  (upstream PR trustno1-coder#2371).
- The lock-free refresh check wired back (upstream PR trustno1-coder#2175).
- slot_evict honours busy (upstream PR trustno1-coder#2173); the memory guard counts
  pagefile growth (upstream PR trustno1-coder#2392).
- A failed FSR dispatch has the title's state set again; early jitter is
  logged.

Run on an RX 7800 XT as v2026.11.29.02-amd2-test2 for eleven minutes at
FSR Quality with frame generation 2x: no error, no device loss, 0 failed
upscales. A like-for-like speed comparison with amd1 is still to be done
(docs/amd-results.md).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
moritz-eckhard-nickel added a commit to moritz-eckhard-nickel/VIctory-NVIDIA that referenced this pull request Nov 29, 2026
@Lyrnc

Lyrnc commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Tested on an RTX 5080 + 9800X3D with 32 GB RAM and a system-managed page file. Series S, DLSS Quality, FG and RT off, standing still in the world, 300 s per run, all on 829188e. Cold means the driver pipeline cache was deleted first. The columns are fps, compiles put off, and pipelines failed with 0x8007000E.

Build Cold Warm
829188e 0.1–0.2 / 1,337 / 1,272 (never leaves loading) 23.5
#2886 alone 0.4 / 172 / 70 25.9, but 636 put off and 276 refused, so draws are dropped
this PR alone 0.2 / 332 / 138 23.0
#2886 + this PR (merge cleanly) 22.4 / 0 / 0 25.4 / 0 / 0

On this PC, free commit sits at 0.3–2 GB in the world, and this PR is what lifts it over the commit floor. Even with this PR, free physical memory stays under the 1 GB soft floor. #2886's lower floor for pipelines put off again and again is what gets those through. Together they fix the cold-start stall; alone, neither does. The default-off alternative and its numbers are in #3347.

AI use: Claude Code (Claude Opus 5.5) ran these runs and wrote this comment.

@nick0451

nick0451 commented Nov 30, 2026 •

Copy link
Copy Markdown

For whoever merges: six open PRs change the same stall (compiles put off under the commit floor, 0.1–0.3 fps). Here is how they fit together, checked with git merge-tree against main 41adb551 (v2026.11.29.05) and against each other. This is from reading the diffs only, with no runs.

PR what it changes
#2392 (this) the compile gate counts pagefile growth, as residency already does
#2886 a lower commit floor for a pipeline put off again and again
#3347 compile admission off by default
#3426 memory refusals can be retried; on hosts with ≤ 32 GiB RAM, residency counts the commit of the moment only (no pagefile growth)
#3474 one compile at a time under the floor; refusals retried with back-off; a compile's cost measured without the title's card loads
#3398 a draw's wait ends when its compile is put off

One semantic point between #2392 and #3426. They go in opposite directions on ≤ 32 GiB hosts:

Lyrnc's runs above (32 GB: #2392 + #2886 together 22.4 fps cold, either alone 0.2–0.4) suggest the 32 GB case needs a second piece whichever way this goes.

🤖 Generated with Claude Code

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

Labels

pr-fix Pull request: fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v2026.11.29.01: memory guard puts off every compile during the world load (0.1 fps): it ignores pagefile growth

9 participants