XMemAllocDefault: big blocks from write-watched memory (VICTORY_ALLOC_WATCHED_KB) #10
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ReTerryDavis--ReVIctory!10
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-10"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@luannzin on GitHub · 2026-12-02 01:29 UTC · original
luannzin:xmem-watched-default-alloc→main· +85 −0 · 1 files · 1 commits · merged 2026-12-04 02:38 UTCWhat this changes
XMemAllocDefaultcan take its big blocks from write-watched virtual memory below 2^40 instead of the host heap. Onlycrates/victory-hle/src/modules/xmem.rschanges, and nothing changes unless the new switch is set.VICTORY_ALLOC_WATCHED_KB=<n>: blocks ofnKiB and more, aligned to 2 MiB at most, come fromXMemVirtualAlloc(reserved and committed, graphics flags), which already asks forMEM_WRITE_WATCHand keeps to the console's address range. Unset or0: every block from the host heap, as before.title_virtual_free, so the notes the GPU side keeps of its memory go with it. Other blocks keep their header and the host heap.Why
The host heap's memory is not write-watched, so a title buffer that lies in it is compared whole wherever a refresh looks for what the CPU wrote. Committed resources take their memory from the title's allocator (
resource.rs,Memory::for_resource), and here that ended inXMemAllocDefault: the log had "a GPU address above 40 bits ... backing=committed" for it.In the first gameplay room of the prologue one such buffer of 21 MB (at
0x16aede50000in one run,0x1caa1020000in the next) was looked at twice a frame: 42 to 44 MB and 11 to 12 ms of the refreshing threads, for 0.15 MB that had changed ("copied from" in the log, and the traffic line). It was the longest refresh of the flushes the submitting thread waits for: about 12 ms of the 16 ms it waited.The comment above the host-heap path already said what to do if such memory came to matter ("Sub-allocate from a reservation below 2^40 if one does"). This takes whole allocations instead of sub-allocating, which is why it starts at a size and is off by default.
Measured
Xeon E5-2680 v4 (14 cores, 28 threads), Radeon RX 7600 8 GB, 16 GB, Windows 10 22H2 with the Agility SDK 1.621, Series S profile, diag build of
925ac0a,-Fast -Stream -SoftPages, standing in the same room, two runs one after the other, per frame:VICTORY_ALLOC_WATCHED_KB=10240xa4e0b0000)The first run is
play-20261201-212215, the secondplay-20261201-213614, both withVICTORY_LEGACY_MUL=dataand the other switches of my preset for this PC. The scene is not the same from run to run, so the frame rate says less than the refresh lines do.Not tested
Checks
cargo clippy -p victory-hle --all-targets --all-features -- --no-deps -D warningspasses. The workspace clippy does not pass onmaintoday on the pinned toolchain (victory-loader,victory-shader,victory-gpu), with or without this change.This touches the same file as #3 but not the same functions (#3 is in the physical page allocations).
🤖 Generated with Claude Code
326b5607c8to5386b892eb