perf(agc): bypass the draw cache while its hit rate is under 5% #12478
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12478"
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 EagleBearerYS on 2026-10-28T15:43:37Z.
What
Based on @bcortezf's #5404, which they closed on 2026-10-22. This is their bypass on current
main, with their co-authorship in the commit.When two windows of 2,048 draw-cache lookups in a row each have fewer than 5% useful lookups, the next 2,048 draws neither look up nor insert draw entries. Each further low window in a row doubles that, up to 16,384, and a window at or above 5% ends the run. A lookup counts as useful when the whole draw hits, when a cached draw of the same shape is found (before its data and push-offset checks decide whether a stage is reused), or when its draw key was seen before, since the cache admits the draw at that sighting.
APS5_DRAW_CACHE_BYPASS_PERCENTsets the threshold (default 5).0never bypasses, and values above 100 count as 100. Its row is inENVIRONMENT.md.APS5_PROFILE_DRAW,[draw-cache] bypassed N draws (10 s): useful lookups stayed under 5% for two or more windows in a rowreports how many draws skipped the cache. The bypass counts them in an atomic, so a bypassed draw takes no lock.useDrawEntries == falsealready takes (the same asAPS5_NO_DRAW_SRT_ENTRIES), so no new draw path is added.On @oneandonlydean's review of #5404 (comment):
Stage hits now count (
ab71996739).useDrawEntriesstill gatesstageEntries, so a bypassed draw also skips stage reuse. But the window now counts a lookup as useful when the whole draw hits, or when a cached draw of the same shape is found for one of its stages (the data-only path), before the data and push-offset checks decide whether that stage is reused. So a scene whose whole-draw keys miss while its stages hit keeps the cache, as you suggested.On Resident Evil Village (PPSA01556)'s main menu, stage reuse was small anyway. These are the
[draw-cache]lines of two profiled runs of the same menu on a local tree without the bypass, at menu +15 min:One window word (
ab71996739). The window's hits and lookups are now one 64-bit word updated by a single compare-exchange, so exactly one caller closes each window.The exact threshold (
b7001db47d). The minimum isceil(2048 × percent / 100), 103 hits at 5%. So 102 hits in 2,048 lookups (4.98%) bypasses and 103 keeps the cache, matching "fewer than 5%".Speed at
main's defaults (the 256 MiB budget from #9129 on, the bypass at 5%): this description claims no speed gain for the current head.a8e7e2f8a7ran Resident Evil Village (PPSA01556)'s menu 26% faster thanmain319621ba2e, and saved no memory (Tested).14209e93ba, with the warm-up fix, a pair onmainebb4075168shows no measurable gain (Tested).167947744a, a pair onmain6472c708aeran 13.3% faster. But in a profiled boot of that tree the bypass starts in none of the measured window's 57 ten-second blocks, so that gain isn't attributed to this change (Tested).On @adriadam10's review and @bcortezf's warm-up report (review, report):
c7981bcb3b). With second-sight admission a draw hits only at its third sighting. So on a cold scene of about 1,000 or more draws, the first window had almost no hits and started a bypass, during which no sightings were recorded either. Both suggested fixes are in:DrawKeySightingshas seen before now counts as useful;40973d322a).DrawCacheBypasscounts the draws it skips in an atomic, and the draw-cache report takes and resets that count.ENVIRONMENT.mdrow.14209e93bamergesmainebb4075168. The draw-cache tests ran again on it (Tested), and the Village pair on the new base is in Tested.On @MarcZX10's review of
14209e93ba(review):11e29b3107).Skiptakes its draw from the same word.05d2faab6cmergesmain76fd1c09e9, and the draw-cache tests and the validation comparison ran on it (Tested).Overlap:
tools/pr_overlap.pyfinds no conflict with any open pull request that merges cleanly withmain.git merge-treeafter its own merge withmain.mainalready, #5609 and #6188 share the draw-cache files:evictDrawEntries, and also editsDrawCacheStatistics.cppandDrawCacheReuse.cpp. Whichever merges second keeps both sides there.Related: #5404, #9129
Profiled boot of
14209e93baon Resident Evil Village (PPSA01556)'s menu (profiled, not a timing run). It ran under the warm-up fix's rule, where a lookup whose key was seen before counts as useful.APS5_PROFILE_DRAW=1with the usualAPS5_LAZY_SHADER_PREPARE=1 APS5_NO_GPL=1 APS5_HOST_IMPORT_MIB=6400 APS5_TRACE_SUMMARY_EVERY=10and the pad script, and no draw-cache variables. RTX 3070 Laptop GPU (NVIDIA 617.42), held 12 min past the menu.[draw-cache] bypassedlines in 80 ten-second blocks, 112,640 draws bypassed in all (2,048, 4,096, 8,192, then 16,384 six times). All 9 are in the 8th to 18th blocks, none after.The pairs, the captures, the profiled
bypassedlines and the light-title run are in Tested.Tested
Tests:
agc_driver_draw_cache_low_hit_bypass(default) andagc_driver_draw_cache_low_hit_bypass_off(APS5_DRAW_CACHE_BYPASS_PERCENT=0) run four new cases inDrawCacheReuse.cpp, andagc_driver_draw_cache_cold_sceneand its_offrun a fifth. The draw-level cases draw only the lookups whose outcome they check and note the rest of each 2,048-lookup window on the driver's bypass (167947744a, below).LowHitRateBypassesTheCachechecks that:StageHitsKeepTheCacheLookedUp: after one low window, a window whose only useful lookups are 103 draws whose keys miss but whose vertex stages are reused from the cache keeps the next draw looked up.ConcurrentNotesCloseEachWindowOnce:LowWindowsLengthenTheBypass: a run of low windows bypasses 2,048, 4,096, 8,192 and then 16,384 draws. A window at 5% ends the run, and the next bypass again waits for two low windows and starts at 2,048. No draw is bypassed before the window that starts the bypass has closed.ConcurrentClosesKeepTheirOrder: a low window closes on one thread while three others note the next, useful window, 256 times. The bypass the two low windows started must be exactly 2,048 draws, one more low window must start none, and a second must start 2,048.ColdSceneKeepsTheCacheLookedUp(--cold-scene): a scene of 1,000 new draws, repeated every frame from cold, hits at least 90% by its fourth frame, with the bypass on and off.^agc_driver_draw_cache×10 at each commit, 13 tests, 130 of 130 runs, 0 skipped):3e4d8e25f2;ab71996739("draws after a window of 102 hits in 2048 lookups were still looked up or inserted").main04fefebe90, ×10, for the first commit: on Linux the new case fails with main's code and passes 10 of 10 with this change (13 tests, 0 skipped), and the libc and libkernel suites run with 0 failed (run). On Windows all 13 build and skip, and the suites run with 0 failed.58171b22e8,agc_driver_draw_cache_cold_scenefails on Linux and its_offarm passes (run). On Windows both skip, since the runner has no Vulkan device.TakeBypassedthat commit adds, so it doesn't build on its parent.ConcurrentClosesKeepTheirOrderpasses on both11e29b3107and its parent. The old code's gap can't be forced through the API without a hook in production code. Every existing case passes unchanged on11e29b3107, which shows the single-threaded policy is the same.a8e7e2f8a7, a merge ofmain319621ba2e(clean; the PR's patch-id is unchanged) (run):APS5_SKIP_TIMING_TESTS=1, the libc and libkernel suites run 171 and 291 tests on Linux and 199 and 314 on Windows, with 0 failed.check_conventions.pypasses, with no comment lines added.Validation comparison (
VERIFY_VALIDATION=1on GitHub's Linux runner, llvmpipe (LLVM 20.1.2, Mesa 25.2.8), the two bypass tests and every^agc_driver_draw_cachetest):7157a5bf59,main319621ba2eagainst it): 13 passed, 0 skipped.VUID-VkDeviceCreateInfo-pNext-pNextappears in both arms, and the change adds none (run).main04fefebe90against3e4d8e25f2): the same result (run).Resident Evil Village (PPSA01556), draw cache at
main's defaults, static main menu, ona8e7e2f8a7(before the warm-up fix). 16 min each run after a warm-up past the menu, unprofiled, B A A B, 2026-10-28.main319621ba2e; B =a8e7e2f8a7, this PR's head at the time.scePadOpenanswer for port types 3 and 4.measure/12478-a-main-319621ba2e) and B is bd421aa3c2fb (branchmeasure/12478-b-head-a8e7e2f8a7). Each is its arm's commit, then thescePadOpenanswer (e054dfdca2 in A, e09dff7347 in B), then merges of #11580 atfedf3e91a7and #10304 ate0d6e062a9.APS5_LAZY_SHADER_PREPARE=1 APS5_NO_GPL=1 APS5_HOST_IMPORT_MIB=6400 APS5_TRACE_SUMMARY_EVERY=10, with no draw-cache variables (budget 256 MiB, bypass 5% in B). Each arm used its own shader cache. These four runs take their numbers from theAPS5_TRACE_SUMMARY_EVERYintervals; the captures below follow the form.mainDriver.Packetms per frameDriver.Packet.memory_waitms per frameDriver.Drawms per frameSpeed: B's mean is 0.866 fps against A's 0.688 (+26%), and B is ahead in both adjacent pairs (0.905 vs 0.742, then 0.827 vs 0.635).
Memory: no difference. B is 55 MB lower on the mean, inside A's own 473 MB spread.
[draw-cache]lines at this menu, from one profiled B boot (APS5_PROFILE_DRAW=1added, to menu +10; not a timing run):bypassed 16384 draws (10 s)in 23 of the 25 ten-second blocks, 376,832 draws in all, from the second block on.Captures, as the Performance report form describes: one traced run per arm on the same trees and caches as the pair, A then B in one session on 2026-10-28 (PT).
APS5_LAZY_SHADER_PREPARE=1 APS5_NO_GPL=1 APS5_HOST_IMPORT_MIB=6400 APS5_TRACE_SECONDS=960:30and the pad replay (APS5_PAD_INPUT_FILE), with no otherAPS5_TRACE_*orAPS5_PROFILE_*switch. Each arm wrote its trace and summary line into its own working directory.Driver.Packet3,666 against 4,499 ms per frame (-19%), of whichmemory_wait2,133 against 2,668 andPacket.draw970 against 1,217;Packet.dispatch526 against 565 ms, and GPU busy per present 244 against 232 ms.APS5_TRACE_SUMMARY_EVERY=10andAPS5_TRACE_DIR, which the form doesn't allow. In those, B was also ahead (p50 1,080 against 1,178 ms), andPacket.dispatchwas higher in B (564 against 492 ms).aps5-trace-103015a9ca66-13244.json.gz(2.4 MB) and Baps5-trace-bd421aa3c2fb-33348.json.gz(2.7 MB).aps5-summary.jsonlholds them (A, then B):A (main
319621ba2e+ #11580 + #10304): trace_digest.pyseconds 960:30 from present 3194: 19 presents, frame p50 1509.6 / p90 1868.2 / p99 2204.5 / max 2204.5 ms, GPU busy 232.2 ms per present
NVIDIA GeForce RTX 3070 Laptop GPU, NVIDIA 617.42, Windows 10.0.26300, 3840x2160, commit 103015a9ca66, dropped: no
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 4487.4, Driver.Packet.memory_wait 2667.5, Driver.WorkerWait 1659.9, Driver.WorkerWait.dequeue_order 1423.1, Driver.Packet.draw 1215.9, Driver.Draw 1214.6, Graphics.Draw 986.8, Graphics.Draw.draw_and_resource_release 963.7, Driver.Packet.dispatch 564.2, Driver.Dispatch 523.0
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
B (this head + #11580 + #10304): trace_digest.py
seconds 960:30 from present 3346: 24 presents, frame p50 1264.3 / p90 1638.0 / p99 1663.6 / max 1663.6 ms, GPU busy 244.2 ms per present
NVIDIA GeForce RTX 3070 Laptop GPU, NVIDIA 617.42, Windows 10.0.26300, 3840x2160, commit bd421aa3c2fb, dropped: no
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 3655.9, Driver.Packet.memory_wait 2132.6, Driver.WorkerWait 1403.0, Driver.WorkerWait.dequeue_order 1178.5, Driver.Packet.draw 968.5, Driver.Draw 967.4, Graphics.Draw 858.5, Graphics.Draw.draw_and_resource_release 839.2, Driver.Packet.dispatch 524.4, Driver.Dispatch 482.3
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
a8e7e2f8a7(the same build, relinked for that title), with its own usual switches: `APS5_STORAGE_CACHE_ENTRIES=1024 APS5_THREAD_PRIORITY=high APS5_PROFILE_DRAW=1` (`APS5_STORAGE_CACHE_ENTRIES` is #14220's cap, which isn't on `main`), no LAZY or NO_GPL, and a cold shader cache. It ran 15 min through the logos into its menu. Not a timing run. - **No `bypassed` line in the whole run.** The hit rate per 10 s block stayed between 15.8% and 75.0%, median 19.8%: 1,262,160 hits in 6,381,888 lookups. - The cache sat at its 4,096-entry cap, ~14-15.5 MiB of the 256 MiB budget, turning over by entry count.Resident Evil Village (PPSA01556), with the draw-cache budget off (an earlier pair, 2026-10-28 morning). Static main menu, 16 min each run after an unmeasured warm-up, unprofiled, B A A B.
main85a4d7f8c8plus #9129 and #8926 (both merged since), our local table-index and Village-harness commits, a local scePadOpen answer and a diagnostic print, with the bypass commit on top (7bc49ce4d0).APS5_LAZY_SHADER_PREPARE=1 APS5_NO_GPL=1 APS5_HOST_IMPORT_MIB=6400 APS5_TRACE_SUMMARY_EVERY=10, andAPS5_DRAW_CACHE_BYTES=1099511627776(budget off) in every run.APS5_DRAW_CACHE_BYPASS_PERCENT=0(no bypass); B leaves it unset (5%).Driver.Packetms per frameDriver.Packet.memory_waitms per frameSummary lines (the last interval of B's and A's first runs)
The traces themselves, the four runs'
aps5-summary.jsonlfiles with every 10 s interval, stay on the test machine.tools/trace_digest.py's text output for the same two runs is in a comment. Those lines share one commit because the arms differ only in the environment. The pair above comparesmainand this PR as two builds.58171b22e8, a merge ofmainedf6804cf5(run, validation run). The merge was clean:CMakeLists.txt,Driver.hppandENVIRONMENT.mdmerged without conflicts, and the PR's patch-id is unchanged. The Village pair, the captures and the profiled runs above were measured ona8e7e2f8a7, whose patch this merge doesn't change.^agc_driver_draw_cachetest ×10. Linux: 13 run, 13 pass, 0 skip, 0 fail. Windows: 13 run, 0 pass, 13 skip, 0 fail, since the runner has no Vulkan device. The libc and libkernel suites run 191 and 291 tests on Linux and 220 and 314 on Windows, with 0 failed. The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.VERIFY_VALIDATION=1on GitHub's Linux runner, llvmpipe (LLVM 20.1.2, Mesa 25.2.8)),mainedf6804cf5against58171b22e8: 13 passed, 0 skipped.mainhas no bypass tests, so its arm ran the other^agc_driver_draw_cachetests.VUID-VkDeviceCreateInfo-pNext-pNextappears in both arms, and the merge adds none.14209e93ba, a merge ofmainebb4075168, on top ofc7981bcb3band40973d322a(run, validation run). The merge was clean.^agc_driver_draw_cachetest ×10, the bypass and cold-scene tests included:APS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.VERIFY_VALIDATION=1on GitHub's Linux runner, llvmpipe (LLVM 20.1.2, Mesa 25.2.8)),mainebb4075168against this head:mainhas no bypass or cold-scene tests, so its arm ran the other^agc_driver_draw_cachetests.VUID-VkDeviceCreateInfo-pNext-pNextappears in both arms, and the change adds none.05d2faab6c:11e29b3107, the window race fix, then a merge ofmain76fd1c09e9(run, validation run). The merge was clean.^agc_driver_draw_cachetest ×10,ConcurrentClosesKeepTheirOrderincluded:APS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.VERIFY_VALIDATION=1on GitHub's Linux runner, llvmpipe (LLVM 20.1.2, Mesa 25.2.8)),main76fd1c09e9against this head:VUID-VkDeviceCreateInfo-pNext-pNextappears in both arms, and the change adds none.Resident Evil Village (PPSA01556) on the new base, draw cache at
main's defaults, static main menu, B A A B, one block, 2026-10-29 (PT), unprofiled.mainebb4075168, B =14209e93ba, each with the same localscePadOpenanswer and #11580 and #10304 merged. The A-to-B diff is exactly this PR's diff overmain.APS5_LAZY_SHADER_PREPARE=1 APS5_NO_GPL=1 APS5_HOST_IMPORT_MIB=6400 APS5_TRACE_SUMMARY_EVERY=10and the pad replay, no draw-cache variables, one shader cache warmed by an unmeasured cold run; 0 misses after b1's first 10 s.14209e93bamainebb4075168Driver.Packetms per frame (median)Driver.Packet.memory_waitms per frame (median)167947744a, the tests' cost (test-only):Why: on an NVIDIA RTX 2000 Ada with the validation layers on, the four bypass tests ran past ctest's 120 s timeout and took 146 to 326 s alone. There, each draw that misses the cache or is bypassed costs about 10 to 20 ms.
What changed: the low-hit-rate and stage-hit cases draw only the lookups whose outcome they check, and note the rest of each 2,048-lookup window on the driver's bypass through
DriverTestAccess. The cold-scene case keeps only its 1,000-draw scene, the one that is red on the head before the warm-up fix. No production code changed.What moved: the draw-level checks stay draw-level, with fewer draws, including the draw whose pixel constant changed and must write the new colour. The third low window's 4,096-draw bypass, the draw after it, and the window of hits that ends a run are
LowWindowsLengthenTheBypass's, which now also requires that no draw is bypassed before the window that starts the bypass has closed. The stage-hit case now notes one low window first, so stage hits that didn't count as useful would start a bypass.Times on GitHub's Linux runner (llvmpipe),
05d2faab6cagainst this head:agc_driver_draw_cache_cold_sceneagc_driver_draw_cache_cold_scene_offagc_driver_draw_cache_low_hit_bypassagc_driver_draw_cache_low_hit_bypass_off×10 (run), every
^agc_driver_draw_cachetest:APS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.Validation (run),
main76fd1c09e9against this head: 15 passed.VUID-VkDeviceCreateInfo-pNext-pNextappears in both arms, and the change adds none.Still red on
58171b22e8, the head before the warm-up fix (run): the trimmedagc_driver_draw_cache_cold_scenefails with "frame 4 of a scene that repeats the same 1000 new draws every frame hit 0 of them, expected at least 90%", and its_offarm passes. On Windows both skip.Resident Evil Village (PPSA01556) on
167947744a,main6472c708ae, draw cache atmain's defaults, static main menu. B A A B, one block, 2026-10-30 (PT), unprofiled.measure/12478-a-main-6472c708ae):main6472c708ae, plus the localscePadOpenanswer (a0486e8917), QRMOE's #11580 (fedf3e91a7,dbf2107ba6) and Ondra97's #10304 (e0d6e062a9).measure/12478-b-head-167947744a): the same, with167947744amerged. The A-to-B diff is exactly this head's 8 files.libSceAgcDriver.prxdiffers by this head's code, and five others differ only in PE timestamp and checksum bytes.APS5_LAZY_SHADER_PREPARE=1 APS5_NO_GPL=1 APS5_HOST_IMPORT_MIB=6400 APS5_TRACE_SUMMARY_EVERY=10and the pad replay, with no draw-cache variables. One shader cache was warmed by an unmeasured run of A; its key, 5ccd6c63be592224, was the same before and after every run.As measured: B's mean is 0.663 fps against A's 0.585 (+13.3%), and both B runs are above both A runs. The two A runs are within 0.9% of each other, and the two B runs within 1.0%. Median phases, B against A:
Driver.Packet4,176 against 4,828 ms per frame,Driver.Packet.draw1,120 against 1,294, andmemory_wait13.8% lower.Load: non-game CPU in the window was 43.8, 42.9, 41.8 and 36.1%. b2 ran lighter than the other three. On the three within 2 points of each other, b1 against the A mean is +13.9%.
Health: no failed host imports and no stop line, and the menu was first seen at +5.5 to +6.2 min. a1, a2 and b2 each logged one presenter FATAL at close time, after the window. Pixel comparison of the static regions at menu +10 shows B rendering like A.
Not attributed to this change. One profiled boot of each tree, with
APS5_PROFILE_DRAW=1added, over the same window. That switch turns off the finisher hand-off, so the boots are compared only with each other:[draw-cache] bypassedin 0 of the window's 57 ten-second blocks. All 12 of its bypass lines came during loading, 50 to 610 s after launch.main. It adds adrawKeySeenlookup underdrawCacheMutexfor each lookup that doesn't hit, a relaxed atomic load per draw and a compare-exchange per lookup.Captures, as the Performance report form describes: one traced run per arm on the same trees and cache, A (16:21–16:43) then B (16:44–17:06) in one session, with
APS5_TRACE_SECONDS=960:30and the pad replay, and no other trace or profile switch. The window opens 960 s after the first present, at about menu +11 min. Neither trace dropped events. GPU clocks weren't logged for these two runs.Driver.Packet3,884 against 4,051 ms per frame, of whichmemory_wait2,284 against 2,363 andPacket.draw1,054 against 1,065; GPU busy per present 237 against 248 ms.aps5-trace-237e88d4ff9c-28876.json.gz(2.6 MB) and Baps5-trace-05bae016f8dd-11428.json.gz(2.4 MB). Theirtools/trace_digest.pyoutput is in this comment."dirty": true. That'strace_revision.cmake's porcelain check seeing only3rdparty/freetypeas modified:main's new freetype pin has a nestedsubprojects/dlgthat can't be fetched. With submodule content ignored, the status is empty, the same in both trees, so neither tree has a source change beyond its commit.aps5-summary.jsonlholds them (A, then B):eaafdf934b, the cold-scene case's cost (test-only;DrawCacheReuse.cpp, +6 −3). The pair above ran on 167947744a's library code, which this head doesn't change.167947744a,agc_driver_draw_cache_cold_sceneand_offtook 93.3 and 94.8 s with the validation layers on. Each arm drew a 1,000-draw scene for 4 frames, 4,000 draws._offarm are unchanged.|| drawKeySeen(drawKey)removed fromdrawCacheBypass.Note(...)): the default arm fails, "frame 4 of a scene that repeats the same 128 new draws every frame, after a low window and with the scene's first two frames closing the next one, hit 0 of them, expected at least 90%";APS5_DRAW_CACHE_BYPASS_PERCENTignored: the_offarm fails too;LowWindowsToBypass = 1): the default arm fails.167947744a. It passed with 0 new failures and no new validation IDs.^agc_driver_draw_cache_test:APS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.da441e01cc, a merge ofmain0836dfdf4f(run). #12862 movedlibSceAgcDriver's test registrations intotests/cmake/; the conflict inCMakeLists.txtis resolved withtools/agc_test_split.py resolve, which moves this PR's registrations intotests/cmake/agc_driver_draw_cache_reuse_tests.cmake(+12 lines). Nothing else conflicted. Apart from the move, this PR's diff is unchanged. With-DBUILD_TESTING=ON,ctest -Ngives 3079 tests:main's 3075 plus its 4 tests, each listed once. The 16 tests matching^agc_driver_draw_cache_pass 10 runs in a row. Linux: 16 run, 16 pass, 0 skip, 0 fail. Windows: 16 run, 0 pass, 16 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (199 and 308) and on Windows (226 and 330). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.NVIDIA, TechLevelZero's GPU runner (report):
da441e01ccmerged ontomain0836dfdf4f, NVIDIA RTX 2000 Ada Generation, driver 595.99.02, Linux. Passed: 2,447 passed, 0 new failures (4 fail onmaintoo, and 2 are unstable there), and no new validation IDs againstmainover 928 tests run on the GPU.Checklist
main; no other open PR implements the same functions (see Overlap)NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file: n/a, none added.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T15:46:18Z.
Review: CHANGES_REQUESTED
I reviewed the exact head
3e4d8e25f2. Two items need resolution before approval.APS5_DRAW_CACHE_BYPASS_PERCENT=5is documented as bypassing when fewer than 5% of 2,048 lookups hit. ButminimumHits = 2048 * 5 / 100truncates to 102, and the test explicitly treats 102/2,048 (4.9805%) as meeting the threshold. If the documented percentage is literal, the minimum count should beceil(2048 * percent / 100)(103 for 5%), and the boundary test should cover 102 versus 103. Alternatively, document that the integer threshold is rounded down and test that contract.The
perfevidence still does not show the required main-versus-change capture. The summary lines in the body use commit7bc49ce4d0c9for both bypass-on and bypass-off runs; settingAPS5_DRAW_CACHE_BYPASS_PERCENT=0on the changed binary is a useful control, but it is not a capture onmain. The red/green test run is onmain04fefebe90, and the requestedVERIFY_VALIDATION=1comparison is still listed as running. Please add matchedmainand exact-head captures/traces/digests and finish the validation comparison on the current basef8f5b24b77ad. I did not independently run the GPU tests or capture.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T05:22:51Z.
Review: CHANGES_REQUESTED
Re-checked — changes requested
The new report fixes the threshold/stage-hit findings and includes paired traces and digest output, but it still does not meet the performance form’s capture requirements, and this head is based on an older
mainthat changed two touched paths.What I ran
a8e7e2f8a72888acfc3aa9bcb4c9a90bb711f0b8against currentmain52c09d567d2fa453494dd720fcf53a98149468e4.git merge-tree --write-tree,git diff --check, and compared paths changed on currentmainsince the PR merge base.Results
c2666560a7cb061410bce876ecbe3881bbca4589319621ba2e578bd053b0baba2877fe70520e0737; current main has 204 later commitscore/libs/prx/libSceAgcDriver/CMakeLists.txtandcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hppa8e7e2f8a7vs main319621ba2eaps5-summary.jsonllines are pasted for the paired main/head captures. The captures setAPS5_TRACE_SUMMARY_EVERY=10, an additionalAPS5_TRACE_*switch prohibited by the formRaw output
Negative control
Findings
Blocking
trace_digest.pyoutput and says theaps5-summary.jsonlfiles stay on the test machine. The report form requires the actual summary line for each compared capture. Please paste the exactaps5-summary.jsonlline from the main run and the exact line from this-head run; the digest JSON objects are not substitutes for those lines.APS5_TRACE_SUMMARY_EVERY=10, in addition to the permittedAPS5_TRACE_SECONDS=960:40. The form explicitly says to set no otherAPS5_TRACE_*orAPS5_PROFILE_*switch because they cost time. Please recapture the same main/head scene without that extra switch, paste both summary lines, attach the two traces, and includetrace_digest.pyoutput for those exact traces.mainand rerun the focused draw-cache tests and validation comparison on that exact integrated head. Current main changed bothCMakeLists.txtandDriver.hppafter this branch’s base, so the existing exact-head test and performance reports do not cover the current tree.Non-blocking
Packet.dispatchis higher on the change. Keep both effects visible in the report.Sources
Not verified
To get this to a good state
Rebase onto current
main, rerun the focused draw-cache/validation tests, then capture main and the rebased head on the same machine and scene with only the required trace setting. Paste the exact twoaps5-summary.jsonllines, attach those two traces, and include digest output generated from those same traces.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T08:36:04Z.
Review: CHANGES_REQUESTED
Re-reviewed exact head
58171b22e89daedc60672482d0eb349b36609ac1and your new test report. The draw-cache tests on this head and the validation-layer comparison are useful; they address the focused correctness run. The branch’s merge base is stilledf6804cf52c62eacafc592dd6142cb4efe5bd05, not currentmain4c7d275bef89d309313d16bc2bc05d37a1b50be2. Current main changedCMakeLists.txtandDriver.hpp, both touched by this PR. The report’s perf pair also remains against an older baseline, so please integrate current main, rerun the focused validation comparison, and refresh the matched performance capture against that current main and the resulting head. Merge preview is clean; diff check and conventions pass. I did not run GPU tests locally.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-29T22:03:44Z.
Review: CHANGES_REQUESTED
Thanks for the work. The threshold, the single-word window and the tests look right. What blocks it:
DrawCacheBypass::Note(Draw.cpp:664) counts a hit only when a cached draw of the same shape exists. With second-sight admission the first two sightings of every draw miss, so on a cold start with more than ~700 distinct draws per frame the first 2,048-lookup window stays under 5% and the bypass starts. While it runs no sightings or inserts happen, so warm-up takes 14-19 frames against 2 onmain. You agreed in your reply; please push that fix. A lookup whose keyDrawKeySightingshas already seen should count towards the window, or the bypass should need two consecutive low windows. Scenes whose keys never repeat must still bypass.APS5_DRAW_CACHE_BYPASS_PERCENT=0. It has to fail on this head.Draw.cpp:391takesdrawCacheMutexfor every bypassed draw only to bumpbypassed; make it an atomic.dataCandidatesnot empty) before the data and push-offset checks. Say what is counted, here and inENVIRONMENT.md.main(it changedCMakeLists.txtandDriver.hpp) and rerun the draw-cache tests and the perf pair on the new base.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T00:42:14Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The new head adds the warm-up and accounting changes, but concurrent window closures can violate the documented rule that a useful window resets the low-hit streak; current-main tests and a current-base performance pair are also still missing.
What I ran
14209e93badbf5cc32aa2122a803c3bc2052b0c0. Its merge base isebb4075168e9d96a2b3f177d9e6cda6900326e27; freshly fetched upstreammainis401e4babaa18afaf02d3f0c32ba13f9b8c8e4d66.mainwas clean. Currentmainand this PR both changecore/libs/prx/libSceAgcDriver/CMakeLists.txtanddocs/dev/ENVIRONMENT.md.Results
ENVIRONMENT.md14209e93baagainstmainebb4075168; I did not run them.Unedited output from the local checks
Negative control
Findings
Blocking
windowcompare-exchange closes each 2,048-lookup window, but each closing thread updateslowWindowsafterward using a separate load/store. If a low-window closer reads the old streak, pauses, and a following useful-window closer stores zero, the first closer can then store its stale increment. One subsequent low window can therefore start bypass even though a useful window intervened, contrary to the documented “a useful window ends the run” behavior. Please make the streak update linearizable in window order and add a concurrency regression that verifies a useful window resets the streak when adjacent close handling overlaps.ebb4075168, while currentmainis401e4babaa; both changedCMakeLists.txt, which this PR also changes. Please validate the focused tests and validation comparison on an integration with currentmain. The PR description also says the matched Resident Evil Village capture pair for the new head is pending. The performance form requires same-machine, same-session base/change captures and their summary lines; please add the exact lines, traces, and digest output for currentmainand the corrected head.Non-blocking
main; the merge preview alone does not substitute for tests on the integrated tree.Sources
mainNot verified
I did not build or run tests, validation layers, a console/game session, or performance captures locally. The PR’s reported test/validation runs cover its stated
ebb4075168integration, not currentmain401e4babaa. Hosted Windows passed; product Linux and specialized jobs were skipped.To get this to a good state
Serialize the low-window streak decision with window completion, add a concurrent reset regression, integrate or otherwise validate against current
main, and attach the matched performance pair for that resulting head. I will rerun the same source checks and reassess the exact new head and reported tests/captures.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-30T02:42:34Z.
Review: CHANGES_REQUESTED
Thanks, the five points are all in: warm-up, atomic counter, description, base, and the window-close race. I read
Note/Skipand the single-word state looks correct. What still blocks it:perfand adds a new window, env var and counters. Please show one scene where the bypass starts under the "seen before counts as useful" rule and the gain is outside noise, withtools/trace_digest.pysummaries ofmainand the change from the same machine and scene. You have the profiled boot pending; post it. Without a scene where it fires and helps, the change adds complexity for nothing, and the direction would be to drop it.14209e9),agc_driver_draw_cache_cold_scene,_off,low_hit_bypassand_offall hit the 120 s timeout in the parallel run and passed only on a 360 s retry. Please cut their draw counts or frames so each runs well under the default timeout with validation layers on.Everything else from the last review is met. Once a measured gain is posted this is ready to merge.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-30T04:33:21Z.
Review: CHANGES_REQUESTED
Thanks for the test commit: drawing only the lookups the cases check and noting the rest of each window on the bypass should cut the draw counts well below the 120 s timeout (the NVIDIA rerun on
167947744awill show it). One point still blocks this:perfand adds a window, an env var and counters. Please post one scene where the bypass starts under the "seen before counts as useful" rule and the gain is outside noise, withtools/trace_digest.pysummaries ofmainand the change from the same machine and scene. If no scene fires and helps, the direction is to drop the change.Also, @MarcZX10 asked for the
VUID-vkCmdCopyBuffer-commonparentinagc_driver_depth_clear_hleon the NVIDIA report to be attributed (same-head repeat, or the test againstmain); please answer that too.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T16:32:17Z.
Review: CHANGES_REQUESTED
Re-checked — new head, changes still needed
The atomic window-state fix addresses the earlier race, but the updated performance change still lacks a matched capture pair for the reviewed head against current
main.What I ran
Reviewed head
167947744aff84d8c890b9c4ef349bae799283a1. GitHub reports the PR base snapshot as76fd1c09e9be0465d50a7431a79d371a5a10abb2; current upstreammainis8f756acf599027be651dadb392506dbbd4b785e9. The read-only merge preview onto currentmainwas clean (23003b378c7cbbcc136f8388348fc38d7d25c8f4). Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0. No build or test executable was run.Results
mainmainf6fddd6, not currentmain8f756acf.maincapture, summary-line pair, attached traces, or trace digests for this head. Existing Village captures in the description are from older code; the description says the pair for the warm-up-fixed branch was queued.Unedited output from local checks
git diff --checkexited 0 with no output.The isolated precheck reported these helper errors:
Findings
Blocking
main. The latest Crysis profile is useful evidence that a low-hit workload exists, but it reports only the changed build. The older comparison predates the warm-up and atomic window-order fixes. Since this is aperfPR and the branch still describes the bypass as cutting wasted work, please capture currentmainand this exact head on the same machine, title, scene, and settings. Add bothaps5-summary.jsonllines, attach both traces, and includetools/trace_digest.pyoutput for each trace.Non-blocking
f6fddd6integration rather than currentmain; the local merge preview establishes clean application, not test coverage of that integration.Sources
CONTRIBUTING.mdat currentmainmainNot verified
To get this to a good state
Add the matched current-main/current-head capture pair, both summary lines, traces and digest output. I will rerun the same source checks and review the new evidence against the resulting head.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-31T03:49:24Z.
Review: CHANGES_REQUESTED
The cold-scene test change is fine: 128 draws after one noted low window, and it is red when the warm-up is removed. The library code is the same as
167947744a, which I already read. One point still blocks this, unchanged from the last two reviews:main/ change pair from the same machine and scene with theaps5-summary.jsonllines andtools/trace_digest.pyoutput, plus the[draw-cache] bypassedlines showing it fired during the measured window. @ntamas94's Crysis Remastered profile (~2% hits, 110k of 113k lookups "no entry") or the Red Dead Redemption case from #5404 are candidates. If no scene fires and helps, the direction is to drop the change.@MarcZX10's
VUID-vkCmdCopyBuffer-commonparentquestion inagc_driver_depth_clear_hleis answered in your reply (not repeated on 167947744a's NVIDIA run); I'm not asking for more there.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-31T22:16:24Z.
Review: CHANGES_REQUESTED
The head only merges main into
eaafdf934b; the range-diff of the 8 commits is empty, so the previous review stands. One point still blocks this:main/ change pair from the same machine and scene with theaps5-summary.jsonllines andtools/trace_digest.pyoutput, plus the[draw-cache] bypassedlines showing it fired in the measured window. Crysis Remastered or the Red Dead Redemption case from #5404 are candidates. If no scene fires and helps, the direction is to drop the change.Pull request closed