perf(agc): lease mapped readable runs for import events #9011

Merged
JJenkx merged 2 commits from upstream-pr/9011 into main 2026-10-27 08:05:23 +00:00
JJenkx commented 2026-10-21 09:41:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-21T09:41:43Z.


What

Lease the complete compatible readable runs around newly mapped allocations instead of copying every readable allocation in the process for each map event. Reject stale allocation identities, preserve neighboring run ranges and lease lifetimes, and retain the full-registry snapshot when adopting a device or replacing an existing import. Recheck allocation ownership after taking that full snapshot.

This preserves eager-import policy. #7465 changes that policy by deferring mappings up to 64 KiB; it touches the same function but is a separate change, and either merge order requires resolving that small overlap. No dependency on #7465 or other open PRs. The overlap report and manual review of stale shared-file patches are saved with the evidence.

Tested

Refreshed branch: 623501f36560884b66e16c93a0617d00e266e196 on main b5d763770a8e932b35db9bea1c415e7e0ac50a22. Full runtime/library and focused-test build passed. The same six focused tests listed below passed on both refreshed main and candidate with Vulkan required, shader cache disabled, and the real Khronos validation layer loaded (six layer-load records per arm). No VUIDs, missing-layer warnings or skipped tests in either log. Candidate restored and rebuilt after the pair. Conventions checks pass.

The native performance measurements below are explicitly pinned to earlier main 53a0a27bb61e613638e3764dcdce43a5f85c8baf and topic 993f9f9b5c55b375e217588437d4b75cbaa3a96d. The topic range-diff is identical after refresh; these are not measurements of the refreshed hashes.

Record of Lodoss War PPSA05347 v01.000.001, same forest tutorial, input script, machine, 3840x2160, environment and 200:30-second trace window. Two pairs in opposite orders: main 50.089 / 51.220 FPS; topic 59.840 / 59.940 FPS. All four logs had no GPU fault/reset, dropped trace events or observed compiler overlap. The compiler monitor samples every two seconds, so does not exclude brief unseen activity. Screenshots show the same scene; this does not establish broad gameplay or other-title gains.

Official tools/trace_digest.py summary lines for the first pair:

