Repository navigation
Conversation
Integrate upstream PR boykopovar#157 at a1427b8. Query individual VMAs through the kernel and retain the text scan on older kernels. Local validation: graphics, shader-memory and write-tracking tests pass with the ioctl path and with APS5_NO_PROCMAP_QUERY=1. The Skyrim performance capture identified repeated maps parsing as a CPU hotspot. AI-assisted upstream implementation and local integration. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Cache positive kernel mapping queries within registered allocation bounds, invalidated by the allocation generation. Use a bounded per-thread cache and a nonblocking registry description so cache fills never wait behind allocation or unmap work. Keep kernel queries for unregistered memory and APS5_NO_MAPPING_CACHE for comparison. Tested on Linux: agc_driver, agc_driver_graphics, agc_driver_pm4; graphics tests also pass with the cache disabled and with the proc-maps text fallback. Cover protection changes, partial unmaps, address reuse, adjacent unregistered mappings, busy registries and cross-thread invalidation. Written with AI assistance.
1b1fc32 to
ebfe2b7
Compare
|
Rebased on Measured upstream plus #157 ( Fedora 44, GCC 16 Release, Ryzen 5 5600, CPU 3. Six processes per variant, ABBA × 3. Each process has one warmup and nine batches of 4,096 calls to production
Stable sets of 1 and 64 ranges use 96.6% and 93.9% less time. The 128-range cycle exceeds the 64-entry cache and has a 19.9% slower median. Ending a registry mutation before every query forces invalidation; those medians regress by 7.6–10.6%. The unregistered median regresses by 6.7%, with overlapping ranges. These costs are included rather than omitted from the result. Every query returns the expected access result. Driver, graphics, and PM4 tests pass. Graphics tests also pass with the cache disabled and with the text |
|
#157 is in; please rebase to drop its copy (it conflicts in |
adriadam10
left a comment
There was a problem hiding this comment.
Thanks for the measurements. Two things before this can go in:
- Rebase. #157 is merged; as @oneandonlydean asked, rebase onto
mainto drop its copy ofdescribePages(the PR conflicts inGuestMemory.cpp). After that, only the final commit should remain. - Justification. Your own table shows this cache is 7–20 % slower in the invalidated, 128-range and unregistered cases, and #157 alone already removes the slowdown in a real title (see Dean's test on #157: 60 fps held where
mainfell to single digits). Please show a case from a title or a workload where the query cost is still visible after #157 and this cache fixes it; otherwise the regressions outweigh a gain that only appears in stable sets of ≤ 64 ranges. - Staleness. The cache is only invalidated by
GuestAllocationsmutations. A host-sidemprotectinside a registered allocation outside aMutation(your test needs the explicitGuestAllocationsInvalidatecall for it) keeps returning the old permissions. Please state which callers can do that, or drop the cache for them. - Surface.
APS5_NO_MAPPING_CACHEis a new environment knob andGuestAllocationsTryDescribeRange_nid_no_patcha new libc export-style function; keep them only if needed.
adriadam10
left a comment
There was a problem hiding this comment.
Still blocked on the same points from the previous review:
- Rebase. #157 is merged; the PR still carries its copy of
describePagesand conflicts inGuestMemory.cpp. Only the final commit (ebfe2b70b) should remain. - Justification. The measured gains are in stable sets of ≤ 64 ranges; the invalidated, 128-range and unregistered cases are 7–20 % slower, and #157 alone already removes the slowdown in a real title (@oneandonlydean held 60 fps where
maindropped to single digits). Please show a title or workload where the query cost is still visible after #157 and this cache fixes it. Without that the regressions and the extra surface outweigh the gain. - Surface. If it stays, say why
APS5_NO_MAPPING_CACHEand the newGuestAllocationsTryDescribeRange_nid_no_patchexport are needed, and which callers can change permissions inside a registered allocation outside aMutation(the test needs the explicitGuestAllocationsInvalidatecall for that).
Closing as stale later if there is no activity; feel free to reopen rebased with the evidence.
|
Review-pass update: Current There is no new evidence that an extra 64-entry registered-range cache pays for its previously measured 7–20% invalidation/large-set/unregistered regressions. Nor is there a demonstrated need for another disable knob/export. A future version must audit permission changes outside I have updated the PR description to match this status. The PR remains open; the outstanding review requirements are not being marked resolved. AI-assisted audit. |
|
Closing for now: main's page cache (#157) now covers it. With the queue this large we're closing stalled perf PRs that don't show a gain in a title; reopen it with before/after numbers from a title scene (the summary lines from the performance report form) if you pick it up again. |
Status after review
Current page caches overlap the original motivation.
Current
GuestMemory.cppalready caches arena page states, additionally caches the Windows image extent, and registersForgetPageswithGuestAllocationsSetInvalidator_nid_postfix. This changes the baseline substantially beyond the original #157 comparison. The new Skyrim loading sample on main + experimental NGS reports zero OS query calls while servicing tens of thousands of verifies; that is a limited workload observation, not a universal conclusion.There is no new evidence that an extra 64-entry registered-range cache pays for its previously measured 7–20% invalidation/large-set/unregistered regressions. Nor is there a demonstrated need for another disable knob/export. A future version must audit permission changes outside
Mutationagainst the existing invalidation path. #157 is merged; the carried copy is historical and is not an open dependency. No new code push.What
Cache Linux page permissions only inside registered allocation bounds. Keep at most 64 positive results per thread. Mapping generations invalidate them; a busy registry skips the cache fill. Unregistered host memory still uses a kernel query.
Tested
Earlier branch-specific tests and measurements remain in the discussion. They have not been rerun on a redesigned current-main version of this PR. The review audit and shared NGS-assisted title exploration do not establish that this head is merge-ready. No full Linux/Windows platform CI was dispatched in this pass.
Checklist