fix(agc): let heap mirrors replace host imports when the import budget is full #12074
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12074"
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 mehmetbayoglu on 2026-10-27T18:57:23Z.
What
Since #8380 imports a heap over the host import budget in pieces, the budget (8132 MiB here) can fill with imports that every address-based build uses. #11357 then protects every import used in the current or the previous frame, so none of them is evictable. Astro Bot (PPSA21567) has a working set of about 12 GiB and hits two problems:
APS5_ADDRESS_COPY_MAX_MIB, the evicting retry finds nothing to evict, and the title stops withFATAL: an address-based build copies ~1.1 GiB ... import over the host import budget, heap not fully write-watched.Many of the imports holding the budget cover a single releasable range that is still write-watched, so a heap mirror can serve that range just as well. This PR lets both paths evict those imports:
AcquireRegistered): the evicting retry for a range only an import serves may also evict imports whose single range is releasable and write-watched, even inside the frame protection, as long as the current build has not taken them yet. The build then serves those ranges from heap mirrors. Remembered refusals are not used for this retry.importsNow): for a cached heap mirror that left the write watch, the import attempt now evicts the same way, with the imports of earlier builds no longer held, instead of the non-evicting attempt that was refused every time.Other requests keep the current eviction rules. The debt entry for host import windows and budget describes the new eviction.
Checked against open and merged PRs:
Neither fixes it.
Tested
Windows 11 Pro, MinGW GCC (winlibs), Release, NVIDIA GeForce RTX 4070 Ti.
mainis14332cd8d0; each tree was built in its own build directory.New tests (each runs with 0, 1 and 2 frames ended, so both the lookup-count rule and the two-frame rule are covered):
agc_address_copy_cap_mirror: a build past the copy cap needs a range outside the write watch while the budget is held by a recently used, write-watched import.mainwith only this PR's test changes: aborts withFATAL: an address-based build copies 2 MiB of 1 registered ranges, past 1 MiB (APS5_ADDRESS_COPY_MAX_MIB); ... (2.0 MiB committed, import over the host import budget, heap not fully write-watched), the same abort as in Astro Bot.agc_address_space_unwatched_mirror_import: a cached heap mirror leaves the write watch while the budget is held by another heap's import.mainwith only the test changes: fails (a heap whose mirror left the write watch was not imported in place of an import a mirror can replace).agc_heap_mirror_unwatchnow takes its idle and busy ranges out of the write watch on Windows, so they are outside it as on Linux (where only the heap is registered) and a mirror cannot stand in for them. It passes onmainand with this PR.AGC suite,
ctest -R "agc|shader_cache" -j 4:main: 1107 of 1108 pass.agc_driver_mesh_barycentric_emulation(the pixel shader did not emulate barycentrics). It does not touch host imports.Validation layer:
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest -R "agc_address|agc_heap_mirror|host_import" -Vmain: 19 of 19 pass.agc_host_import_sparseis skipped on both (udmabuf imports are Linux only).VUID-messages over 7 real devices. The new tests run against the mock Vulkan device, so the layer does not see them.Astro Bot (PPSA21567), Windows, RTX 4070 Ti. Measured on our integration tree with the pin fix (#6182's change) and #11307, not on plain
main:Black Ops (BO1) output is identical on the same tree (byte-equal frames and draw records in a strict frame replay). This PR makes no speed claim.
python3 tools/check_conventions.py --base origin/mainreports no errors and one warning: the host import debt entry, already over 1000 characters onmain, grows by about 340.python3 tools/pr_overlap.pyreports one conflict: #7844 edits the same debt entry (docs/dev/debt/libSceAgcDriver.mdL261). Either order is fine with me; the maintainers can choose. If #7844 lands first, this PR rebases on it, keeps both debt updates, and setsDepends on: #7844.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T19:00:28Z.
Review: CHANGES_REQUESTED
The two new regression scenarios target the reported failure modes, and the implementation only yields single-range, releasable, currently watched imports to mirrors. Exact-head conventions checks report no errors (with the existing debt-length warning),
git diff --checkis clean, and the branch merges cleanly with currentmain. The hosted Windows build has not finished, so I have not assessed its result yet.Please resolve the remaining contribution-rule items before merge:
main/change summary lines nor attached traces.CONTRIBUTING.mdrequires the performance-report artifacts for speed claims. Please add a current-main comparison from the same title, scene and machine with the traces and digest, or remove the speed comparison and keep the claim focused on correctness/avoiding the abort and repeated copies.Depends on: nonedoes not record an agreed order. Please coordinate which PR lands first with its author and declare that dependency/order in the checklist, while preserving both debt updates.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T09:25:10Z.
Review: CHANGES_REQUESTED
Re-review — changes requested
The latest description now explicitly makes no speed claim and focuses on the correctness result: the copy-cap abort is avoided and repeated full-range copies/import refusals are reduced. That resolves my earlier request for matched performance-report artifacts or removal of the speed comparison. The author reports the two new regression tests pass with this change and fail on main; I did not rerun them locally.
Two integration items remain:
14332cd8d0, while current upstream main isaaccd0ba39b7. Please refresh onto current main and rerun the focused address-copy/import tests on the exact resulting head.Depends on: none, and neither PR records an agreed order. Please get that order selected and recorded on both sides; if #7844 lands first, preserve its debt edit while rebasing this PR as described.The authored Windows/AGC suite report is useful, but the hosted Linux product job is skipped and I did not run a local GPU build. I am holding approval for the current-main and overlap items, not for the removed speed claim.