fix(agc): do not evict host imports used in the current or previous frame #11357
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11357"
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-10-26T08:10:29Z.
Summary
Host imports used in the current or the previous frame are no longer evicted for another import.
An import was evictable 256 lookups after its last use. A frame makes thousands of lookups, so when the imports a frame uses do not all fit the budget, each new one evicts another of the same frame, and (reasoned from the 256-lookup rule, not measured here) the set is imported again every frame. A frame now ends at a flip packet or a CPU flip (
NoteHostImportFrame), and only imports not used in the current or the previous frame are evicted; what does not fit is refused and copied, as below the budget. A frame boundary also expires the remembered evicting refusals; a remembered refusal also ends when a build holding an import two frames old raises its floor.ProtectedUsesand the use-count horizon it fed remain only for the stretch before two frames have ended; once frames exist the frame rule decides.Until two frames have ended, imports age by lookups exactly as on main (so a loading stretch before the first flips behaves as before); after that, without flips (compute-only work) no frame ends and nothing more becomes evictable, so imports that do not fit are copied instead of evicting by recency. A frame end moves its own counter, used only by the remembered-refusal memory; it does not move the imports epoch, so the address-space cache survives a flip with no import change. The debt entry says so.
Tests
New
importEvictionFramesTests: three ranges under a budget for two, each used by its own build every frame with more lookups than a frame's worth of imports between uses; the first two keep their imports, the third is refused every frame, and a range unused for two frames is evicted.RunAddressCopyCapTests(agc_address_copy_cap,agc_address_copy_cap_remembered) now runs with 0, 1 and 2 frame notes in one process (the notes accumulate, so the third run starts with one frame already ended and adds two): with no frame history the cap retry is served as on main instead of being refused and aborting.importEvictionFramesTestsalso checks that ending a frame with no import change leaves the imports epoch unchanged.agc_driver_eop_interruptschecks that a flip packet and a CPU flip from a thread that never submitted queue 0 each end a host import frame.Existing tests whose setup assumed the old 256-lookup rule now advance frames in their setup (
importAtMapOverBudgetTests,importCoverageHintBudgetTests,failedImportJoinProbeBudgetTests,evictingRefusalMemoryTests,evictingRefusalAgingTests); their assertions are unchanged.Linux, Intel i9-14900KF, NVIDIA GeForce RTX 4090:
ctest -R 'agc_address_copy_cap|agc_driver_graphics_maps_fallback|agc_driver_eop_interrupts|public_headers': 69 of 69 passed, 0 failed, 0 not run.Not run: Windows; a game run; a measured before/after of the re-import thrash (the shutdown
host importsmade/refused counts would show it); the Windows lane of the new checks.Mutant check of the new test: with the frame protection removed (
evictable()back to "not the latest use"),importEvictionFramesTestsfails with "a range over the budget evicted an import used in the same frame (frame 0)"; unmutated it passes.Mutant checks, each failing as intended: fallback disabled (both cap tests abort); frame note removed from the flip packet path or from the CPU-flip path (
agc_driver_eop_interruptsfails); epoch bump added back to a frame end (agc_driver_graphics_maps_fallbackfails); the frame counter removed from the refusal memory (agc_driver_graphics_maps_fallbackfails).AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T08:16:41Z.
Review: CHANGES_REQUESTED
I reviewed exact head
9e7edf6e0ca53ac01b0067e1e2ba27dd4928d725. The frame-floor policy and regression description are coherent, and the author reports the focused graphics tests and mutant check passing. I am requesting changes for repository validation and integration items:conventionscheck fails: the PR body omits the template'sWhat,Tested, andChecklistsections. Please fill those sections in the repository template format and rerun the check.docs/dev/debt/libSceAgcDriver.mdentry at 4,108 characters, over the 1,000-character limit. Please reduce it to the actual unverified behavior/gap and preserve the other debt entries.204c6747d0a1cbaf932def3dea0778810cc3935e; this branch is 1 commit ahead and 46 behind. The merge preview is clean, but main added a separate host-import debt entry since this branch's base. Please rebase and retain both entries, then rerun conventions and the focused graphics/public-header tests on the resulting head.The CI product jobs are skipped by path policy; I have not independently run the reported Linux graphics tests or a game workload. The author also notes the CPU-flip boundary path lacks a unit test, so please include coverage for that call path if it can be driven by the existing test harness.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T09:46:52Z.
Review: CHANGES_REQUESTED
Follow-up on exact current head
9e7edf6e0ca53ac01b0067e1e2ba27dd4928d725. The Windows comparison reported by ycbuzi is a concrete regression:agc_address_copy_capandagc_address_copy_cap_rememberedpass on currentmain4e43321bd6and abort on this head with the address-copy-cap message. The report says the other 33 selected graphics tests, including the new frame-eviction test, pass on three GPUs.The frame-based eviction policy explains why the existing address-copy-cap fixtures now hit the fallback copy path:
RunAddressCopyCapTestsexercises 300 lookups but never callsNoteHostImportFrame, so its idle import is never two frames old and cannot be evicted. Please update these fixtures to model the required frame boundaries and preserve their intended assertions, or adjust the policy if these are valid no-flip workloads; then rerun both tests on Windows and the focused graphics tests on Linux. Please do not suppress the cap failure or weaken the new same-frame protection.The hosted
conventionscheck still fails on this head, and the PR body/debt entry issues from my earlier review remain to be resolved. Product jobs are skipped by path policy. I did not independently reproduce the Windows result locally.