perf(xmem): add opt-in 2 MiB physical page sections (VICTORY_SECTION_MB) #261
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
needs-logs
old-names
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/TaynanGT--Vice-Tay!261
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-261"
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?
@Vladimir-Human on GitHub · 2026-11-27 12:46 UTC · original
Vladimir-Human:perf/xmem-2m-sections→main· +60109 −5445 · 206 files · 652 commits · closed without mergingSummary
Adds opt-in 2 MiB physical page section splitting (
VICTORY_SECTION_MB=2; default0= single section per allocation on both Windows and Wine so baseline behavior stays unchanged, with Wine always staying on the single-section fallback) to avoid Windows section-lock view-walk stalls during heavy 64 KiB page mapping/unmapping, and upgradesvictory-gpu::inplacesection tracking toBTreeMapso thousands of sections stay O(log N).Changes
crates/victory-hle/src/modules/xmem.rsXMemAllocatePhysicalPagesinto sections of at mostVICTORY_SECTION_MBMiB when explicitly enabled on Windows (opt-in, default0= single section on both Windows and Wine; Wine always stays on the single-section fallback to match Wine'sSEC_COMMITsparse-section path).coalesce()inxmem::mapusingVirtualQueryEx(AllocationBase) +MEM_COALESCE_PLACEHOLDERS+split()so multi-page remappings across adjacent split placeholders (such as partial unmaps straddling a 2 MiB section boundary or earlier scatter-unmapped 64 KiB holes) succeed reliably.section_size_parsing_and_fallback,physical_allocations_split_into_two_mebibyte_sections_with_fallback,os_map_unmap_remap_stress_across_two_mebibyte_sections) plus a release microbenchmark (xmem_section_2m_vs_64k_bench).crates/victory-gpu/src/inplace.rsViews::sectionsandViews::wholefromVectoBTreeMapfor O(log N) lookups and cleanup.v.sectionsintitle_memory_section_gone.census_ofsection summaries by(bytes, committed)and addcensus_groups_sections_and_removes_freed_handles.Upstream Credit
Adapted from
voidopcode/vilocity(0f44a17), building on the Windows section-lock root-cause findings of RyanCase94, CuteBooty, and KainanP.Verification
cargo clippy -p victory-hle -p victory-gpu --all-targets -- -D warnings(default &--features diagnostics): 0 warningscargo test -p victory-hle --features diagnostics --lib modules::xmem -- --test-threads=1: 21/21 passed (default unset) and 21/21 passed (VICTORY_SECTION_MB=2)cargo test -p victory-gpu --features diagnostics --lib inplace::tests -- --test-threads=1(VICTORY_D3D12_DEBUG=1): 9/9 HW passed & 9/9 WARP (VICTORY_D3D12_WARP=1) passed, 0 D3D12 debug errorsxtask policy --staged&cargo test -p xtask(11/11 passed)cargo test --release -p victory-hle --lib xmem_section_2m_vs_64k_bench -- --ignored --nocapture --test-threads=1, 2048 pages = 128 MiB):7.0 ms, 64 x 2 MiB map+unmap14.79 ms(231.1 us/op)0.7 ms, 64 x 2 MiB map+unmap3.60 ms(56.3 us/op)9.89xalloc+free,4.11xmap+unmap@TaynanGT on GitHub · 2026-11-27 12:53 UTC · original
@Vladimir-Human The cross-boundary remap stress test is the useful check for the smaller sections. I’d keep the 2 MiB setting opt-in until we have a matched Windows load and a Wine fallback check. The release allocator benchmark gives the expected lookup and mapping cost on its own.
perf(xmem): split physical page allocations into 2 MiB sectionsto perf(xmem): add opt-in 2 MiB physical page sections (VICTORY_SECTION_MB)8269810b2cto8915099bf7@Vladimir-Human on GitHub · 2026-11-27 13:04 UTC · original
@TaynanGT Updated in
8915099:VICTORY_SECTION_MBis now opt-in (default0= single section per allocation on both Windows and Wine), while Wine unconditionally stays on the single-section fallback even ifVICTORY_SECTION_MBis set.parse_section_mb§ion_size_parsing_and_fallbackverify default unset/0/invalid -> single section, explicitVICTORY_SECTION_MB=2/4on Windows -> 2 MiB / 4 MiB sections, and Wine fallback -> single section.modules::xmem21/21 both with default unset and withVICTORY_SECTION_MB=2(includingos_map_unmap_remap_stress_across_two_mebibyte_sections),inplace::tests9/9 HW & 9/9 WARP,clippy(default &diagnostics) 0 warnings, and releasexmem_section_2m_vs_64k_bench(9.89xalloc+free,4.11xmap+unmap).@TaynanGT on GitHub · 2026-11-27 13:09 UTC · original
@Vladimir-Human The new default matches the existing single-section path. The opt-in and Wine parsing tests cover the compatibility choice, and the cross-boundary remap test covers the Windows mechanism. I’ll keep the allocator microbenchmark separate from the matched game-load comparison.
8915099bf7tocbb87f609dcbb87f609dto14fc1c031d@TaynanGT on GitHub · 2026-11-30 17:14 UTC · original
mainhas moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the currentmainand open a new PR; I'll review it there.Pull request closed