perf(shader): admit repeated materialized results to the memo #1298
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1298"
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 TibixDev on 2026-10-07T22:42:28Z.
Status after review
Awaiting a demonstrated memo-eviction workload.
Current main still has a 256-entry per-source result memo, but the insertion point is now
materializePreparedMemoizedkeyed byvariant->artifact.variantId. This policy would need to move there. I confirmed that main already reports memo hits, misses, evictions and Populate time underAPS5_PROFILE_DRAW, so another instrumentation API is not needed.The earlier unique/repeated microbenchmarks do not demonstrate the proposed benefit: the reviewer reproduced a slowdown in both. The needed comparison is a mixed hot-set plus one-use stream that actually evicts useful results, followed by a title profile showing that eviction/Populate cost matters. No such isolated title gain has been established. I have removed the description's implication that the older component numbers justify landing it; no new code push or merge-readiness claim.
A subsequent 180-second Skyrim run with the same main-based experimental NGS library reached recurring draws/dispatches. In three later 10-second memo intervals, main recorded 154/182/208 evictions and only 1.4/1.2/1.2 ms total Populate time. This confirms that evictions occur, but does not show that admission would improve hit rate or materially reduce frame time; the hot-set-versus-stream trace and isolated A/B are still missing.
What
Results used once fill the shader-result cache and evict useful entries. Retain a result only after its key occurs twice. A fixed history of 256 keys avoids allocation and preserves the existing result lifetime.
Tested
Earlier branch-specific tests and measurements remain in the discussion. They have not been rerun on a redesigned current-main version of this PR. The review audit and shared NGS-assisted title exploration do not establish that this head is merge-ready. No full Linux/Windows platform CI was dispatched in this pass.
Checklist
Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-08T07:07:45Z.
Rebased on
bc1fbe81. Kept the upstream buffer-device-address test registration alongside memo-admission coverage.Fedora 44 Release:
agc_result_memo_tests,agc_shader_memory_testsbuild; the targeted tests and contribution checks pass. Windows CI is pending.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T08:23:33Z.
Review: CHANGES_REQUESTED
Thanks for the PR. Findings:
The claimed gain does not reproduce. I ran this PR's own
agc_result_memo_tests --benchmark(3 runs each, same machine, same binary built with and without the admission check; baseline =admitforced totrue):So the PR is slower in both rows here. Both numbers are also sub-microsecond CPU microbenchmarks, which
CONTRIBUTINGdoesn't accept as a reason for a perf PR on their own. Please post before/after numbers on the same tree (main vs main + PR), several runs, ideally from a real draw/dispatch profile (APS5_PROFILE_DRAW) showing the memo's eviction actually costs something.Cost vs. benefit. It adds a 69-line custom open-addressing hash plus a 159-line test to save at most a few hundredths of a microsecond per call, and every first occurrence of a result is now rebuilt once more before it is retained. Please show a workload where evictions of one-use results hurt hit rate; otherwise this isn't worth the code.
Conflicts with
main:materializeMemoizedwas split intomaterializePreparedMemoized(variant->artifact.variantId) andlibSceAgcDriver/CMakeLists.txtchanged. Needs a rebase.agc_result_memoshows as "Not Run" in a scoped ctest unlessagc_result_memo_testsis built explicitly; it is registered correctly, just noting it.Happy to look again with measurements that show a gain.
Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-12T04:51:49Z.
Review-pass update:
Current main still has a 256-entry per-source result memo, but the insertion point is now
materializePreparedMemoizedkeyed byvariant->artifact.variantId. This policy would need to move there. I confirmed that main already reports memo hits, misses, evictions and Populate time underAPS5_PROFILE_DRAW, so another instrumentation API is not needed.The earlier unique/repeated microbenchmarks do not demonstrate the proposed benefit: the reviewer reproduced a slowdown in both. The needed comparison is a mixed hot-set plus one-use stream that actually evicts useful results, followed by a title profile showing that eviction/Populate cost matters. No such isolated title gain has been established. I have removed the description's implication that the older component numbers justify landing it; no new code push or merge-readiness claim.
A subsequent 180-second Skyrim run with the same main-based experimental NGS library reached recurring draws/dispatches. In three later 10-second memo intervals, main recorded 154/182/208 evictions and only 1.4/1.2/1.2 ms total Populate time. This confirms that evictions occur, but does not show that admission would improve hit rate or materially reduce frame time; the hot-set-versus-stream trace and isolated A/B are still missing.
I have updated the PR description to match this status. The PR remains open; the outstanding review requirements are not being marked resolved. AI-assisted audit.
Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-12T16:53:55Z.
A title workload for the comparison asked for above: Astro's Playroom (PPSA01325) in its first level evicts on practically every memo miss. This is main's own
[recompile] result memoreport underAPS5_PROFILE_DRAW=1, four consecutive 10 s windows in gameplay (Linux, RTX 5080, about 2,900 draw packets per frame at 12 FPS):The title needs more than
mainto reach the level, so the build ismaind371ed307plus the since-merged PR 4162 and local changes (a depth-plane copy check and draw-path work).Recompiler.cppis unchanged from that commit, so the memo is main's 256-entry one.Measured since: a larger memo does not help here. With
ResultMemoEntriesraised from 256 to 4096 the hit rate stays at 31.7% (four windows, 228,171 to 240,551 hits against 494,754 to 519,003 misses). A counting run shows why: of 5.2 million misses, 731,851 had a key seen before, while 5,198,754 had been seen before once buffer and vertex buffer addresses are left out of the key (1,246 distinct). The game places per-draw constants at new addresses every frame, so nearly every miss is a new key and nearly every evicted entry is never asked for again.These two runs are on the same stack with one more local memo change (a miss reuses the storage of the evicted result). I have not run this PR's policy on it.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T05:08:52Z.
Closing for now: the author found no demonstrated gain from the memo. With the queue this large we're closing stalled perf PRs that don't show a gain in a title; reopen it with before/after numbers from a title scene (the summary lines from the performance report form) if you pick it up again.
Pull request closed