GPU: trim caches under system commit pressure #43

Open
tecnofifamobile-ai wants to merge 3 commits from upstream-pr/43 into main
tecnofifamobile-ai commented 2026-11-25 20:24:53 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by tecnofifamobile-ai on 2026-11-25T20:24:53Z.


Summary

  • Use Windows available system commit as an additional cache pressure signal.
  • Shorten idle retention for texture, staging, shadow, and mapped pipeline-library caches as commit headroom falls.
  • Add regression coverage for low commit headroom while VRAM remains below its pressure threshold.

The crash log recorded 0x8007000E texture/pipeline failures followed by a Rust allocation failure, while Windows Event 2004 showed system commit at 49,847,648,256 / 50,114,695,168 bytes and victory.exe at 22,322,229,248 bytes. This change makes idle GPU caches respond to system commit pressure, not only VRAM and physical RAM pressure.

Validation

  • cargo test -p victory-gpu -- --test-threads=1 (190 passed, 3 ignored; doc tests passed)
  • git diff --check
<!-- greyfinch-sync:DexNom/VIctory:issue:5498591728 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/43). Originally posted by [tecnofifamobile-ai](https://github.com/tecnofifamobile-ai) on 2026-11-25T20:24:53Z. --- ## Summary - Use Windows available system commit as an additional cache pressure signal. - Shorten idle retention for texture, staging, shadow, and mapped pipeline-library caches as commit headroom falls. - Add regression coverage for low commit headroom while VRAM remains below its pressure threshold. The crash log recorded `0x8007000E` texture/pipeline failures followed by a Rust allocation failure, while Windows Event 2004 showed system commit at 49,847,648,256 / 50,114,695,168 bytes and `victory.exe` at 22,322,229,248 bytes. This change makes idle GPU caches respond to system commit pressure, not only VRAM and physical RAM pressure. ## Validation - `cargo test -p victory-gpu -- --test-threads=1` (190 passed, 3 ignored; doc tests passed) - `git diff --check`
Artking175 commented 2026-11-25 21:10:12 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by Artking175 on 2026-11-25T21:10:12Z.


Two details worth checking against the out-of-memory run:

  • The texture, staging, and shadow sweeps still require IDLE_FRAMES = 4 in long_ago. At 0.2–0.4 frame advances per second, that gate is roughly 10–20 seconds even with the 250 ms commit-pressure timeout. I saw that frame-rate range on RTX 2060 during a separate dark-prologue run. The new threshold tests exercise the millisecond policy only. A case covering slow frame advancement would make the practical eviction delay visible.
  • MEMORYSTATUSEX.ullAvailPageFile reports commit available to the calling process, which can be lower than the system-wide headroom in Event 2004. The effective process value seems useful for this heuristic. Could the helper documentation name that distinction? Microsoft's field documentation.

This is a source review of 1a82816.

<!-- greyfinch-sync:DexNom/VIctory:comment:7174705148 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/43#issuecomment-7174705148). Originally posted by [Artking175](https://github.com/Artking175) on 2026-11-25T21:10:12Z. --- Two details worth checking against the out-of-memory run: - The texture, staging, and shadow sweeps still require `IDLE_FRAMES = 4` in `long_ago`. At 0.2–0.4 frame advances per second, that gate is roughly 10–20 seconds even with the 250 ms commit-pressure timeout. I saw that frame-rate range on RTX 2060 during a separate dark-prologue run. The new threshold tests exercise the millisecond policy only. A case covering slow frame advancement would make the practical eviction delay visible. - `MEMORYSTATUSEX.ullAvailPageFile` reports commit available to the calling process, which can be lower than the system-wide headroom in Event 2004. The effective process value seems useful for this heuristic. Could the helper documentation name that distinction? [Microsoft's field documentation](https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/ns-sysinfoapi-memorystatusex). This is a source review of `1a82816`.
j-fuxa commented 2026-11-26 01:41:12 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by j-fuxa on 2026-11-26T01:41:12Z.


Measurements on what counts toward process commit and working set (NVIDIA)

These bear on the commit-headroom signal in this PR. They come from an RTX 4060 Laptop 8 GB, 32 GB RAM, Windows 11, at the title's world entry, in a different fork where we used a job-object commit limit as a guard.

  • The driver charges D3D12 default-heap textures that live in VRAM to the process's commit. Eight 16 MiB textures added 128 MiB of private bytes. At world entry that was about 4.3 GB of commit for texture storage. This agrees with the comment on texture_idle_ms that local-memory textures also consume the commit limit. It also means headroom can fall while physical RAM and the host caches are not the cause, so shorter cache idle times may not give it back.
  • Private working set undercounts: title memory held in pagefile-backed sections is counted as shareable (about 7 GiB here).
  • Whole working set overcounts: a page mapped at two addresses counts twice (0.6-1.0 GiB). QueryWorkingSet's share count saturates at 7, so it cannot dedupe. Walking the working set over the known views and counting each section page once does work.
  • RAM at world entry: the title holds 7.1 GB of physical pages, mapped as 11.5 GB of its own views plus 2.3-2.5 GB of GPU page-mapping copies. The roughly 20 GB "mapped" figure is address space. Only 1.9-2.7 GB of distinct title pages were resident, and a zero-page scan found no eager touching. The emulator's own private memory (about 8 GB) dominated.

Why it may matter here. If trimming is meant to react to commit, it helps to log three things separately when headroom is low: commit charged for VRAM textures, the host caches, and the title's sections. Then a low-headroom event can be attributed.

Caveats. NVIDIA only. We do not know whether the Radeon driver charges VRAM textures the same way. One title, one scene, numbers from our own builds and not from this branch.

<!-- greyfinch-sync:DexNom/VIctory:comment:7180023391 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/43#issuecomment-7180023391). Originally posted by [j-fuxa](https://github.com/j-fuxa) on 2026-11-26T01:41:12Z. --- **Measurements on what counts toward process commit and working set (NVIDIA)** These bear on the commit-headroom signal in this PR. They come from an RTX 4060 Laptop 8 GB, 32 GB RAM, Windows 11, at the title's world entry, in a different fork where we used a job-object commit limit as a guard. - The driver charges D3D12 default-heap textures that live in VRAM to the process's commit. Eight 16 MiB textures added 128 MiB of private bytes. At world entry that was about 4.3 GB of commit for texture storage. This agrees with the comment on `texture_idle_ms` that local-memory textures also consume the commit limit. It also means headroom can fall while physical RAM and the host caches are not the cause, so shorter cache idle times may not give it back. - Private working set undercounts: title memory held in pagefile-backed sections is counted as shareable (about 7 GiB here). - Whole working set overcounts: a page mapped at two addresses counts twice (0.6-1.0 GiB). `QueryWorkingSet`'s share count saturates at 7, so it cannot dedupe. Walking the working set over the known views and counting each section page once does work. - RAM at world entry: the title holds 7.1 GB of physical pages, mapped as 11.5 GB of its own views plus 2.3-2.5 GB of GPU page-mapping copies. The roughly 20 GB "mapped" figure is address space. Only 1.9-2.7 GB of distinct title pages were resident, and a zero-page scan found no eager touching. The emulator's own private memory (about 8 GB) dominated. **Why it may matter here.** If trimming is meant to react to commit, it helps to log three things separately when headroom is low: commit charged for VRAM textures, the host caches, and the title's sections. Then a low-headroom event can be attributed. **Caveats.** NVIDIA only. We do not know whether the Radeon driver charges VRAM textures the same way. One title, one scene, numbers from our own builds and not from this branch.
Artking175 commented 2026-11-26 05:32:25 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by Artking175 on 2026-11-26T05:32:25Z.


I checked the follow-up at 8354242 on Windows 10. The six pressure-filtered tests and the separate requested-sweep test passed, including commit_pressure_does_not_wait_for_slow_frame_advances. The updated documentation also distinguishes per-process commit headroom from the system-wide value in Event 2004. This addresses both points from my earlier review. The tests cover the sweep policy and age gates. I did not drive the machine into an actual out-of-memory condition.

<!-- greyfinch-sync:DexNom/VIctory:comment:7183578327 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/43#issuecomment-7183578327). Originally posted by [Artking175](https://github.com/Artking175) on 2026-11-26T05:32:25Z. --- I checked the follow-up at `8354242` on Windows 10. The six pressure-filtered tests and the separate requested-sweep test passed, including `commit_pressure_does_not_wait_for_slow_frame_advances`. The updated documentation also distinguishes per-process commit headroom from the system-wide value in Event 2004. This addresses both points from my earlier review. The tests cover the sweep policy and age gates. I did not drive the machine into an actual out-of-memory condition.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/43:upstream-pr/43'
git switch 'upstream-pr/43'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/43'
git switch 'upstream-pr/43'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/43'
git switch 'upstream-pr/43'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/43'
git switch 'main'
git merge --squash 'upstream-pr/43'
git switch 'main'
git merge --ff-only 'upstream-pr/43'
git switch 'main'
git merge 'upstream-pr/43'
git push origin 'main'
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
DexNom/VIctory!43
No description provided.