perf(victory): physical pages from 2 MiB sections (VICTORY_SECTION_MB, off by default) #352
No reviewers
Labels
No labels
accessibility
bloqué : binaire console
bug
chargeur
console-dll
cpu
documentation
duplicate
enhancement
good first issue
gpu
help wanted
invalid
performance
question
runtime-gdk
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LooperSalty--AnyXboxX!352
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-352"
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?
@KainanP on GitHub · 2026-11-26 11:23 UTC · original
KainanP:perf/physical-sections-2mib→main· +317 −64 · 4 files · 2 commits · merged 2026-11-26 15:38 UTCChange
VICTORY_SECTION_MB=2backs eachXMemAllocatePhysicalPagesrequest with pagefile-backed sections of at most 2 MiB. Today a request gets one section: 6.1 GiB in a single call for GTA VI. Off by default. Unset or0runs today's code path.The cost being fixed: the title maps that one section a 64 KiB view at a time, so the section carries a very large number of views. Windows' large-page rebuild worker (
MiRebuildLargePages→MiTradePage→MiTrimSection) trades the section's pages one at a time, and for each page it walks the section's views while holding the section's lock. The title's map and unmap calls wait behind it. RyanCase94 found this in a kernel trace (fxceless/victory-fork#1089). The fork measured it in game, always against the fork's own base:remapping:summed over the opening cutscene dropped from 32-65 s to 2.5 s.The median frame did not change in those runs. The gain is in long frames while the world streams, which matches the dips described in the README's known limits.
GPU side (
inplace.rs):sectionsandALIASES(our own views of a title section,VICTORY_QUIET_BACK) are now maps keyed by handle. They used to be vectors scanned linearly, and with 2 MiB sections there are thousands of entries.title_memory_section_closed). Before, it stayed until the handle number came round again. A copy that is still writing through such a view faults and falls back, through the existingwrite_aliashandler.This is a port of fxceless/victory-fork#1274 (CuteBooty), which comes from RyanCase94's patch in #1089. Both are credited in
THIRD_PARTY.mdand in the commit'sSource:line.Linked issue: none (upstream: fxceless/victory-fork#1089; the same change for Marvisak/VIctory is #3177 there).
Verification
Windows 11 26200, i7-14650HX, 32 GB, Rust 1.98.1 MSVC, from
third_party/victory:cargo clippy ... -D warningsstops at an existingredundant_closureinvictory-formats/src/texture.rs, which is also onmain.New test
sections_hold_at_most_the_pages_asked:[33]or[32, 1], with consecutive page numbers.write_physicalstill writes both bytes.XMemMapPhysicalPagesmakes two views. Both bytes are visible through them, and a write through the view lands in the right page.Measured (synthetic, no game)
physical_remap_bench(#[ignore]) goes through the realXMemAllocatePhysicalPagesandXMemMapPhysicalPages. It maps 4 GiB one page per view and touches every page. It then remaps a random page at a random address for 10 s, while another thread makes, touches and frees 2 GiB. It runs 5 rounds per mode, alternating.In rounds where the worker did not run, the two modes measure the same. The roughly 30 slow calls a round that both modes show come from the busy machine, not from the sections. Without the churn thread, 2 MiB sections cost about 8 % per remap (10.0 µs against 9.1 µs median, upstream port).
Not measured: the game. Could you A/B it with the launcher's override,
-Override @{ VICTORY_SECTION_MB = '2' }? Look at the frame log'sremapping:field and the longest frames while driving or in a cutscene, more than the median. If it holds up, it belongs in the tuned set. I left the launcher, its test and the docs unchanged so that this PR stays one behaviour.Checklist
THIRD_PARTY.md.AI use: Claude Code (Claude Opus 5.5) did the port, the benchmark and this description, and ran the checks on my machine. No game files or game data.
🤖 Generated with Claude Code