Repository navigation
xmem: map and unmap contiguous physical pages in runs (RT-671) - #8095
morodirule wants to merge 1 commit into
Conversation
Map each maximal run of consecutive guest pages backed by one section at consecutive offsets with a single MapViewOfFile3 instead of one view per page; bulk unmaps drop whole views the same way. Every page is still recorded individually, so single pages can be remapped or unmapped later (a page inside a run view splits the view around it). A failure part-way leaves the pages before it mapped, as before. Measured under Wine 11.22, xmem_test, 8192 pages in one call: map 570.1 ms (0.070 ms/page) -> 1.8 ms; unmap 542.2 ms -> 0.6 ms. At the reported 0.27 ms/page, 99,776 pages stop tripping the title's watchdog by two orders of magnitude. xmem_test 183/183 under Wine.
|
Tested
AI-assisted (Claude Code). Synthetic test only, no game files. |
|
Closing in favor of #7584, which was opened earlier, measures the real boot (28.6 s for the 99,776-page call), and handles fragmented placeholders (per-placeholder-span views) plus bounded unmap cost (1024-page cap) where mine falls back to per-page mapping. I verified #7584 independently on Arch + Wine 11.22: its xmem_test passes and my 8192-page benchmark harness on its code gives map 0.6 ms / unmap 0.0 ms — confirming the approach, so nothing is lost by closing this one. My synthetic benchmark of the old path (570 ms / 542 ms) stands as the before-figure. Thanks to the Windows tester who ran this branch 3x green. AI-assisted. |
|
Tested
AI-assisted (Claude Code). |
|
Closing in favor of earlier #7584, which covers the same change with a harder-to-verify property I confirmed independently: I built #7584 here (Arch + Wine 11.22, clang-cl 23.1) and its xmem_test passes 186/186, and a temporary 8192-page map/unmap benchmark on #7584's code gives map 0.6 ms / unmap 0.0 ms — same order as my own implementation's 1.8/0.6 ms, and ~4 orders of magnitude under the per-page path (my measured 570/542 ms). #7584 additionally handles fragmented placeholders per-span and caps views at 1024 pages, which my single-REPLACE-plus-fallback does not. The Windows 3x-green run on this PR stands as an extra data point for the approach. AI-assisted. |
Claimed in the coordination issue as RT-671: #7804 (comment) (follow-up claim on #7913: carry-over).
What and why
Under Wine, mapping the title's physical pages one page at a time costs ~0.27 ms per page (found by cynbun); at 99,776 pages that trips the title's own watchdog. Each page went through its own unmap + placeholder-split + MapViewOfFile3.
This batches maximal runs — consecutive guest addresses backed by one section at consecutive offsets — into a single MapViewOfFile3 (and symmetric whole-view unmaps). Every page is still recorded in g_mapped, so single pages keep working: unmapping one page of a run view splits the view and re-maps the surviving siblings. A failure part-way leaves the pages before it mapped, and a range that cannot go through as a whole falls back to per-page mapping with identical errors.
Tested
No game data. AI-assisted.