Repository navigation
perf(victory): physical pages from 2 MiB sections (VICTORY_SECTION_MB, off by default) - #352
Merged
LooperSalty merged 2 commits intoNov 26, 2026
Merged
Conversation
…, off by default) XMemAllocatePhysicalPages made one pagefile-backed section per request (6.1 GiB at once for GTA VI), mapped a 64 KiB view at a time. Windows' large-page rebuild worker walks every view of a section under its lock for each page it trades, so the title's map and unmap calls wait behind it (fxceless/victory-fork#1089). VICTORY_SECTION_MB=2 backs a request with sections of at most 2 MiB; unset or 0 keeps one section per request. GPU side: sections and our own views of them (VICTORY_QUIET_BACK) are kept by handle in maps instead of vectors scanned linearly, a closed section's own view is unmapped at once (title_memory_section_closed), and the census groups sections by size. Synthetic benchmark included (ignored test physical_remap_bench). Source: fxceless/victory-fork#1274 (CuteBooty), idea and first patch from fxceless/victory-fork#1089 (RyanCase94) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
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