perf(xmem,resource): add opt-in MEM_WRITE_WATCH for large private allocations #321
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/TaynanGT--Vice-Tay!321
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-321"
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?
@FredDietrich on GitHub · 2026-11-27 16:35 UTC · original
FredDietrich:perf/write-watch-private-allocs→main· +103 −0 · 2 files · 1 commits · merged 2026-11-27 17:49 UTCSummary
Split out from #294 as requested so the two write-watch allocation switches can be measured independently on Windows and Linux/Wine before changing any defaults.
Adds two opt-in switches (both OFF by default):
VICTORY_WATCH_HEAP=1(crates/victory-gpu/src/resource.rs): backs ≥ 64 KiB (align <= 64 KiB)Memory::newallocations withVirtualAlloc(..., MEM_RESERVE | MEM_COMMIT | MEM_WRITE_WATCH, PAGE_READWRITE)instead ofalloc_zeroed, and frees them viatitle_memory_freed+VirtualFreeinDrop.VICTORY_WATCH_XMEM_ALLOC=1(crates/victory-hle/src/modules/xmem.rs): backs ≥ 64 KiB (align <= 64 KiB)XMemAllocDefaultallocations (whenALLOC_32BIT == 0) withVirtualAlloc(..., MEM_WRITE_WATCH)(using a leading 64 KiB page for the[usize::MAX, base]header), and releases them viatitle_memory_freed+VirtualFreeinXMemFreeDefault.Measured Trade-off (Why Opt-In)
diag): In GTA VI, the 21 MB private buffer (+0x1412200, allocated viaXMemAllocDefault) previously fell back tocopied whole (memory not watched)2×/frame (42.09 MB/frame, ~12.5 ms CPU + 21.05 MB GPU upload). Enabling both switches droppedcopied wholefrom 43.3 MB / 13.1 ms → 0.0 MB / 0.0 ms and its upload from 21.05 MB → 0.00 MB, raising steady-state median FPS from 9.00 → 9.80 fps (-9.0 ms/frame).landcopying ~20.6 MB back from the GPU into that buffer re-dirties ~5,100 4 KiB pages every frame (GetWriteWatchdirty pages doubled from ~5,140 → ~10,250/frame), which on Windows can add ~7–14 ms topreparing(81 → 95 mswith steady FPS unchanged). Keeping both switches opt-in allows independent A/B measurement across scenes and platforms.