perf(agc): release a heap mirror once a host import serves its range #1410

Merged
Celegans12 merged 1 commit from upstream-pr/1410 into main 2026-10-09 19:06:03 +00:00
Celegans12 commented 2026-10-08 03:00:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-08T03:00:48Z.


What

An address-based build maps each readable registered range through a host import, else through a heap mirror, a host-visible copy kept current by write tracking. A range mirrored while APS5_HOST_IMPORT_MIB was full kept its mirror after a later pass imported it (budget freed by an unmap). Until the guest freed the range, the mirror held host-visible memory and bytes no build read.

  • AcquireRegistered now releases the heap mirror of each range its pass serves through an import. Recorded work that bound it keeps it until it completes, as for a swept mirror. Image mirrors are unchanged.
  • The [buffers] image mirrors line (APS5_PROFILE_DRAW) counts the released mirrors.
  • In PPSA26344 v1.008 (main with our open PRs and #290), heap mirrors held 10.6 GiB in 37k ranges while host imports swung between 0.7 and 3.7 GiB with the mirror count flat.
  • #290 rewrites importAllocation and its call in this pass (it conflicts with main already; this change adds no conflict). Its eviction drops imports of ranges that stay registered; the next pass then mirrors such a range anew from the guest bytes. #1085 (ours, acquireMirror and the same tests), #1071 (ClearImageMirrors) and #1357, #1359 and #1361 (the import entry in the same AcquireRegistered loop) merge cleanly.

Tested

  • Windows 11, MinGW-w64 GCC 15.2.0, based on main df16c4c2: configure -DBUILD_TESTING=ON, full build, --target libs, ctest:
  • 404/404 tests pass (ctest --output-on-failure)
  • Same build on lavapipe (Mesa 26.2.4 llvmpipe, 8-wide subgroups, VK_DRIVER_FILES): 403/403 pass; agc_driver_flat_store is left out there because it takes several minutes on Windows llvmpipe
  • agc_driver_graphics (mock device, new case next to the heap mirror tests): a mirrored range that a later build imports loses its mirror, an imported range is not mirrored again, and a build without the import mirrors the current guest bytes anew. Fails on main.
  • PPSA26344 v1.008 (with our open PRs, 3,000 s): 697 heap mirrors (862 MiB) released for imports, all in the first 923 s; heap mirrors then stayed under 5.7 GiB and no vkAllocateMemory failed.
  • Not tested: Linux (CI), console behaviour.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4781175596 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1410). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-08T03:00:48Z. --- ### What An address-based build maps each readable registered range through a host import, else through a heap mirror, a host-visible copy kept current by write tracking. A range mirrored while `APS5_HOST_IMPORT_MIB` was full kept its mirror after a later pass imported it (budget freed by an unmap). Until the guest freed the range, the mirror held host-visible memory and bytes no build read. - `AcquireRegistered` now releases the heap mirror of each range its pass serves through an import. Recorded work that bound it keeps it until it completes, as for a swept mirror. Image mirrors are unchanged. - The `[buffers] image mirrors` line (`APS5_PROFILE_DRAW`) counts the released mirrors. - In PPSA26344 v1.008 (`main` with our open PRs and #290), heap mirrors held 10.6 GiB in 37k ranges while host imports swung between 0.7 and 3.7 GiB with the mirror count flat. - #290 rewrites `importAllocation` and its call in this pass (it conflicts with `main` already; this change adds no conflict). Its eviction drops imports of ranges that stay registered; the next pass then mirrors such a range anew from the guest bytes. #1085 (ours, `acquireMirror` and the same tests), #1071 (`ClearImageMirrors`) and #1357, #1359 and #1361 (the import `entry` in the same `AcquireRegistered` loop) merge cleanly. ### Tested - Windows 11, MinGW-w64 GCC 15.2.0, based on `main` df16c4c2: configure `-DBUILD_TESTING=ON`, full build, `--target libs`, `ctest`: - 404/404 tests pass (`ctest --output-on-failure`) - Same build on lavapipe (Mesa 26.2.4 llvmpipe, 8-wide subgroups, `VK_DRIVER_FILES`): 403/403 pass; `agc_driver_flat_store` is left out there because it takes several minutes on Windows llvmpipe - `agc_driver_graphics` (mock device, new case next to the heap mirror tests): a mirrored range that a later build imports loses its mirror, an imported range is not mirrored again, and a build without the import mirrors the current guest bytes anew. Fails on `main`. - PPSA26344 v1.008 (with our open PRs, 3,000 s): 697 heap mirrors (862 MiB) released for imports, all in the first 923 s; heap mirrors then stayed under 5.7 GiB and no vkAllocateMemory failed. - Not tested: Linux (CI), console behaviour. ### Checklist - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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 - [x] AI-assisted: yes
EdouardSence commented 2026-10-08 13:18:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-08T13:18:09Z.


Tested on AMD under Linux, since this PR wasn't: RX 9070 XT (RDNA4, GFX1201), RADV / Mesa 26.2.4, Linux 7.2.9 (CachyOS), GCC Release build.

  • ctest: this PR merged onto main 07c2405c, all 452 tests pass with ctest -j8 (main alone: 452/452 on the same machine).
  • Astro Bot (PPSA21567, retail): built as main + #759 (needed to boot this title on main) + this PR, then one scripted run headless from boot through the title screen. No error and no amdgpu fault came from this change.
    • Presents per 10 s on the title screen: 243, 231, 227; with main + #759 alone: 226, 229, 226.
    • The run then stops, with and without this PR, on storage image access to depth/stencil surface ... is not implemented (the gap #425 fills). So nothing past the title screen is covered.

AI-assisted: the runs and this write-up were done by Claude (Claude Code) on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6060746146 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1410#issuecomment-6060746146). Originally posted by [EdouardSence](https://github.com/EdouardSence) on 2026-10-08T13:18:09Z. --- Tested on AMD under Linux, since this PR wasn't: RX 9070 XT (RDNA4, GFX1201), RADV / Mesa 26.2.4, Linux 7.2.9 (CachyOS), GCC Release build. - **`ctest`**: this PR merged onto `main` 07c2405c, all 452 tests pass with `ctest -j8` (main alone: 452/452 on the same machine). - **Astro Bot (PPSA21567, retail)**: built as `main` + #759 (needed to boot this title on `main`) + this PR, then one scripted run headless from boot through the title screen. No error and no amdgpu fault came from this change. - Presents per 10 s on the title screen: 243, 231, 227; with `main` + #759 alone: 226, 229, 226. - The run then stops, with and without this PR, on `storage image access to depth/stencil surface ... is not implemented` (the gap #425 fills). So nothing past the title screen is covered. AI-assisted: the runs and this write-up were done by Claude (Claude Code) on my machine.
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!1410
No description provided.