perf(agc): cache page permissions within registered allocations #1330
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1330"
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?
Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-07T23:41:15Z.
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
Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-08T06:07:24Z.
Rebased on
e9846679. The #157 prerequisite retains Pacuka's authorship.Measured upstream plus #157 (
5b65345a) against that same baseline plus this PR's final commit (ebfe2b70). Thus both sides usePROCMAP_QUERY.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
GuestMemory::Accessible. Requests rotate across separate registered 4 KiB ranges in one host mapping. The unregistered case uses the same host mapping without registry entries. No game or build ran during timing.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
/proc/self/mapsfallback. These include adjacent unregistered memory, protection changes, partial unmaps, address reuse, a busy registry, and cross-thread invalidation. Contribution checks pass. No title frame time or Windows result is claimed. AI-assisted.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:22:02Z.
#157 is in; please rebase to drop its copy (it conflicts in
GuestMemory.cpp).Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T23:03:06Z.
Review: CHANGES_REQUESTED
Thanks for the measurements. Two things before this can go in:
mainto drop its copy ofdescribePages(the PR conflicts inGuestMemory.cpp). After that, only the final commit should remain.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.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.APS5_NO_MAPPING_CACHEis a new environment knob andGuestAllocationsTryDescribeRange_nid_no_patcha new libc export-style function; keep them only if needed.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T08:53:00Z.
Review: CHANGES_REQUESTED
Still blocked on the same points from the previous review:
describePagesand conflicts inGuestMemory.cpp. Only the final commit (ebfe2b70b) should remain.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.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.
Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-12T04:52:09Z.
Review-pass update:
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.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.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T05:09:21Z.
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.
Pull request closed