Repository navigation
perf(agc): retry hot heap mirrors as host imports behind a switch - #22438
Conversation
With APS5_HEAP_MIRROR_RETRY=1 a write-watched heap mirror that is refilled on most address-based builds is tried as a host import again every 64 builds. Under recorded work the idle imports are retired ahead, the heap is owed their room and the address space is rebuilt when the bytes are released. A cached space that holds heap mirrors is rebuilt after an import change instead of patched. Default behaviour is unchanged.
|
This pull request is labeled |
|
Ran Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor
No new AI-assisted: yes (Claude Code) |
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
A draw that reuses its cached resources retakes the address space without an address-based build, so on a screen served by reuse the retry count never advanced and the trial never ran. With APS5_HEAP_MIRROR_RETRY a retake of a space with heap mirrors now counts as a build and is refused when the trial or an owed import is due, which sends that draw through a build where the existing trial runs. The image mirrors profile line is also printed from retakes.
|
Updated clean Windows coverage on your latest canonical Three commits:
The exact final fixture binaries and support-library hashes are identical between providers; only libSceAgcDriver.prx changes. Both completion markers appear in every round, including the credit-disabled refusal, credit-enabled admission during recorded work, quarter-budget limit, and released-bytes assertions. Thus a Windows early return cannot masquerade as coverage. These transition checks use the fixture's simulated device. Eight separate cases per round create actual RTX 5070 Ti devices with Khronos insertion; zero skips, missing-layer messages or VUID/SYNC identifiers. This is native regression coverage, not a forced hardware credit/retry or game-performance result. Windows 11 26200, RTX 5070 Ti / NVIDIA 617.42, GCC 15.2 r7 Release, validation 1.4.363. Diff/conventions checks pass against current origin/main. The first local compilation caught an incorrect cleanup-call argument list; it was corrected before freezing any tested binaries, and the successful rebuild and all four gates use f581. 007 remains separate: our existing #9508 integration predominantly takes the per-resource sparse-mirror path outside the cached-address-space retry path, and its observed retry/import/owed counters remain zero. No e179 production change has been staged into the game runtime and no loading or FPS benefit is claimed. Raw title data remains local. AI-assisted. |
While recorded work is active a new host import gets no credit for the imports it replaces and may evict nothing, because the retired bytes stay pinned until the work completes. At a full budget nothing new is admitted, so a heap that fell back to a mirror stays one. With APS5_IMPORT_RETIRE_CREDIT an import may replace and evict under recorded work while the retired bytes still pinned stay within a quarter of the budget, which bounds what is pinned at the budget plus a quarter. The shutdown report counts the imports admitted this way.
The credited counter rose with the switch off, on any replacing import and on imports that later failed. Count it after the import is made, only when the credit let it in over the budget, and check the counter in the switch-off test.
MarcZX10
left a comment
There was a problem hiding this comment.
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
- Read the prepared description, commit list, manifest, and diff; inspected the changed import-budget and address-space retry logic at the pinned head.
- No build or tests run. No repository changes made.
Results
| Check | Result | Note |
|---|---|---|
| Diff and changed code | passed | Key retry and credit paths inspected |
| Build and tests | not run | No executable checks performed |
Findings
Blocking
None verified in the inspected code.
Non-blocking
- The description reports Linux coverage and explicitly notes that no title or performance run was available. The intended PPSA06866 comparison remains unverified; it would establish the experiment’s practical impact.
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.- No build, tests, title run, Windows run, or performance measurements were performed by this reviewer. Author-reported Linux test results were not independently verified.
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.
…re credit admitted the import With both switches off the retire after an import is created reads the pinned total again, the same expression as before the retire credit. Only an import admitted on the credit uses live bytes there. The environment table states the bound as a quarter of the budget plus at most one import.
MarcZX10
left a comment
There was a problem hiding this comment.
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
| Check | Result | Note |
|---|---|---|
| Source review | failed | Two retry-path defects verified |
| Build and tests | not run | Author reports Linux tests; not independently run |
| Windows and title behavior | not run | No Windows build or title run confirmed |
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.cpp was excluded from the prepared files because it was too large; relevant functions and call sites were read through repo_read.py. The included files GuestBufferMemory.hpp, BdaResources.cpp, and docs/dev/ENVIRONMENT.md were 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_graphics coverage on the updated head, including heap retry with recorded work and with enough idle imports.
|
@MarcZX10 I checked both findings against e179f36 and I do not think either is a defect. Line numbers are in
If you see a path where the owed range is dropped before the release, point me at it and I will add a test arm for it. |
MarcZX10
left a comment
There was a problem hiding this comment.
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 9986d0ec58a95d2a28e114ef3744cb40ff8b7034 using the prepared diff and repo_read.py for targeted source ranges. No build or tests were run. The description reports Linux build and test results; these were not independently verified.
Results
| Check | Result | Note |
|---|---|---|
| Diff and targeted source review | passed | Retry and retire-credit paths inspected |
| Build and tests | not run | Author reports Linux results |
| Runtime performance | not run | No title run or performance captures reported |
Findings
Blocking
None.
Non-blocking
- The retry behavior is an experiment without title-level performance measurements. The description identifies the Phoenix scene and profile counters needed to assess whether it improves frame time; sharing those captures would help establish the change’s value.
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.- Build, tests, Windows behavior, console behavior, and performance were not independently verified.
To get this to a good state
Nothing is required. Optional: report the Phoenix scene profile captures described in the PR description.
|
Head No new failures and no new validation messages on either GPU.
Layer runs used AI-assisted: yes |
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 repository