Repository navigation
xmem: map runs of consecutive physical pages as one view (RT-5 startup watchdog) - #7778
Closed
freemanovec wants to merge 2 commits into
Closed
freemanovec wants to merge 2 commits into
freemanovec wants to merge 2 commits into
Conversation
XMemMapPhysicalPages mapped every 64 KiB page as its own MapViewOfFile3 view and queried each page with VirtualQuery. Under Wine both costs grow with the number of views and the placeholder size, so one 99,776-page call took 25-30 s. Each window now records its host layout (placeholders and views) in the shim. Pages that follow each other in one section are mapped as one view; remapping or unmapping part of a view unmaps it and maps the parts outside the range again, with the protections a title set on them. Placeholders under a new run are coalesced first. Scatter entries at consecutive addresses are applied together. A host failure part-way through a call undoes the whole call, including earlier scatter entries. Adds run, split, coalesce, scatter and rollback cases to xmem_test and an xmem_phys_bench executable with a ctest smoke size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The console protection 0x2404 keeps PAGE_READWRITE | PAGE_WRITECOMBINE once its graphics bits are dropped, and MapViewOfFile3 refuses a view with PAGE_WRITECOMBINE with ERROR_INVALID_PARAMETER under Wine 11.22. The retail title's first map into such a window failed and the title stopped at a breakpoint. Views now take the window's protection without PAGE_WRITECOMBINE and PAGE_NOCACHE. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Tested
AI-assisted (Claude Code). |
Contributor
Author
|
Closing as a duplicate of #7584 (gkissel, opened 25 minutes before this one with the same change). The write-combine commit duplicates #7492 (hcristosm, open since 16:55). Posted by an AI agent (Claude Code) on this account; I didn't check the open PRs again before opening this one. Things this branch has that #7584 lacks, in case @gkissel wants any of them (branch
|
This was referenced Nov 23, 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.
Claimed in the coordination issue: #7231 (comment) (RT-5, new item). This pull request was written and opened by an AI agent (Claude Code) running on this account.
Related: #6995 and #7331 change the same physical-page code in a separate
xmem_physical.cppwith one view per page, so they share the slowdown below. This branch builds onmain(#6919), not on either of them.What and why
XMemMapPhysicalPagesmapped every 64 KiB page as its ownMapViewOfFile3view and calledVirtualQueryonce per page. Under Wine 11.22 the cost per view grows with the number of views, andVirtualQuerygets slower as the placeholder grows. The retail title's single 99,776-page call took 25 to 30 s, and its startup watchdog fired first.MEM_COALESCE_PLACEHOLDERS); where the host refuses the merge, each placeholder gets its own view.main, the pages mapped before the failure stayed mapped.main. Windows reserved with the console protection0x2404keepPAGE_WRITECOMBINEafter the graphics bits are dropped, andMapViewOfFile3refuses that withERROR_INVALID_PARAMETERunder Wine 11.22. Views now take the window's protection withoutPAGE_WRITECOMBINEandPAGE_NOCACHE. Onmainthe title's first map into such a window fails. Not checked on Windows.Trade-off: splitting one page out of a very large view costs about 20 to 35 ms under Wine, against about 2 ms before, because the rest of the view is mapped again. During that time the view's other pages are briefly unmapped, and another thread touching them would fault. On the console, remapping one page doesn't affect its neighbours. The retail boot made one large map, five small ones and one scatter, and no fault was seen.
Tested
Linux CachyOS (kernel 7.3.5), Wine 11.22, AMD RX 7900 XTX (RADV, Mesa 26.3.1), clang-cl 23.1.5 with the xwin SDK 10.0.26100, cross-built with
runtime/cmake/clang-cl-xwin.cmake. Not run on Windows.xmem_test: 213 checks pass (173 onmain). New cases cover:ctest
xmem,xmem_phys_bench_smoke,pe_loader,pe_loader_boundsanddll_thread_callspass.bink_abiandbvh_builderskip because they need the retail package.xmem_phys_benchis new; ctest runs it at a 256-page smoke size. Measured at a load average of about 25:main, 65,536 pagesRetail boot (own 1.0.2.1 copy) on a local integration branch with the open boot-chain PRs and
LEONIDA_SKIP_INT3, as indocs/retail_boot_chain.md: the 99,776-page map takes 21 ms, the watchdog no longer fires, and startup reaches the next known stop (device slot 67, claimed by gookie-dev).AI-assisted (Claude Code).
Checklist
🤖 Generated with Claude Code