The title's 32-bit graphics heap as private write-watched memory (VICTORY_LOW_HEAP_PRIVATE=1, off by default) #4874

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

@⁠Liliallen on GitHub · 2026-12-01 12:20 UTC · original
Liliallen:pr-low-heap-private → main · +67 −0 · 1 files · 1 commits · open

What it changes

The game reserves a 185 MB heap below 4 GiB as a placeholder, splits it in five, maps the pages of one XMemAllocatePhysicalPages into the pieces once, and never maps those pages anywhere else. As views of physical pages the heap can only be watched by page protection (the kernel watches no view), so every first write to a block there is a write fault on a title thread and a protection change. In play, 54 % of the title's write faults were in this heap.

VICTORY_LOW_HEAP_PRIVATE=1 (off by default) makes that heap one private allocation of its own, committed and write-watched, in place of the placeholder. The title's placeholder splits, page mappings and frees inside it do nothing (logged). It stays off with renderer port 1 (port_on()) and under Wine.

shortcut: pages mapped there that were written through another mapping first, or mapped elsewhere afterwards, would not show the same bytes. The game does neither in the runs below; it is logged if it happens.

How it was tested

  • GPU and profile: RTX 5070 Ti, Series X, 2560x1440, DLSS Balanced, frame generation 2x, ray tracing off. The same 260 s play route (driving and walking), on a tree based on v2026.11.29.05, 2026-11-30.
  • Before (switch off): 2,146,303 title write faults; seconds with a frame over 100 ms 71 %; median frame 61 ms; 15.4 fps.
  • After (switch on): 999,423 title write faults; seconds with a frame over 100 ms 51 %; median frame 56 ms; 14.9 fps (the fps difference is inside run-to-run noise). The picture looked the same.
  • Not tested: the game on this branch (rebased onto main 5fabb46e) has not been run; the numbers above are from the older base. Not tested on Series S, AMD, Intel or under Wine.
  • For shader changes, the wave sizes tested: not a shader change.
  • cargo test --locked -p victory-hle -p victory-gpu on this branch: victory-gpu passed (1095 passed, 66 ignored). victory-hle: 468 passed, 1 failed, modules::kernel::tests::the_narrow_command_line_is_in_the_ansi_code_page, which fails the same way on main 5fabb46e on this PC (#4539 is about it). a_read_by_range_waits_only_for_a_remapping_that_meets_it failed in some full runs on both this branch and main, and passed alone (#2439, #4419).
  • cargo clippy --locked -p victory-gpu -p victory-hle --all-targets -- -D warnings: 5 findings, all in host/font.rs, host/menu.rs and host/panel.rs, which this PR does not touch; the same on main. No finding in xmem.rs.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: none change the 32-bit graphics heap. Many open PRs touch xmem.rs; the nearest are #3859 and #2923 (renderer port 1, which this switch stays out of) and #4761 (page mapping in XMemMapPhysicalPages).

🤖 Generated with Claude Code

https://claude.ai/code/session_01KXyvvT4sXPGBobHa74YXgA

**@⁠Liliallen** on GitHub · 2026-12-01 12:20 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4873) `Liliallen:pr-low-heap-private` → `main` · +67 −0 · 1 files · 1 commits · open ## What it changes The game reserves a 185 MB heap below 4 GiB as a placeholder, splits it in five, maps the pages of one `XMemAllocatePhysicalPages` into the pieces once, and never maps those pages anywhere else. As views of physical pages the heap can only be watched by page protection (the kernel watches no view), so every first write to a block there is a write fault on a title thread and a protection change. In play, 54 % of the title's write faults were in this heap. `VICTORY_LOW_HEAP_PRIVATE=1` (off by default) makes that heap one private allocation of its own, committed and write-watched, in place of the placeholder. The title's placeholder splits, page mappings and frees inside it do nothing (logged). It stays off with renderer port 1 (`port_on()`) and under Wine. shortcut: pages mapped there that were written through another mapping first, or mapped elsewhere afterwards, would not show the same bytes. The game does neither in the runs below; it is logged if it happens. ## How it was tested - GPU and profile: RTX 5070 Ti, Series X, 2560x1440, DLSS Balanced, frame generation 2x, ray tracing off. The same 260 s play route (driving and walking), on a tree based on v2026.11.29.05, 2026-11-30. - Before (switch off): 2,146,303 title write faults; seconds with a frame over 100 ms 71 %; median frame 61 ms; 15.4 fps. - After (switch on): 999,423 title write faults; seconds with a frame over 100 ms 51 %; median frame 56 ms; 14.9 fps (the fps difference is inside run-to-run noise). The picture looked the same. - Not tested: the game on this branch (rebased onto `main` 5fabb46e) has not been run; the numbers above are from the older base. Not tested on Series S, AMD, Intel or under Wine. - For shader changes, the wave sizes tested: not a shader change. - `cargo test --locked -p victory-hle -p victory-gpu` on this branch: victory-gpu passed (1095 passed, 66 ignored). victory-hle: 468 passed, 1 failed, `modules::kernel::tests::the_narrow_command_line_is_in_the_ansi_code_page`, which fails the same way on `main` 5fabb46e on this PC (#4539 is about it). `a_read_by_range_waits_only_for_a_remapping_that_meets_it` failed in some full runs on both this branch and `main`, and passed alone (#2439, #4419). - `cargo clippy --locked -p victory-gpu -p victory-hle --all-targets -- -D warnings`: 5 findings, all in `host/font.rs`, `host/menu.rs` and `host/panel.rs`, which this PR does not touch; the same on `main`. No finding in `xmem.rs`. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: none change the 32-bit graphics heap. Many open PRs touch `xmem.rs`; the nearest are #3859 and #2923 (renderer port 1, which this switch stays out of) and #4761 (page mapping in `XMemMapPhysicalPages`). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01KXyvvT4sXPGBobHa74YXgA
The 185 MB heap the game reserves below 4 GiB is one allocation of its
own, committed and write-watched, in place of a placeholder with views
of physical pages; the title's placeholder splits and page mappings
there do nothing. In play on Series X (a 260 s route, 2026-11-30, on
v2026.11.29.05) 54 % of the title's write faults were in that heap:
2,146,303 faults without the switch, 999,423 with it. Seconds with a
frame over 100 ms 71 % -> 51 %, median frame 61 -> 56 ms; fps
15.4 -> 14.9, inside run-to-run noise. Off with renderer port 1 and
under Wine.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KXyvvT4sXPGBobHa74YXgA
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 12:21:36 +00:00
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/4874/head:github-bot/gh-4873'
git switch 'github-bot/gh-4873'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-4873'
git switch 'github-bot/gh-4873'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-4873'
git switch 'github-bot/gh-4873'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-4873'
git switch 'main'
git merge --squash 'github-bot/gh-4873'
git switch 'main'
git merge --ff-only 'github-bot/gh-4873'
git switch 'main'
git merge 'github-bot/gh-4873'
git push origin 'main'
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!4874
No description provided.