perf(agc): skip unchanged heap mirror runs and idle mirror sweeps in address-based builds #1411

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

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


What

An address-based build served by the cached address space still walked all of its regions for mirrors, sorted the heap mirrors, compared each one's blocks with the write tracker and swept the whole mirror registry. PPSA26344's world keeps about 37,000 heap mirrors (10.6 GiB) in about 2,000 runs; mirror preparation took 37 ms per cache-hit build.

  • The space keeps its writable mirrors, sorted heap mirrors and their adjacent runs from when it is published.
  • Each run is still flushed and collected. When GuestMemory::UnchangedSince finds no block of the run stamped since the generation of its last complete check, its mirrors skip ChangedBlocks; that generation is stored only after the build's blocks were copied.
  • sweepMirrors skips the registry walk while every live mirror's range is held by the cached space's lease and no mirror changed since the last walk: such a range cannot expire.
  • MirrorCounters adds sweeps and heapChecks.
  • #1085 calls sweepMirrors before a heap mirror that would go past the budget; its tests pass merged with this.
  • #639 (draft) adds BDA write tables next to the new AddressSpace fields and #290 already conflicts with main here; this adds no conflict hunk to either. #1357, #1359 and #1361 change the import entry in AcquireRegistered; they 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: a build after an unchanged one compares no heap mirror and walks no registry; later CPU writes and write-backs are seen. Does not build on main.
  • Offline (mock Vulkan, 37,000 section-backed 64 KiB heap ranges, runs of 18): median 9.8 to 1.1 ms per build.
  • PPSA26344 v1.008 (with our open PRs, 3,000 s): mirror preparation 13.9 ms per address-based build in the world, 15.1 ms in an earlier run without this change; every compared block had changed.
  • 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:4781178027 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1411). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-08T03:01:11Z. --- ### What An address-based build served by the cached address space still walked all of its regions for mirrors, sorted the heap mirrors, compared each one's blocks with the write tracker and swept the whole mirror registry. PPSA26344's world keeps about 37,000 heap mirrors (10.6 GiB) in about 2,000 runs; mirror preparation took 37 ms per cache-hit build. - The space keeps its writable mirrors, sorted heap mirrors and their adjacent runs from when it is published. - Each run is still flushed and collected. When `GuestMemory::UnchangedSince` finds no block of the run stamped since the generation of its last complete check, its mirrors skip `ChangedBlocks`; that generation is stored only after the build's blocks were copied. - `sweepMirrors` skips the registry walk while every live mirror's range is held by the cached space's lease and no mirror changed since the last walk: such a range cannot expire. - `MirrorCounters` adds `sweeps` and `heapChecks`. - #1085 calls `sweepMirrors` before a heap mirror that would go past the budget; its tests pass merged with this. - #639 (draft) adds BDA write tables next to the new `AddressSpace` fields and #290 already conflicts with `main` here; this adds no conflict hunk to either. #1357, #1359 and #1361 change the import `entry` in `AcquireRegistered`; they 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`: a build after an unchanged one compares no heap mirror and walks no registry; later CPU writes and write-backs are seen. Does not build on main. - Offline (mock Vulkan, 37,000 section-backed 64 KiB heap ranges, runs of 18): median 9.8 to 1.1 ms per build. - PPSA26344 v1.008 (with our open PRs, 3,000 s): mirror preparation 13.9 ms per address-based build in the world, 15.1 ms in an earlier run without this change; every compared block had changed. - 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:10 +00:00 (Migrated from github.com)

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


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: 255, 239, 244; 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:6060746554 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1411#issuecomment-6060746554). Originally posted by [EdouardSence](https://github.com/EdouardSence) on 2026-10-08T13:18:10Z. --- 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: 255, 239, 244; 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!1411
No description provided.