{"commit":"53a0a27bb61e","dirty":false,"env":{"APS5_DRAW_CACHE_ENTRIES":"4096","APS5_HOST_IMPORT_MIB":"16384","APS5_PAD_INPUT_FILE":"<path>","APS5_PIPELINED_DRAWS":"1","APS5_PIPELINE_DMA":"1","APS5_SPIRV_OPT":"full","APS5_TRACE_EVENTS":"2097152","APS5_TRACE_SECONDS":"200:30"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.4-arch1.1","os":"Linux 7.2.9-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA05347","title":"Record of Lodoss War -Deedlit in Wonder Labyrinth-","content_version":"01.000.001","resolution":"3840x2160","window":{"spec":"seconds 200:30","first_present":11086,"ms":30006.569},"presents":1503,"frame_ms":{"p50":19.162,"p90":24.09,"p99":29.407,"max":37.943},"gpu_busy_ms_per_present":2.622,"worker_busy_pct":{"queue worker 0x0":23.478},"top_phases_ms_per_frame":{"Driver.Packet":4.685,"VideoOut.Flip":1.881,"VideoOut.Flip.present":1.84,"Driver.Present":1.838,"Graphics.Draw":1.826,"Driver.Present.render_fence_wait":1.596,"Vulkan.Retire":1.596,"Vulkan.Retire.wait":1.592},"trace_dropped":false,"trace":"aps5-trace-53a0a27bb61e-473842.json.gz"}
{"commit":"993f9f9b5c55","dirty":false,"env":{"APS5_DRAW_CACHE_ENTRIES":"4096","APS5_HOST_IMPORT_MIB":"16384","APS5_PAD_INPUT_FILE":"<path>","APS5_PIPELINED_DRAWS":"1","APS5_PIPELINE_DMA":"1","APS5_SPIRV_OPT":"full","APS5_TRACE_EVENTS":"2097152","APS5_TRACE_SECONDS":"200:30"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.4-arch1.1","os":"Linux 7.2.9-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA05347","title":"Record of Lodoss War -Deedlit in Wonder Labyrinth-","content_version":"01.000.001","resolution":"3840x2160","window":{"spec":"seconds 200:30","first_present":11406,"ms":30013.32},"presents":1796,"frame_ms":{"p50":16.683,"p90":16.69,"p99":20.236,"max":24.687},"gpu_busy_ms_per_present":2.353,"worker_busy_pct":{"queue worker 0x0":34.341},"top_phases_ms_per_frame":{"VideoOut.Flip":13.511,"VideoOut.Flip.vblank_wait":12.01,"Driver.Packet":5.737,"Graphics.Draw":1.755,"VideoOut.Flip.present":1.471,"Driver.Present":1.469,"Recorder.Sync":1.396,"Graphics.Draw.draw_and_resource_release":1.32},"trace_dropped":false,"trace":"aps5-trace-993f9f9b5c55-385408.json.gz"}

On the pinned measurement revisions, the same six focused tests passed on main and topic: guest_memory, guest_mmap_fixed_anonymous, MemoryPoolTest, agc_host_import_retirement, agc_host_import_unmap, and agc_sparse_run_import. Both logs confirm Khronos validation loaded and contain no VUID errors, skips, or missing-layer warning. Tests use ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. Guest-memory coverage includes neighboring readable runs, permission/GPU boundaries, reversed/duplicate targets, stale owners, removed ranges and retained lease lifetime.

Evidence archive: four raw traces, official digests, screenshots, reports, focused logs and refresh validation. SHA256 70cdb1ea41aa5ff5c1a42c4030c257a9af1c30fce036b169bbd8aec1c1496d4e. Separate directories distinguish native measurements (measured-53a0-993f) from refreshed focused validation (refreshed-b5d763-623501).

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none (performance only; PPSA05347, discussion #6460)
  • GPUs tested: AMD Radeon RX 6650 XT, RADV Mesa 26.2.4-arch1.1, Linux 7.2.9-arch1-1
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4949547220 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9011). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-21T09:41:43Z. --- ### What Lease the complete compatible readable runs around newly mapped allocations instead of copying every readable allocation in the process for each map event. Reject stale allocation identities, preserve neighboring run ranges and lease lifetimes, and retain the full-registry snapshot when adopting a device or replacing an existing import. Recheck allocation ownership after taking that full snapshot. This preserves eager-import policy. #7465 changes that policy by deferring mappings up to 64 KiB; it touches the same function but is a separate change, and either merge order requires resolving that small overlap. No dependency on #7465 or other open PRs. The overlap report and manual review of stale shared-file patches are saved with the evidence. ### Tested Refreshed branch: `623501f36560884b66e16c93a0617d00e266e196` on `main` `b5d763770a8e932b35db9bea1c415e7e0ac50a22`. Full runtime/library and focused-test build passed. The same six focused tests listed below passed on both refreshed main and candidate with Vulkan required, shader cache disabled, and the real Khronos validation layer loaded (six layer-load records per arm). No VUIDs, missing-layer warnings or skipped tests in either log. Candidate restored and rebuilt after the pair. Conventions checks pass. The native performance measurements below are explicitly pinned to earlier main `53a0a27bb61e613638e3764dcdce43a5f85c8baf` and topic `993f9f9b5c55b375e217588437d4b75cbaa3a96d`. The topic range-diff is identical after refresh; these are not measurements of the refreshed hashes. Record of Lodoss War PPSA05347 v01.000.001, same forest tutorial, input script, machine, 3840x2160, environment and 200:30-second trace window. Two pairs in opposite orders: main 50.089 / 51.220 FPS; topic 59.840 / 59.940 FPS. All four logs had no GPU fault/reset, dropped trace events or observed compiler overlap. The compiler monitor samples every two seconds, so does not exclude brief unseen activity. Screenshots show the same scene; this does not establish broad gameplay or other-title gains. Official `tools/trace_digest.py` summary lines for the first pair: ```json {"commit":"53a0a27bb61e","dirty":false,"env":{"APS5_DRAW_CACHE_ENTRIES":"4096","APS5_HOST_IMPORT_MIB":"16384","APS5_PAD_INPUT_FILE":"<path>","APS5_PIPELINED_DRAWS":"1","APS5_PIPELINE_DMA":"1","APS5_SPIRV_OPT":"full","APS5_TRACE_EVENTS":"2097152","APS5_TRACE_SECONDS":"200:30"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.4-arch1.1","os":"Linux 7.2.9-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA05347","title":"Record of Lodoss War -Deedlit in Wonder Labyrinth-","content_version":"01.000.001","resolution":"3840x2160","window":{"spec":"seconds 200:30","first_present":11086,"ms":30006.569},"presents":1503,"frame_ms":{"p50":19.162,"p90":24.09,"p99":29.407,"max":37.943},"gpu_busy_ms_per_present":2.622,"worker_busy_pct":{"queue worker 0x0":23.478},"top_phases_ms_per_frame":{"Driver.Packet":4.685,"VideoOut.Flip":1.881,"VideoOut.Flip.present":1.84,"Driver.Present":1.838,"Graphics.Draw":1.826,"Driver.Present.render_fence_wait":1.596,"Vulkan.Retire":1.596,"Vulkan.Retire.wait":1.592},"trace_dropped":false,"trace":"aps5-trace-53a0a27bb61e-473842.json.gz"} {"commit":"993f9f9b5c55","dirty":false,"env":{"APS5_DRAW_CACHE_ENTRIES":"4096","APS5_HOST_IMPORT_MIB":"16384","APS5_PAD_INPUT_FILE":"<path>","APS5_PIPELINED_DRAWS":"1","APS5_PIPELINE_DMA":"1","APS5_SPIRV_OPT":"full","APS5_TRACE_EVENTS":"2097152","APS5_TRACE_SECONDS":"200:30"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.4-arch1.1","os":"Linux 7.2.9-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA05347","title":"Record of Lodoss War -Deedlit in Wonder Labyrinth-","content_version":"01.000.001","resolution":"3840x2160","window":{"spec":"seconds 200:30","first_present":11406,"ms":30013.32},"presents":1796,"frame_ms":{"p50":16.683,"p90":16.69,"p99":20.236,"max":24.687},"gpu_busy_ms_per_present":2.353,"worker_busy_pct":{"queue worker 0x0":34.341},"top_phases_ms_per_frame":{"VideoOut.Flip":13.511,"VideoOut.Flip.vblank_wait":12.01,"Driver.Packet":5.737,"Graphics.Draw":1.755,"VideoOut.Flip.present":1.471,"Driver.Present":1.469,"Recorder.Sync":1.396,"Graphics.Draw.draw_and_resource_release":1.32},"trace_dropped":false,"trace":"aps5-trace-993f9f9b5c55-385408.json.gz"} ``` On the pinned measurement revisions, the same six focused tests passed on main and topic: guest_memory, guest_mmap_fixed_anonymous, MemoryPoolTest, agc_host_import_retirement, agc_host_import_unmap, and agc_sparse_run_import. Both logs confirm Khronos validation loaded and contain no VUID errors, skips, or missing-layer warning. Tests use ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. Guest-memory coverage includes neighboring readable runs, permission/GPU boundaries, reversed/duplicate targets, stale owners, removed ranges and retained lease lifetime. [Evidence archive](https://github.com/JJenkx/AnyPS5/releases/download/game-library-checks-20261016/20261021-lodoss-mapped-readable-run-validated.tar.gz): four raw traces, official digests, screenshots, reports, focused logs and refresh validation. SHA256 `70cdb1ea41aa5ff5c1a42c4030c257a9af1c30fce036b169bbd8aec1c1496d4e`. Separate directories distinguish native measurements (`measured-53a0-993f`) from refreshed focused validation (`refreshed-b5d763-623501`). <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none (performance only; PPSA05347, discussion #6460) <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: AMD Radeon RX 6650 XT, RADV Mesa 26.2.4-arch1.1, Linux 7.2.9-arch1-1 <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
clairtonmichel commented 2026-10-21 09:47:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by clairtonmichel on 2026-10-21T09:47:40Z.


Tested on AMD Ryzen 7 9800X3D and AMD Radeon RX 7900 XTX (Fedora Linux, Mesa 26.2.5):

  • Built cleanly with zero errors.
  • Ran the complete AGC graphics and driver test suites (848/851 passed successfully, ~99% green).
  • Lease mapped readable runs for import events behaves correctly on host. Ready to merge!
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6313004743 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9011#issuecomment-6313004743). Originally posted by [clairtonmichel](https://github.com/clairtonmichel) on 2026-10-21T09:47:40Z. --- Tested on AMD Ryzen 7 9800X3D and AMD Radeon RX 7900 XTX (Fedora Linux, Mesa 26.2.5): - Built cleanly with zero errors. - Ran the complete AGC graphics and driver test suites (848/851 passed successfully, ~99% green). - Lease mapped readable runs for import events behaves correctly on host. Ready to merge!
JJenkx commented 2026-10-21 09:49:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-21T09:49:07Z.


Thanks for testing on the 9800X3D / RX 7900 XTX. Could you share the names and failure summaries of the three tests that did not pass, plus the tested commit? If possible, running those same tests on the corresponding main base would distinguish existing failures from regressions in this change.

The paired focused checks recorded in the PR passed on both arms on my RX 6650 XT; I have not reproduced or classified the three failures from your broader run.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6313041215 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9011#issuecomment-6313041215). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-21T09:49:07Z. --- Thanks for testing on the 9800X3D / RX 7900 XTX. Could you share the names and failure summaries of the three tests that did not pass, plus the tested commit? If possible, running those same tests on the corresponding main base would distinguish existing failures from regressions in this change. The paired focused checks recorded in the PR passed on both arms on my RX 6650 XT; I have not reproduced or classified the three failures from your broader run. AI-assisted: yes
clairtonmichel commented 2026-10-21 09:53:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by clairtonmichel on 2026-10-21T09:53:31Z.


Tested on AMD Ryzen 7 9800X3D and AMD Radeon RX 7900 XTX (Fedora Linux, Mesa 26.2.5):

  • Built cleanly with zero errors on the PR #9011 branch commit.
  • Comparative test run against clean main:
    • The exact 3 failing tests (agc_driver_guest_memory_lifetime, agc_driver_image_array_window_past_layer_limit, and agc_driver_tessellation) are identically present on clean main as well.
    • Confirmed that these are pre-existing environment behaviors/failures and not regressions introduced by this PR.
  • Lease mapped readable runs for import events is fully stable. Ready to merge!
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6313128340 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9011#issuecomment-6313128340). Originally posted by [clairtonmichel](https://github.com/clairtonmichel) on 2026-10-21T09:53:31Z. --- Tested on AMD Ryzen 7 9800X3D and AMD Radeon RX 7900 XTX (Fedora Linux, Mesa 26.2.5): - Built cleanly with zero errors on the PR #9011 branch commit. - Comparative test run against clean `main`: - The exact 3 failing tests (`agc_driver_guest_memory_lifetime`, `agc_driver_image_array_window_past_layer_limit`, and `agc_driver_tessellation`) are identically present on clean `main` as well. - Confirmed that these are pre-existing environment behaviors/failures and **not regressions** introduced by this PR. - Lease mapped readable runs for import events is fully stable. Ready to merge!
JJenkx commented 2026-10-21 09:57:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-21T09:57:23Z.


Thanks for the paired main check and the test names. I have recorded your report that agc_driver_guest_memory_lifetime, agc_driver_image_array_window_past_layer_limit, and agc_driver_tessellation fail identically on clean main on your Fedora / RX 7900 XTX setup. This distinguishes the reported 848/851 result from three newly introduced failures; it is reviewer-provided evidence, separate from my six focused paired checks.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6313198266 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9011#issuecomment-6313198266). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-21T09:57:23Z. --- Thanks for the paired main check and the test names. I have recorded your report that `agc_driver_guest_memory_lifetime`, `agc_driver_image_array_window_past_layer_limit`, and `agc_driver_tessellation` fail identically on clean main on your Fedora / RX 7900 XTX setup. This distinguishes the reported 848/851 result from three newly introduced failures; it is reviewer-provided evidence, separate from my six focused paired checks. AI-assisted: yes
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!9011
No description provided.