The title's map/unmap calls wait for Windows' large-page worker on the one big section; 2 MiB sections remove the wait #1089
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/fxceless--victory-fork#1089
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@RyanCase94 on GitHub · 2026-11-25 19:04 UTC · original
Following on from
d510ee4("the dips while moving, measured"): a kernel trace says what the title's map and unmap calls wait for, and a small change removes the wait without changing how pages are mapped. Patch below; it applies cleanly tomainatd510ee4.What the calls wait for
Setup: RTX 4070 Ti, Ryzen 7 5800X, Windows 11 26200,
--console series-x, the first minutes of the prologue. Anxperftrace (PROC_THREAD+LOADER+CSWITCH+DISPATCHER, stacks onCSwitchandReadyThread) taken while the title streams, read for 4 seconds:ExfAcquirePushLockExclusiveExunderMiPostInsertVad < MiInsertVad < MiMapViewOfDataSection(1.06 s) and underMiManageSubsectionView < MiDeleteVad < MiUnmapVad(1.00 s). So mostly not the address space lock itself but the section's.ExfReleasePushLockShared < MiTrimSection < MiTrimSharedPage < MiTradePage < MiClaimPhysicalRun < MiFindContiguousPagesEx < MiRebuildLargePage < MiRebuildLargePages < ExpWorkerThread.MiViewMayContainPage < MiTrimSection.So: Windows' large-page rebuild worker trades the section's pages one by one. For each page it looks through the section's views and holds the section meanwhile.
XMemAllocatePhysicalPagesmakes one section per request (the title asks for 6.1 GiB at once) and the title maps it a 64 KiB view at a time, so that one section has views by the hundred thousand: every trade is slow and every trade holds all of the title's physical memory.Ruled out on the way, by measurement: the kernel reads of title memory (
VICTORY_COPY_PLAIN=1changed nothing), write-watch askings (none over 1 ms), and crowding of the title's pinned threads (VICTORY_SPREAD=1with all processors spare changed nothing).The change
Sections of 2 MiB instead of one per request (
VICTORY_SECTION_MB, 0 = as before). A trade then looks through a few dozen views and holds one small section. Mapping is otherwise as it was (still one view per run of consecutive pages of one section, somap_aliasstill maps page by page);Views::sectionsbecomes a map because there are now thousands.Measured
First 90 s after reaching the prison, map/unmap system calls of 1 ms or more:
Not shown
d510ee4measures them on the render thread's way in cutscenes, so it may show more there.Patch
@Exopus-0x65f7ad0 on GitHub · 2026-11-25 21:47 UTC · original
Confirmed on a third machine, and in the opening cutscene, where it pays the most: RTX 5060 Ti 8 GB, Ryzen 7 8700F, 16 GB RAM, Windows 11, Series S. Tree: fork
maind510ee4plus a stack of fork PRs (#868, #1031, #1063 among them). I applied your patch unchanged, with the defaultVICTORY_SECTION_MB=2.I summed the frame log's
remapping:field over the long frames from the first 3D frame to the first gameplay frame:What remains in the cutscene's long frames is mostly the submit thread's copies (~11 GB over the cutscene) and page faults. No new defect in the picture: faces through the bar and prison shots look as they did before. One run with the patch so far, so the fps figure is a first reading. The remapping drop, though, is far outside the run-to-run noise.
🤖 Generated with Claude Code
@HLVM04 on GitHub · 2026-11-25 20:34 UTC · original · edited 2026-11-26 01:55 UTC
A data point for two of the "not shown" items: Series S mode, and frame times. RTX 5070 Ti, Ryzen 7 9800X3D, Windows 11 build 26200, first gameplay scene, on our own stack (an older fork main plus several open PRs and local changes).
The patch from this issue, applied alone with the default
VICTORY_SECTION_MB=2:So here the gain is mostly in the long frames, which fits the dips you describe. That's one scene and few runs, and I didn't take a kernel trace, so I can't say how many map/unmap calls still block. On top of it, #868's
VICTORY_SKIP_WC_BACK=1gave a median of 71–72 ms with no crash or device loss in 2 runs of 200 s.Edit (2026-11-26):
VICTORY_SKIP_WC_BACK=1turned out not to be free on our stack: the room's lamp light goes missing and rooms render dark (our earlier runs were judged only by the character). The section-patch numbers above were taken without it.@KainanP on GitHub · 2026-11-26 11:23 UTC · original
A synthetic reproduction of this stall, which needs no game, with numbers on an i7-14650HX: #1274 (comment below the PR). 4 GiB of physical pages in one section, remapped page by page while another thread makes and frees memory, had 1,386 remaps of 1 ms or more in 10 s. With 2 MiB sections that drops to 28, and throughput goes from 6,644 to 50,607 remaps/s (median of 5 rounds). The same change is also proposed for upstream (Marvisak/VIctory#3177) and AnyXboxX (LooperSalty/AnyXboxX#352), with credit to you for the idea and the first patch.
AI use: Claude Code (Claude Opus 5.5) wrote the benchmark and this note.