Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
Celegans12:perf/agc-imported-heap-mirrors
Oct 9, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
Celegans12:perf/agc-imported-heap-mirrors

Conversation

@Celegans12

Copy link
Copy Markdown
Contributor

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.

Tested

  • Windows 11, MinGW-w64 GCC 15.2.0, based on main df16c4c: 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

@EdouardSence

Copy link
Copy Markdown
Contributor

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.

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

An address-based build maps every readable registered range: through a
host import when one can be made, else through a heap mirror, a
host-visible copy of the range. A range mirrored while the import budget
was full kept its mirror after a later pass imported it, until the guest
freed the range. The pass then read the range through the import, and the
mirror only held host-visible memory and a second copy of the bytes.

The pass now releases the heap mirror of every range it serves through
an import. Recorded work that bound the mirror keeps it until it
completes. If the import goes away while the range stays registered, the
next pass makes a new mirror from the guest bytes. The [buffers] image
mirrors profile line counts the released mirrors.
@Celegans12
Celegans12 force-pushed the perf/agc-imported-heap-mirrors branch from c468258 to 3f00dc7 Compare October 9, 2026 13:48
@oneandonlydean
oneandonlydean merged commit 05ba7f7 into boykopovar:main Oct 9, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants