perf(agc): retry hot heap mirrors as host imports behind a switch #22438
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22438"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-11-17T15:54:53Z.
What
An experiment for #22339, behind
APS5_HEAP_MIRROR_RETRY=1. Without the variable nothing changes.Background: a registered heap that was refused as a host import once (budget full) is heap mirrored. While it stays write-watched, a cached address space keeps the mirror and never asks for the import again; only a rebuild of the space does. Since #15919 an import change patches the space instead of rebuilding it, and since #16751 nothing is evicted while recorded work is active, because the retired bytes stay pinned until that work is released. On PPSA06866 this leaves a hot heap mirrored for the whole run: it is refreshed on every address-based build and each refresh writes pending images back.
With the switch:
The
[address]profile line gainsheap mirror retries N (imported N, owed N).Tested
Linux, built on
e7988a85b0.agc_driver_graphicspasses with the newheapMirrorRetryTests, which runs both arms on a write-watched block: without recorded work the retried heap replaces an idle import at once; with a recorder active the idle import is retired ahead, the heap stays mirrored while the bytes are held, and the first build after their release rebuilds the space and imports the heap. Without the switch 140 builds leave the mirror and the idle import alone. The test body is not built on Windows.Not tested: no title was run. PPSA06866 is not available on my machine, so there are no performance numbers. The run that would settle it is the scene of #22339 (
phoenix-31) withAPS5_PROFILE_DRAW=1, three arms on this branch: default,APS5_HEAP_MIRROR_RETRY=1, andAPS5_HEAP_MIRROR_RETRY=1withAPS5_NO_SPACE_PATCH=1. The[address]and[buffers] image mirrorslines of each arm show whether the heap leaves the mirror (retries, imported, owed, heap MiB) and what it does to the frame time.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T12:04:53Z.
Review: COMMENTED
Reviewed — no blocking findings
The targeted inspection found no verified blocking defect in the retry and retire-credit paths at head
e01b313b65eac44edeeba8be5003614ac9678af3; executable checks were not run.What I ran
Results
Findings
Blocking
None verified in the inspected code.
Non-blocking
Not verified
GuestBufferMemory.cppwas read only in targeted ranges because its full text was excluded as too large. Thus this is not a complete review of that file or every changed hunk.BdaResources.cppanddocs/dev/ENVIRONMENT.mdare listed as included in the manifest but their full texts were not inspected; the test implementation was read from the diff only.review/files.jsoncould not be read through the available reader; the manifest showsGuestBufferMemory.cppexcluded for size and the other two changed files included.To get this to a good state
Nothing is required. Optional: run the documented PPSA06866 three-arm comparison and report the profile and frame-time results.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T13:43:32Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: fix the host import retry path so a retry can admit the heap after retiring idle imports, and keep the retry guard active through the import attempt.
What I ran
Reviewed head
e179f36c12f0ac2c023ba53e973438c48c8dcb57. No commands or tests were run; the prepared reader was used to inspect the diff and source.Results
Findings
Blocking
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp:2450: When an owed heap retry finds enough idle imports,evictableis capped to the retire-credit allowance. With retire credit disabled, or whenretired + replacedexceeds the allowance, this cap is zero. The subsequent test at lines 2451–2460 uses the uncapped idle amount to retire imports and record the heap as owed, but then returns without importing it. On the next build the owed bytes are cleared because the range is not yet imported; the heap can therefore remain mirrored despite available idle imports. The retry path should allow retiring the idle imports needed for the heap attempt, while preserving the recorded-work pinning rules.core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp:5416: The retry flag is cleared immediately afterimportsNow, before the import allocation path runs. The special idle-import retirement branch at line 2452 checks this flag, so a retry that reachesimportRunAtcannot activate the branch. Keep the retry context active through the complete attempt, including allocation, and clear it reliably afterward.Non-blocking
None.
Not verified
The full source file
GuestBufferMemory.cppwas excluded from the prepared files because it was too large; relevant functions and call sites were read throughrepo_read.py. The included filesGuestBufferMemory.hpp,BdaResources.cpp, anddocs/dev/ENVIRONMENT.mdwere read. No other changed files were listed in the manifest. Build, tests, Windows behavior, and title/performance behavior were not verified.To get this to a good state
Correct both retry-path issues, then rerun the reported
agc_driver_graphicscoverage on the updated head, including heap retry with recorded work and with enough idle imports.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T12:26:46Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks merging based on the code inspected; the experiment’s behavior is gated by environment switches, and I found no verified blocking defect.
What I ran
Reviewed head
9986d0ec58a95d2a28e114ef3744cb40ff8b7034using the prepared diff andrepo_read.pyfor targeted source ranges. No build or tests were run. The description reports Linux build and test results; these were not independently verified.Results
Findings
Blocking
None.
Non-blocking
Not verified
GuestBufferMemory.cppwas read through targeted ranges withrepo_read.py; its full 8,409-line text was not read.BdaResources.cppwas read over the changed test range. The prepared diff and manifest were read.GuestBufferMemory.hppandENVIRONMENT.mdwere not fully read; their changed lines were reviewed in the diff and the documentation range was checked. No other files were listed in the manifest.To get this to a good state
Nothing is required. Optional: report the Phoenix scene profile captures described in the PR description.