perf(memory): restrict registry work to affected ranges #1324

Closed
TibixDev wants to merge 2 commits from upstream-pr/1324 into main
TibixDev commented 2026-10-07 23:36:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-07T23:36:13Z.


Status after review

Awaiting a title profile showing registry cost.

Rechecked the motivation against current main. Host imports now have eager GPU-map observation and later span/lifetime fixes. The microbenchmark with empty host callbacks does not model those costs. The existing two-title review measured only −2.3% to +1.0%, within noise; no new isolated title gain has been established.

This pass removed the artificial downstream dependency: #1345, #1357, #1359 and #1366 now have standalone changes on main and do not require these targeted leases. A rebase of this optimization should follow a title/scene profile showing remaining full-registry work, with real callbacks included. No code push or renewed performance claim here.

What

Limit allocation lookup and mapping updates to the requested range. Host-import lookups lease one containing allocation when the registry is current. Protection and unmap changes prepare only affected fragments, then commit after the host operation succeeds.

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

  • Current-main implementation and outstanding review requirements complete.
  • Isolated title benefit / reference validation established where required.
  • Depends on: none.
  • AI-assisted: yes.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4779773536 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1324). Originally posted by [TibixDev](https://github.com/TibixDev) on 2026-10-07T23:36:13Z. --- ### Status after review **Awaiting a title profile showing registry cost.** Rechecked the motivation against current main. Host imports now have eager GPU-map observation and later span/lifetime fixes. The microbenchmark with empty host callbacks does not model those costs. The existing two-title review measured only −2.3% to +1.0%, within noise; no new isolated title gain has been established. This pass removed the artificial downstream dependency: #1345, #1357, #1359 and #1366 now have standalone changes on main and do not require these targeted leases. A rebase of this optimization should follow a title/scene profile showing remaining full-registry work, with real callbacks included. No code push or renewed performance claim here. ### What Limit allocation lookup and mapping updates to the requested range. Host-import lookups lease one containing allocation when the registry is current. Protection and unmap changes prepare only affected fragments, then commit after the host operation succeeds. ### 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 - [ ] Current-main implementation and outstanding review requirements complete. - [ ] Isolated title benefit / reference validation established where required. - [x] Depends on: none. - [x] AI-assisted: yes.
oneandonlydean commented 2026-10-08 03:26:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-08T03:26:16Z.


Could you measure main against main plus this PR alone, ideally frame time in a title? Perf PRs need before/after numbers for the change itself (#218); the 2,354 → 0.764 ms figure is a component run on the combined fork. The same goes for #1309, #1310, #1315, #1316, #1330 (against main plus #157), #1331, #1334 and #1335: their figures are component or combined-branch runs, or there are none.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6051544896 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1324#issuecomment-6051544896). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-08T03:26:16Z. --- Could you measure main against main plus this PR alone, ideally frame time in a title? Perf PRs need before/after numbers for the change itself (#218); the 2,354 → 0.764 ms figure is a component run on the combined fork. The same goes for #1309, #1310, #1315, #1316, #1330 (against main plus #157), #1331, #1334 and #1335: their figures are component or combined-branch runs, or there are none.
TibixDev commented 2026-10-08 06:05:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-08T06:05:07Z.


Rebased on e9846679 with no production changes.

Measured upstream e9846679 against the same revision plus this PR (1daa7f69). Fedora 44, GCC 16 Release, Ryzen 5 5600, CPU 3. Six processes per variant in ABBA × 3 order. Each process has one warmup and nine timed batches: 128 lookups or 64 mapping updates per batch. No game or build ran during timing.

The same fixture calls RegisteredReadableCovers, Mutation::Protect, and Mutation::Unmap followed by Add. It registers 1, 1,000, or 20,000 disjoint 64-byte ranges. Requests rotate through the registry. Host-operation callbacks are empty, so the figures measure registry work only. Both variants verify permissions, allocation release, and matching result counts.

Ranges Operation Upstream median (µs) PR median (µs) Upstream range PR range
1,000 readable 8.1769 0.0358 7.7434–10.9490 0.0347–0.0625
1,000 protect 28.6280 0.1572 27.8199–51.5058 0.1357–0.2791
1,000 unmap 34.3257 0.1808 32.9848–57.8596 0.1731–0.3402
20,000 readable 508.6185 0.0676 483.5950–651.1650 0.0669–0.1020
20,000 protect 744.2820 0.1814 706.8740–783.7310 0.1781–0.3431
20,000 unmap 1048.7200 0.2327 973.9930–1140.5500 0.2256–0.4195

The one-range case has overlapping timing ranges; no gain is established there. The larger cases show that unrelated registry entries no longer dominate these operations. This does not measure Vulkan import creation or title frame time.

Graphics and guest-memory tests pass, including range boundaries, split mappings, permissions, unrelated leases, address reuse, and failed-host-operation rollback. Contribution checks pass. Windows was not tested. AI-assisted.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6053508383 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1324#issuecomment-6053508383). Originally posted by [TibixDev](https://github.com/TibixDev) on 2026-10-08T06:05:07Z. --- Rebased on `e9846679` with no production changes. Measured upstream `e9846679` against the same revision plus this PR (`1daa7f69`). Fedora 44, GCC 16 Release, Ryzen 5 5600, CPU 3. Six processes per variant in ABBA × 3 order. Each process has one warmup and nine timed batches: 128 lookups or 64 mapping updates per batch. No game or build ran during timing. The same fixture calls `RegisteredReadableCovers`, `Mutation::Protect`, and `Mutation::Unmap` followed by `Add`. It registers 1, 1,000, or 20,000 disjoint 64-byte ranges. Requests rotate through the registry. Host-operation callbacks are empty, so the figures measure registry work only. Both variants verify permissions, allocation release, and matching result counts. | Ranges | Operation | Upstream median (µs) | PR median (µs) | Upstream range | PR range | |---:|---|---:|---:|---:|---:| | 1,000 | readable | 8.1769 | 0.0358 | 7.7434–10.9490 | 0.0347–0.0625 | | 1,000 | protect | 28.6280 | 0.1572 | 27.8199–51.5058 | 0.1357–0.2791 | | 1,000 | unmap | 34.3257 | 0.1808 | 32.9848–57.8596 | 0.1731–0.3402 | | 20,000 | readable | 508.6185 | 0.0676 | 483.5950–651.1650 | 0.0669–0.1020 | | 20,000 | protect | 744.2820 | 0.1814 | 706.8740–783.7310 | 0.1781–0.3431 | | 20,000 | unmap | 1048.7200 | 0.2327 | 973.9930–1140.5500 | 0.2256–0.4195 | The one-range case has overlapping timing ranges; no gain is established there. The larger cases show that unrelated registry entries no longer dominate these operations. This does not measure Vulkan import creation or title frame time. Graphics and guest-memory tests pass, including range boundaries, split mappings, permissions, unrelated leases, address reuse, and failed-host-operation rollback. Contribution checks pass. Windows was not tested. AI-assisted.
oneandonlydean commented 2026-10-09 09:22:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:22:01Z.


I measured this alone in two titles: frame time didn't change beyond run-to-run noise (-2.3 % to +1.0 % across three scenes in one, none in the other). Which title does it speed up?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6078116638 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1324#issuecomment-6078116638). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T09:22:01Z. --- I measured this alone in two titles: frame time didn't change beyond run-to-run noise (-2.3 % to +1.0 % across three scenes in one, none in the other). Which title does it speed up?
popcoder565 commented 2026-10-09 16:07:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T16:07:08Z.


Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head 1daa7f69, merged onto main d70b8998 together with #2039, #2193 and #2247.

  • agc_driver_graphics, which includes this PR's GuestAllocations.cpp checks, passes. It didn't report skipping a case.
  • Full ctest in that build: 512 of 512. That needed two local workarounds in #2193, which doesn't build on Windows (reported there).

No title was run.

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6084618334 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1324#issuecomment-6084618334). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-09T16:07:08Z. --- Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head `1daa7f69`, merged onto `main` d70b8998 together with #2039, #2193 and #2247. - `agc_driver_graphics`, which includes this PR's `GuestAllocations.cpp` checks, passes. It didn't report skipping a case. - Full ctest in that build: 512 of 512. That needed two local workarounds in #2193, which doesn't build on Windows (reported there). No title was run. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
adriadam10 commented 2026-10-09 23:05:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T23:05:14Z.

Review: CHANGES_REQUESTED


Checked on current main: build + ctest green locally (308/308 in the touched components); the new tests need the new API, and I found no logic problems in the registry changes (iterator ranges, Commit(), last computation in Unmap, boundary cases).

  • The open question from @oneandonlydean is still unanswered: his measurements in two titles show frame time unchanged (-2.3 % to +1.0 %, run-to-run noise). The numbers in the description are registry microbenchmarks with empty host callbacks, not before/after numbers for a title (CONTRIBUTING, perf PRs). Please name a title/scene where main vs main + this PR alone shows a measurable difference (frame time or the time spent in these functions in a profile).
  • If there is no measurable gain in a real title, this adds complexity to the registry without a benefit and should be dropped, or reopened when a case shows up.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5476199197 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1324#pullrequestreview-5476199197). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-09T23:05:14Z. **Review:** CHANGES_REQUESTED --- Checked on current `main`: build + ctest green locally (308/308 in the touched components); the new tests need the new API, and I found no logic problems in the registry changes (iterator ranges, `Commit()`, `last` computation in `Unmap`, boundary cases). - The open question from @oneandonlydean is still unanswered: his measurements in two titles show frame time unchanged (-2.3 % to +1.0 %, run-to-run noise). The numbers in the description are registry microbenchmarks with empty host callbacks, not before/after numbers for a title (CONTRIBUTING, perf PRs). Please name a title/scene where `main` vs `main` + this PR alone shows a measurable difference (frame time or the time spent in these functions in a profile). - If there is no measurable gain in a real title, this adds complexity to the registry without a benefit and should be dropped, or reopened when a case shows up.
adriadam10 commented 2026-10-11 08:52:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T08:52:55Z.

Review: CHANGES_REQUESTED


Still open after the last review:

  • Perf PRs need before/after numbers for the change alone in a real title (CONTRIBUTING). @oneandonlydean measured this PR alone in two titles and frame time did not change beyond noise (-2.3 % to +1.0 %). The figures in the description are registry microbenchmarks with empty host callbacks. Please name a title/scene where main vs main + this PR shows a measurable difference (frame time, or time spent in these functions in a profile).
  • The branch now conflicts with main; it needs a rebase (and a rerun of guest_allocations/agc_driver_graphics) once the benefit is shown.

Without a measurable gain in a real title this adds complexity to the registry for no benefit; it can be reopened when a case shows up.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5482648282 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1324#pullrequestreview-5482648282). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T08:52:55Z. **Review:** CHANGES_REQUESTED --- Still open after the last review: - Perf PRs need before/after numbers for the change alone in a real title (CONTRIBUTING). @oneandonlydean measured this PR alone in two titles and frame time did not change beyond noise (-2.3 % to +1.0 %). The figures in the description are registry microbenchmarks with empty host callbacks. Please name a title/scene where `main` vs `main` + this PR shows a measurable difference (frame time, or time spent in these functions in a profile). - The branch now conflicts with `main`; it needs a rebase (and a rerun of `guest_allocations`/`agc_driver_graphics`) once the benefit is shown. Without a measurable gain in a real title this adds complexity to the registry for no benefit; it can be reopened when a case shows up.
TibixDev commented 2026-10-12 04:52:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-12T04:52:06Z.


Review-pass update:

Rechecked the motivation against current main. Host imports now have eager GPU-map observation and later span/lifetime fixes. The microbenchmark with empty host callbacks does not model those costs. The existing two-title review measured only −2.3% to +1.0%, within noise; no new isolated title gain has been established.

This pass removed the artificial downstream dependency: #1345, #1357, #1359 and #1366 now have standalone changes on main and do not require these targeted leases. A rebase of this optimization should follow a title/scene profile showing remaining full-registry work, with real callbacks included. No code push or renewed performance claim here.

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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6117975487 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1324#issuecomment-6117975487). Originally posted by [TibixDev](https://github.com/TibixDev) on 2026-10-12T04:52:06Z. --- Review-pass update: Rechecked the motivation against current main. Host imports now have eager GPU-map observation and later span/lifetime fixes. The microbenchmark with empty host callbacks does not model those costs. The existing two-title review measured only −2.3% to +1.0%, within noise; no new isolated title gain has been established. This pass removed the artificial downstream dependency: #1345, #1357, #1359 and #1366 now have standalone changes on main and do not require these targeted leases. A rebase of this optimization should follow a title/scene profile showing remaining full-registry work, with real callbacks included. No code push or renewed performance claim here. 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.
johnmaia commented 2026-10-12 11:54:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-12T11:54:13Z.


Here is a title profile with registry cost, which this PR was waiting for.

Epic Mickey: Rebrushed (PPSA15657, Unreal Engine 4), first level, on Linux with an RX 7600 (RADV, Mesa 25.2.8, kernel 7.0). Base: main e7c70a2df + #3763, #2904, #425 and #4363, which it needs to reach the level. The level runs at about 3 FPS with the GPU submission thread at 81% CPU.

LBR call stacks of that thread over 40 s:

  • GuestAllocationsAcquire plus freeing the lease is about 37% of the thread.
  • GuestBufferMemory::UploadFinish is about 23%: regions that no registered run covers, so nothing is imported.
  • HostImportFor (from InPlaceDrawInput) is about 13%: mostly runs in state.failed, after 38 imports failed at vkAllocateMemory (-13).

Counters per 5 s: about 2,900 full leases from UploadFinish and 1,900 from HostImportFor. The registry generation did not change once, so none of them was a refresh.

I tried a narrow version of the host-import part only: a lease of the readable ranges adjacent to the address within the import window, which is what importRun reads. When that run is uncovered, or failed or misaligned with no overlapping import, the full lease is skipped. The level goes from about 3.0 to 4.6 FPS, the thread drops to 33%, and GuestAllocationsAcquire leaves the profile. Full ctest is 949/949.

Would you rather rebase this PR's host-import part with these numbers, or should I open the narrow version and link it here? I don't want to duplicate your work.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6123738817 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1324#issuecomment-6123738817). Originally posted by [johnmaia](https://github.com/johnmaia) on 2026-10-12T11:54:13Z. --- Here is a title profile with registry cost, which this PR was waiting for. Epic Mickey: Rebrushed (PPSA15657, Unreal Engine 4), first level, on Linux with an RX 7600 (RADV, Mesa 25.2.8, kernel 7.0). Base: main `e7c70a2df` + #3763, #2904, #425 and #4363, which it needs to reach the level. The level runs at about 3 FPS with the GPU submission thread at 81% CPU. LBR call stacks of that thread over 40 s: - `GuestAllocationsAcquire` plus freeing the lease is about 37% of the thread. - `GuestBufferMemory::UploadFinish` is about 23%: regions that no registered run covers, so nothing is imported. - `HostImportFor` (from `InPlaceDrawInput`) is about 13%: mostly runs in `state.failed`, after 38 imports failed at `vkAllocateMemory` (-13). Counters per 5 s: about 2,900 full leases from `UploadFinish` and 1,900 from `HostImportFor`. The registry generation did not change once, so none of them was a refresh. I tried a narrow version of the host-import part only: a lease of the readable ranges adjacent to the address within the import window, which is what `importRun` reads. When that run is uncovered, or failed or misaligned with no overlapping import, the full lease is skipped. The level goes from about 3.0 to 4.6 FPS, the thread drops to 33%, and `GuestAllocationsAcquire` leaves the profile. Full ctest is 949/949. Would you rather rebase this PR's host-import part with these numbers, or should I open the narrow version and link it here? I don't want to duplicate your work.
MarcZX10 commented 2026-10-12 17:26:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T17:26:11Z.


Issue #4634 now provides the requested title profile for Cyberpunk 2077 (PPSA04029). On main d592d54e after #4321, the title has about 35,000 live 64 KiB mappings and hits the 139 s EngineWatchdog with zero dispatches. Samples show DoMtypeprotect/DoMunmap threads waiting in GuestAllocationsBegin, a lock holder in the range-tree operations under GuestAllocationsProtect, and the main thread later in GuestAllocationsRequireAvailable. The issue also identifies the full-map copy in replaceRange/Protect and begin-based walks in RequireAvailable, Overlaps and Acquire; with #4216, cold runs still trip while warm reaches later shader work. This is title-profile evidence of registry cost, not a measured post-fix performance claim: https://github.com/boykopovar/AnyPS5/issues/4634

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6129222453 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1324#issuecomment-6129222453). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-12T17:26:11Z. --- Issue #4634 now provides the requested title profile for Cyberpunk 2077 (PPSA04029). On main `d592d54e` after #4321, the title has about 35,000 live 64 KiB mappings and hits the 139 s EngineWatchdog with zero dispatches. Samples show `DoMtypeprotect`/`DoMunmap` threads waiting in `GuestAllocationsBegin`, a lock holder in the range-tree operations under `GuestAllocationsProtect`, and the main thread later in `GuestAllocationsRequireAvailable`. The issue also identifies the full-map copy in `replaceRange`/`Protect` and begin-based walks in `RequireAvailable`, `Overlaps` and `Acquire`; with #4216, cold runs still trip while warm reaches later shader work. This is title-profile evidence of registry cost, not a measured post-fix performance claim: https://github.com/boykopovar/AnyPS5/issues/4634
MarcZX10 commented 2026-10-12 17:27:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T17:27:03Z.


Your Epic Mickey profile and isolated 3.0 → 4.6 FPS result are the direct title-level evidence this PR was waiting for. The Cyberpunk profile I linked separately shows another registry bottleneck, but does not establish a post-fix speedup. I would keep this as one focused, current-main host-import optimization rather than open a second PR that overlaps #1324; the broader registry work still needs its own measured benefit. If you publish the exact narrow branch or commit, it can be reviewed against this PR’s head and the current base without duplicating it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6129235955 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1324#issuecomment-6129235955). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-12T17:27:03Z. --- Your Epic Mickey profile and isolated 3.0 → 4.6 FPS result are the direct title-level evidence this PR was waiting for. The Cyberpunk profile I linked separately shows another registry bottleneck, but does not establish a post-fix speedup. I would keep this as one focused, current-main host-import optimization rather than open a second PR that overlaps #1324; the broader registry work still needs its own measured benefit. If you publish the exact narrow branch or commit, it can be reviewed against this PR’s head and the current base without duplicating it.
johnmaia commented 2026-10-12 23:26:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-12T23:26:29Z.


Thanks. Here is the narrow change as a branch, without a separate PR:

  • Branch: johnmaia/AnyPS5 perf/import-lease-around-main, one commit, e9ffb2eda, on main 90c683946.
  • What it does: GuestAllocationsAcquireAround leases only the readable ranges next to the one holding an address, within the import window. That is all importRun reads. HostImportFor and UploadFinish use it to decide that an import is refused before taking the full registry lease: the run is uncovered, or it is misaligned or failed and overlaps no import.
  • Diff: GuestBufferMemory.cpp +20/-1, GuestAllocations.hpp/.cpp +21, and a test in core/libs/tests/GuestMemory.cpp (CheckAcquireAroundFollowsTheRun) +32.
  • Tests: all 994 ctests pass at e9ffb2eda on Linux with an RX 7600 (RADV, Mesa 25.2.8).
  • Measurement: the 3.0 to 4.6 FPS figure in my earlier comment was taken with the same change on main e7c70a2df. I haven't measured it again on this base.

It touches the same lookups as this PR, so it can sit on top of it or replace part of it, whichever you prefer. I'm glad to rebase it onto this PR's head.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6134563134 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1324#issuecomment-6134563134). Originally posted by [johnmaia](https://github.com/johnmaia) on 2026-10-12T23:26:29Z. --- Thanks. Here is the narrow change as a branch, without a separate PR: - **Branch:** [johnmaia/AnyPS5 `perf/import-lease-around-main`](https://github.com/johnmaia/AnyPS5/tree/perf/import-lease-around-main), one commit, [`e9ffb2eda`](https://github.com/johnmaia/AnyPS5/commit/e9ffb2eda), on main `90c683946`. - **What it does:** `GuestAllocationsAcquireAround` leases only the readable ranges next to the one holding an address, within the import window. That is all `importRun` reads. `HostImportFor` and `UploadFinish` use it to decide that an import is refused before taking the full registry lease: the run is uncovered, or it is misaligned or failed and overlaps no import. - **Diff:** `GuestBufferMemory.cpp` +20/-1, `GuestAllocations.hpp/.cpp` +21, and a test in `core/libs/tests/GuestMemory.cpp` (`CheckAcquireAroundFollowsTheRun`) +32. - **Tests:** all 994 ctests pass at `e9ffb2eda` on Linux with an RX 7600 (RADV, Mesa 25.2.8). - **Measurement:** the 3.0 to 4.6 FPS figure in my earlier comment was taken with the same change on main `e7c70a2df`. I haven't measured it again on this base. It touches the same lookups as this PR, so it can sit on top of it or replace part of it, whichever you prefer. I'm glad to rebase it onto this PR's head.
MarcZX10 commented 2026-10-13 07:27:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T07:27:32Z.


Issue #4634 adds a Cyberpunk 2077 title trace relevant to this PR: with about 35,000 live 64 KiB mappings, sampled sceKernelBatchMap2 threads spend time in GuestAllocationsRequireAvailable / GuestAllocationsOverlaps tree walks, GuestAllocationsAcquire range copying, and GuestAllocationsProtect range replacement. The report is stack-sample evidence, not an isolated per-function profile or measured benefit, so I am not treating it as satisfying the current profile gate. It may help target the next profiling pass: https://github.com/boykopovar/AnyPS5/issues/4634.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6140552034 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1324#issuecomment-6140552034). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T07:27:32Z. --- Issue #4634 adds a Cyberpunk 2077 title trace relevant to this PR: with about 35,000 live 64 KiB mappings, sampled `sceKernelBatchMap2` threads spend time in `GuestAllocationsRequireAvailable` / `GuestAllocationsOverlaps` tree walks, `GuestAllocationsAcquire` range copying, and `GuestAllocationsProtect` range replacement. The report is stack-sample evidence, not an isolated per-function profile or measured benefit, so I am not treating it as satisfying the current profile gate. It may help target the next profiling pass: https://github.com/boykopovar/AnyPS5/issues/4634.
oneandonlydean commented 2026-10-14 05:16:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T05:16:42Z.


@MarcZX100 your Cyberpunk 2077 trace in #4634 (about 35,000 live mappings, time in the registry tree walks) is the title need this PR was missing. It conflicts with main now and adriadam10's two reviews are still open; would you carry it (rebase plus his points), with TibixDev credited?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6161462361 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1324#issuecomment-6161462361). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T05:16:42Z. --- @MarcZX100 your Cyberpunk 2077 trace in #4634 (about 35,000 live mappings, time in the registry tree walks) is the title need this PR was missing. It conflicts with main now and adriadam10's two reviews are still open; would you carry it (rebase plus his points), with TibixDev credited?
nikowolf123 commented 2026-10-14 17:12:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-14T17:12:51Z.


Gap table for this PR against current main (e34c47921), since @oneandonlydean asked @MarcZX100 to carry it. The branch conflicts with main in all four files, and most of its registry half has already landed through #4216:

#1324 hunk On main e34c47921
Covers starts at upper_bound landed in #4216 (L386-L388)
replaceRange stops copying the whole map; Protect/Unmap commit only the replaced fragments landed in #4216 as RangePatch/applyPatch (L433-L472)
Unmap's last check scans only the allocation landed in #4216 as allocationRemains (L474-L485)
RequireAvailable starts at upper_bound left: still walks from begin() (L358-L369)
Overlaps (not in this PR) left: the same walk from begin() (L371-L379)
GuestAllocationsAcquireRange and its use in HostImportFor, RegisteredReadableCovers and UploadFinish left, but main moved under it. #4698 shares one lease snapshot until the registry changes (L534-L543), #4216 added GuestAllocationsLookup, and GuestBufferMemory.cpp has changed a lot. @johnmaia's GuestAllocationsAcquireAround is the measured version of this part.

That leaves two independent changes, each with its own title:

  • (a) the two walks. RequireAvailable and Overlaps start at the range before the address, as Covers and RequireUnpinned already do. DoMapDirect runs both, under the registry lock, for a fixed mapping outside registered ranges (ReplaceFixedOverlap). DoMunmap runs Overlaps for every unmap (L1088). With #4216 applied, @snoozedDev's samples in #4634 still show these two walks under DoMapDirect (Cyberpunk 2077, PPSA04029). No new export, and no lease or pin change.
  • (b) the host-import lease: johnmaia's AcquireAround (Epic Mickey: Rebrushed, PPSA15657, 3.0 to 4.6 FPS, measured on e7c70a2df). His branch is now at 8ba2d5b9a, with the same diffstat as the e9ffb2eda he posted, and against e34c47921 it conflicts only in GuestBufferMemory.cpp. It changes which ranges HostImportFor and UploadFinish lease, and RequireUnpinned waits on leases, so it needs a separate review from (a).

@MarcZX100 @johnmaia, who takes which part? johnmaia's branch already is (b). If neither of you wants (a), I can open it as its own PR crediting @TibixDev, since the RequireAvailable hunk is his. It is one commit on a453108cf that merges cleanly into e34c47921: nikowolf123/AnyPS5 help/S3-registry-walks (b3f7b2c3c). It adds two tests to guest_memory:

  • An edge test: a range that ends at the address, one that starts at its end, a containing range, and a previous range that misses while the next one overlaps.
  • A Linux check that the cost of the two calls doesn't grow with the ranges below them. It fails on main and passes with (a). With 32,768 ranges below, the cost is 32-39 times the cost with 1,024 on main and 2.5-3.0 times with (a); the limit is 8.

Component numbers only, main against (a):

35,000 live 64 KiB ranges; Ubuntu 26.04 on WSL2, GCC 15.2, Release, i9-14900KF main (a)
35,000 fixed 64 KiB sceKernelMapDirectMemory calls in address order, total (2 runs) 5.35 s, 5.52 s 0.143 s, 0.136 s
per call over the last 5,000 of them 301 µs, 308 µs 4.5 µs, 4.2 µs
sceKernelMunmap of all 35,000 in random order, total 3.13 s, 3.19 s 0.196 s, 0.167 s
Overlaps + RequireAvailable just above 35,000 registered ranges, registry alone (median of 6) 214 µs 0.08 µs

The registry-alone row on native Windows 11 (WinLibs GCC 15.2, pinned to logical CPUs 8-11) is 338 µs against 0.05 µs. The mapping rows come from a throwaway mode of guest_memory_tests that is not in the commit. It maps CPU-only memory without the AGC driver, so it leaves out the GPU-map observer.

None of this shows that (a) gets Cyberpunk past the watchdog. Two full-registry copies that #4634 sampled are in neither part:

  • GuestAllocationsAcquire in the pin waiter WaitForLeasesAndImports (GuestBufferMemory.cpp#L1890).
  • GuestAllocationsAcquire in ImportMappedRanges (L2336-L2341). GuestAllocationsEnd reaches it after every GPU mapping while host imports are on.

Every mutation drops #4698's shared snapshot, so neither copy is avoided while the title keeps mapping. The #4634 runs were also on d592d54e, without #4698 and with #4216 only cherry-picked. @snoozedDev, if you have time, could you do cold runs of current main and of main + (a), and post the watchdog time or how far each gets? That would be the title number this PR's reviews ask for.

AI-assisted: written with Claude Code; I checked this PR's diff hunk by hunk against main e34c47921, the history of GuestAllocations.cpp (#4216, #4698), johnmaia's branch, the callers in DirectMemory.cpp and GuestBufferMemory.cpp, and #4634. I ran git merge-tree of this PR, of johnmaia's branch and of (a) against e34c47921. On a Linux (WSL) build I ran guest_memory with main's GuestAllocations.cpp, where the new scaling check fails, and with (a), where it passes 20 of 20 repeats, plus a randomized check of both walks against a brute-force overlap model (about 1.2 million queries each on main and on (a), no mismatch). I also ran the 908 guest_*/agc_* ctests with (a) on lavapipe (0 failed, 40 skipped), tools/check_conventions.py, and the benchmarks above, Linux and native Windows. I did not run any title.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6173997231 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1324#issuecomment-6173997231). Originally posted by [nikowolf123](https://github.com/nikowolf123) on 2026-10-14T17:12:51Z. --- Gap table for this PR against current `main` (`e34c47921`), since @oneandonlydean [asked](https://github.com/boykopovar/AnyPS5/pull/1324#issuecomment-6161462361) @MarcZX100 to carry it. The branch conflicts with `main` in all four files, and most of its registry half has already landed through #4216: | #1324 hunk | On `main` `e34c47921` | |---|---| | `Covers` starts at `upper_bound` | landed in #4216 ([L386-L388](https://github.com/boykopovar/AnyPS5/blob/e34c479210c78d7b160d7054f3e72de422b23d7a/core/libs/prx/libc/src/GuestAllocations.cpp#L386-L388)) | | `replaceRange` stops copying the whole map; `Protect`/`Unmap` commit only the replaced fragments | landed in #4216 as `RangePatch`/`applyPatch` ([L433-L472](https://github.com/boykopovar/AnyPS5/blob/e34c479210c78d7b160d7054f3e72de422b23d7a/core/libs/prx/libc/src/GuestAllocations.cpp#L433-L472)) | | `Unmap`'s `last` check scans only the allocation | landed in #4216 as `allocationRemains` ([L474-L485](https://github.com/boykopovar/AnyPS5/blob/e34c479210c78d7b160d7054f3e72de422b23d7a/core/libs/prx/libc/src/GuestAllocations.cpp#L474-L485)) | | `RequireAvailable` starts at `upper_bound` | **left**: still walks from `begin()` ([L358-L369](https://github.com/boykopovar/AnyPS5/blob/e34c479210c78d7b160d7054f3e72de422b23d7a/core/libs/prx/libc/src/GuestAllocations.cpp#L358-L369)) | | `Overlaps` (not in this PR) | **left**: the same walk from `begin()` ([L371-L379](https://github.com/boykopovar/AnyPS5/blob/e34c479210c78d7b160d7054f3e72de422b23d7a/core/libs/prx/libc/src/GuestAllocations.cpp#L371-L379)) | | `GuestAllocationsAcquireRange` and its use in `HostImportFor`, `RegisteredReadableCovers` and `UploadFinish` | **left**, but `main` moved under it. #4698 shares one lease snapshot until the registry changes ([L534-L543](https://github.com/boykopovar/AnyPS5/blob/e34c479210c78d7b160d7054f3e72de422b23d7a/core/libs/prx/libc/src/GuestAllocations.cpp#L534-L543)), #4216 added `GuestAllocationsLookup`, and `GuestBufferMemory.cpp` has changed a lot. @johnmaia's `GuestAllocationsAcquireAround` is the measured version of this part. | That leaves two independent changes, each with its own title: - **(a) the two walks.** `RequireAvailable` and `Overlaps` start at the range before the address, as `Covers` and `RequireUnpinned` already do. `DoMapDirect` runs both, under the registry lock, for a fixed mapping outside registered ranges ([`ReplaceFixedOverlap`](https://github.com/boykopovar/AnyPS5/blob/e34c479210c78d7b160d7054f3e72de422b23d7a/core/libs/prx/libkernel/DirectMemory/DirectMemory.cpp#L852-L857)). `DoMunmap` runs `Overlaps` for every unmap ([L1088](https://github.com/boykopovar/AnyPS5/blob/e34c479210c78d7b160d7054f3e72de422b23d7a/core/libs/prx/libkernel/DirectMemory/DirectMemory.cpp#L1088)). With #4216 applied, @snoozedDev's samples in #4634 still show these two walks under `DoMapDirect` (Cyberpunk 2077, PPSA04029). No new export, and no lease or pin change. - **(b) the host-import lease**: johnmaia's `AcquireAround` (Epic Mickey: Rebrushed, PPSA15657, 3.0 to 4.6 FPS, measured on `e7c70a2df`). His branch is now at [`8ba2d5b9a`](https://github.com/johnmaia/AnyPS5/commit/8ba2d5b9ac35ce46f7ad18c87263ec0ed80efa4b), with the same diffstat as the `e9ffb2eda` he [posted](https://github.com/boykopovar/AnyPS5/pull/1324#issuecomment-6134563134), and against `e34c47921` it conflicts only in `GuestBufferMemory.cpp`. It changes which ranges `HostImportFor` and `UploadFinish` lease, and `RequireUnpinned` waits on leases, so it needs a separate review from (a). @MarcZX100 @johnmaia, who takes which part? johnmaia's branch already is (b). If neither of you wants (a), I can open it as its own PR crediting @TibixDev, since the `RequireAvailable` hunk is his. It is one commit on `a453108cf` that merges cleanly into `e34c47921`: [nikowolf123/AnyPS5 `help/S3-registry-walks`](https://github.com/nikowolf123/AnyPS5/commits/help/S3-registry-walks) (`b3f7b2c3c`). It adds two tests to `guest_memory`: - An edge test: a range that ends at the address, one that starts at its end, a containing range, and a previous range that misses while the next one overlaps. - A Linux check that the cost of the two calls doesn't grow with the ranges below them. It fails on `main` and passes with (a). With 32,768 ranges below, the cost is 32-39 times the cost with 1,024 on `main` and 2.5-3.0 times with (a); the limit is 8. Component numbers only, `main` against (a): | 35,000 live 64 KiB ranges; Ubuntu 26.04 on WSL2, GCC 15.2, Release, i9-14900KF | `main` | (a) | |---|---|---| | 35,000 fixed 64 KiB `sceKernelMapDirectMemory` calls in address order, total (2 runs) | 5.35 s, 5.52 s | 0.143 s, 0.136 s | | per call over the last 5,000 of them | 301 µs, 308 µs | 4.5 µs, 4.2 µs | | `sceKernelMunmap` of all 35,000 in random order, total | 3.13 s, 3.19 s | 0.196 s, 0.167 s | | `Overlaps` + `RequireAvailable` just above 35,000 registered ranges, registry alone (median of 6) | 214 µs | 0.08 µs | The registry-alone row on native Windows 11 (WinLibs GCC 15.2, pinned to logical CPUs 8-11) is 338 µs against 0.05 µs. The mapping rows come from a throwaway mode of `guest_memory_tests` that is not in the commit. It maps CPU-only memory without the AGC driver, so it leaves out the GPU-map observer. None of this shows that (a) gets Cyberpunk past the watchdog. Two full-registry copies that #4634 sampled are in neither part: - `GuestAllocationsAcquire` in the pin waiter `WaitForLeasesAndImports` ([GuestBufferMemory.cpp#L1890](https://github.com/boykopovar/AnyPS5/blob/e34c479210c78d7b160d7054f3e72de422b23d7a/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp#L1890)). - `GuestAllocationsAcquire` in `ImportMappedRanges` ([L2336-L2341](https://github.com/boykopovar/AnyPS5/blob/e34c479210c78d7b160d7054f3e72de422b23d7a/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp#L2336-L2341)). `GuestAllocationsEnd` reaches it after every GPU mapping while host imports are on. Every mutation drops #4698's shared snapshot, so neither copy is avoided while the title keeps mapping. The #4634 runs were also on `d592d54e`, without #4698 and with #4216 only cherry-picked. @snoozedDev, if you have time, could you do cold runs of current `main` and of `main` + (a), and post the watchdog time or how far each gets? That would be the title number this PR's reviews ask for. AI-assisted: written with Claude Code; I checked this PR's diff hunk by hunk against `main` `e34c47921`, the history of `GuestAllocations.cpp` (#4216, #4698), johnmaia's branch, the callers in `DirectMemory.cpp` and `GuestBufferMemory.cpp`, and #4634. I ran `git merge-tree` of this PR, of johnmaia's branch and of (a) against `e34c47921`. On a Linux (WSL) build I ran `guest_memory` with `main`'s `GuestAllocations.cpp`, where the new scaling check fails, and with (a), where it passes 20 of 20 repeats, plus a randomized check of both walks against a brute-force overlap model (about 1.2 million queries each on `main` and on (a), no mismatch). I also ran the 908 `guest_*`/`agc_*` ctests with (a) on lavapipe (0 failed, 40 skipped), `tools/check_conventions.py`, and the benchmarks above, Linux and native Windows. I did not run any title.
oneandonlydean commented 2026-10-14 18:01:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T18:01:52Z.


@nikowolf123 yes, please open (a) as its own PR crediting @TibixDev; (b) stays with @johnmaia's branch. Once both are open this one can close.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6174925104 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1324#issuecomment-6174925104). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T18:01:52Z. --- @nikowolf123 yes, please open (a) as its own PR crediting @TibixDev; (b) stays with @johnmaia's branch. Once both are open this one can close.
snoozedDev commented 2026-10-14 22:44:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by snoozedDev on 2026-10-14T22:44:15Z.


@nikowolf123 Cyberpunk 2077 (PPSA04029), Linux, RTX 3090, NVIDIA 610.57.04, three cold runs and one warm run each on main 799982fac (with #4216 and #4698) and on main + (a) (b3f7b2c3c cherry-picked, no conflict; guest_memory passes on Linux):

cold 1 cold 2 cold 3 warm
main watchdog, 431 s watchdog, 446 s first presentation, 491 s first presentation, 205 s
main + (a) watchdog, 161 s first presentation, 348 s first presentation, 333 s first presentation, 165 s

"watchdog" is !!! EngineWatchdog timeout!; "first presentation" is the title's next stop on main, a storage-image format refusal (#6119), which both trees reach with the same shader and exception text. Three runs per tree do not separate 2 of 3 from 1 of 3. On bare main the sceKernelBatchMap2 threads were sampled in RequireAvailable, in Overlaps (from ReplaceFixedOverlap and from DoMunmap) and in Acquire (from WaitForLeasesAndImports and from ImportMappedRanges); with (a) only in the two Acquire copies, and the one watchdog trip with (a) had no registry frame in its 150 s sample. Samples and run details in #4634.

AI-assisted: yes (Claude Code, Claude Fable 5.1), operating under my supervision; I am accountable for this comment and will respond to review.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6180158132 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1324#issuecomment-6180158132). Originally posted by [snoozedDev](https://github.com/snoozedDev) on 2026-10-14T22:44:15Z. --- @nikowolf123 Cyberpunk 2077 (PPSA04029), Linux, RTX 3090, NVIDIA 610.57.04, three cold runs and one warm run each on `main` 799982fac (with #4216 and #4698) and on `main` + (a) (b3f7b2c3c cherry-picked, no conflict; `guest_memory` passes on Linux): | | cold 1 | cold 2 | cold 3 | warm | |---|---|---|---|---| | `main` | watchdog, 431 s | watchdog, 446 s | first presentation, 491 s | first presentation, 205 s | | `main` + (a) | watchdog, 161 s | first presentation, 348 s | first presentation, 333 s | first presentation, 165 s | "watchdog" is `!!! EngineWatchdog timeout!`; "first presentation" is the title's next stop on `main`, a storage-image format refusal (#6119), which both trees reach with the same shader and exception text. Three runs per tree do not separate 2 of 3 from 1 of 3. On bare `main` the `sceKernelBatchMap2` threads were sampled in `RequireAvailable`, in `Overlaps` (from `ReplaceFixedOverlap` and from `DoMunmap`) and in `Acquire` (from `WaitForLeasesAndImports` and from `ImportMappedRanges`); with (a) only in the two `Acquire` copies, and the one watchdog trip with (a) had no registry frame in its 150 s sample. Samples and run details in #4634. AI-assisted: yes (Claude Code, Claude Fable 5.1), operating under my supervision; I am accountable for this comment and will respond to review.
github-actions[bot] commented 2026-10-15 12:05:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:05:27Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1191 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 1835 core/libs/prx/libc/src/GuestAllocations.cpp
PR 2434 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 4448 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 4449 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 5021 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libc/include/GuestAllocations.hpp
core/libs/prx/libc/src/GuestAllocations.cpp
PR 5372 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6146 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6177 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/GuestAllocations.cpp
PR 6182 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6185 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6186 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6197 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6292 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6321 core/libs/prx/libc/src/GuestAllocations.cpp
PR 6481 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6548 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6565 core/libs/prx/libc/src/GuestAllocations.cpp
PR 6615 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6636 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6682 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6879 core/libs/prx/libc/src/GuestAllocations.cpp
PR 6913 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6918 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6921 core/libs/prx/libSceAgcDriver/tests/GuestAllocations.cpp
PR 6947 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6951 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libc/include/GuestAllocations.hpp
PR 7082 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7154 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7201 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libc/src/GuestAllocations.cpp
PR 7233 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7261 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7292 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7371 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7446 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7457 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7465 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7466 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7473 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7514 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7618 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7622 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7629 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7647 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7717 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7844 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7849 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7919 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7961 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 8016 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 8091 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 8104 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 8126 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 8336 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 8380 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 8527 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191627880 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1324#issuecomment-6191627880). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:05:27Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 1191](https://www.github.com/boykopovar/AnyPS5/pull/1191) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 1835](https://www.github.com/boykopovar/AnyPS5/pull/1835) | `core/libs/prx/libc/src/GuestAllocations.cpp` | | [PR 2434](https://www.github.com/boykopovar/AnyPS5/pull/2434) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 4448](https://www.github.com/boykopovar/AnyPS5/pull/4448) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 4449](https://www.github.com/boykopovar/AnyPS5/pull/4449) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp`<br>`core/libs/prx/libc/include/GuestAllocations.hpp`<br>`core/libs/prx/libc/src/GuestAllocations.cpp` | | [PR 5372](https://www.github.com/boykopovar/AnyPS5/pull/5372) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6146](https://www.github.com/boykopovar/AnyPS5/pull/6146) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6177](https://www.github.com/boykopovar/AnyPS5/pull/6177) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/GuestAllocations.cpp` | | [PR 6182](https://www.github.com/boykopovar/AnyPS5/pull/6182) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6185](https://www.github.com/boykopovar/AnyPS5/pull/6185) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6186](https://www.github.com/boykopovar/AnyPS5/pull/6186) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6197](https://www.github.com/boykopovar/AnyPS5/pull/6197) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6292](https://www.github.com/boykopovar/AnyPS5/pull/6292) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6321](https://www.github.com/boykopovar/AnyPS5/pull/6321) | `core/libs/prx/libc/src/GuestAllocations.cpp` | | [PR 6481](https://www.github.com/boykopovar/AnyPS5/pull/6481) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6548](https://www.github.com/boykopovar/AnyPS5/pull/6548) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6565](https://www.github.com/boykopovar/AnyPS5/pull/6565) | `core/libs/prx/libc/src/GuestAllocations.cpp` | | [PR 6615](https://www.github.com/boykopovar/AnyPS5/pull/6615) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6636](https://www.github.com/boykopovar/AnyPS5/pull/6636) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6682](https://www.github.com/boykopovar/AnyPS5/pull/6682) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6879](https://www.github.com/boykopovar/AnyPS5/pull/6879) | `core/libs/prx/libc/src/GuestAllocations.cpp` | | [PR 6913](https://www.github.com/boykopovar/AnyPS5/pull/6913) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6918](https://www.github.com/boykopovar/AnyPS5/pull/6918) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6921](https://www.github.com/boykopovar/AnyPS5/pull/6921) | `core/libs/prx/libSceAgcDriver/tests/GuestAllocations.cpp` | | [PR 6947](https://www.github.com/boykopovar/AnyPS5/pull/6947) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6951](https://www.github.com/boykopovar/AnyPS5/pull/6951) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp`<br>`core/libs/prx/libc/include/GuestAllocations.hpp` | | [PR 7082](https://www.github.com/boykopovar/AnyPS5/pull/7082) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7154](https://www.github.com/boykopovar/AnyPS5/pull/7154) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp`<br>`core/libs/prx/libc/src/GuestAllocations.cpp` | | [PR 7233](https://www.github.com/boykopovar/AnyPS5/pull/7233) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7261](https://www.github.com/boykopovar/AnyPS5/pull/7261) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7292](https://www.github.com/boykopovar/AnyPS5/pull/7292) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7371](https://www.github.com/boykopovar/AnyPS5/pull/7371) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7446](https://www.github.com/boykopovar/AnyPS5/pull/7446) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7457](https://www.github.com/boykopovar/AnyPS5/pull/7457) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7465](https://www.github.com/boykopovar/AnyPS5/pull/7465) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7466](https://www.github.com/boykopovar/AnyPS5/pull/7466) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7473](https://www.github.com/boykopovar/AnyPS5/pull/7473) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7514](https://www.github.com/boykopovar/AnyPS5/pull/7514) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7618](https://www.github.com/boykopovar/AnyPS5/pull/7618) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7622](https://www.github.com/boykopovar/AnyPS5/pull/7622) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7629](https://www.github.com/boykopovar/AnyPS5/pull/7629) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7642](https://www.github.com/boykopovar/AnyPS5/pull/7642) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7647](https://www.github.com/boykopovar/AnyPS5/pull/7647) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7717](https://www.github.com/boykopovar/AnyPS5/pull/7717) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7844](https://www.github.com/boykopovar/AnyPS5/pull/7844) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7849](https://www.github.com/boykopovar/AnyPS5/pull/7849) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7919](https://www.github.com/boykopovar/AnyPS5/pull/7919) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7961](https://www.github.com/boykopovar/AnyPS5/pull/7961) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 8016](https://www.github.com/boykopovar/AnyPS5/pull/8016) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 8091](https://www.github.com/boykopovar/AnyPS5/pull/8091) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 8104](https://www.github.com/boykopovar/AnyPS5/pull/8104) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 8126](https://www.github.com/boykopovar/AnyPS5/pull/8126) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 8336](https://www.github.com/boykopovar/AnyPS5/pull/8336) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 8380](https://www.github.com/boykopovar/AnyPS5/pull/8380) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 8527](https://www.github.com/boykopovar/AnyPS5/pull/8527) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` |
whamre commented 2026-10-20 13:15:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by whamre on 2026-10-20T13:15:43Z.


A title profile with registry cost, as asked for in the status above. SILENT HILL: The Short Message (PPSA10112), Windows 11 (26300), RTX 2080 SUPER, NVIDIA 616.92, WinLibs GCC 15.2.0, Release, main 1edbe4b5e + #8265.

While the title loads its first scene, it changes the registry 1,800–2,800 times per 10 s (a local counter on GuestAllocationsEnd; mostly 64 KiB mappings). Every change moves the generation, so the next address-based build rebuilds the cached address space. Each rebuild calls refreshImports, which walks every import, then importAllocation once per import. A local timer around both, per rebuild, over one run (10 s intervals):

Lease ranges Live imports Rebuilds / 10 s importAllocation calls refreshImports
4,266 575 33 1.3 ms 0.02 ms
6,186 1,487 17 7.0 ms 0.27 ms
9,594 3,754 244 8.8 ms 3.2 ms
12,781 6,918 177 15.2 ms 5.4 ms
14,147 8,062 91 15.4 ms 6.1 ms

So the work per change grows with the whole registry, not with what changed. On main 43a2abaf7 one run reached 62 ms per rebuild ([address] … imports pass 61722) at 94 rebuilds per 10 s, and the title then sits in loading until Unreal's 120 s render-thread check ends it. That happens in 2 of 3 runs on current main.

As a local experiment (not a PR), I limited refreshImports to imports whose 8 MiB window holds a range that changed between two leases, and let a build reuse the import it took for an unchanged range. That brings the import part from about 11–14 ms to about 6 ms per rebuild over 16 runs. It doesn't end the stall, though: what's left is the per-range walk of the rebuild itself, at 300–500 rebuilds per 10 s. These callbacks and walks are real-title registry work of the kind this PR targets, but in the driver's address-space path rather than in lookup/protect/unmap. I can run a rebased head on this title.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6291731292 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1324#issuecomment-6291731292). Originally posted by [whamre](https://github.com/whamre) on 2026-10-20T13:15:43Z. --- A title profile with registry cost, as asked for in the status above. SILENT HILL: The Short Message (PPSA10112), Windows 11 (26300), RTX 2080 SUPER, NVIDIA 616.92, WinLibs GCC 15.2.0, Release, `main` `1edbe4b5e` + #8265. While the title loads its first scene, it changes the registry 1,800–2,800 times per 10 s (a local counter on `GuestAllocationsEnd`; mostly 64 KiB mappings). Every change moves the generation, so the next address-based build rebuilds the cached address space. Each rebuild calls `refreshImports`, which walks every import, then `importAllocation` once per import. A local timer around both, per rebuild, over one run (10 s intervals): | Lease ranges | Live imports | Rebuilds / 10 s | `importAllocation` calls | `refreshImports` | |---|---|---|---|---| | 4,266 | 575 | 33 | 1.3 ms | 0.02 ms | | 6,186 | 1,487 | 17 | 7.0 ms | 0.27 ms | | 9,594 | 3,754 | 244 | 8.8 ms | 3.2 ms | | 12,781 | 6,918 | 177 | 15.2 ms | 5.4 ms | | 14,147 | 8,062 | 91 | 15.4 ms | 6.1 ms | So the work per change grows with the whole registry, not with what changed. On `main` `43a2abaf7` one run reached 62 ms per rebuild (`[address] … imports pass 61722`) at 94 rebuilds per 10 s, and the title then sits in loading until Unreal's 120 s render-thread check ends it. That happens in 2 of 3 runs on current `main`. As a local experiment (not a PR), I limited `refreshImports` to imports whose 8 MiB window holds a range that changed between two leases, and let a build reuse the import it took for an unchanged range. That brings the import part from about 11–14 ms to about 6 ms per rebuild over 16 runs. It doesn't end the stall, though: what's left is the per-range walk of the rebuild itself, at 300–500 rebuilds per 10 s. These callbacks and walks are real-title registry work of the kind this PR targets, but in the driver's address-space path rather than in lookup/protect/unmap. I can run a rebased head on this title. AI-assisted: yes.
oneandonlydean commented 2026-10-20 17:56:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T17:56:56Z.


Thanks for this. Its registry half has landed via #4216, and the remaining directory walk is in #6321, so this one is covered and now conflicts with main. Closing; thank you for getting it started.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6297545742 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1324#issuecomment-6297545742). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T17:56:56Z. --- Thanks for this. Its registry half has landed via #4216, and the remaining directory walk is in #6321, so this one is covered and now conflicts with main. Closing; thank you for getting it started.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!1324
No description provided.