perf(agc): run first the library prebuilds of programs a submission binds #13667
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13667"
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 chitters2004 on 2026-10-30T22:37:04Z.
What
Library prebuilds run in FIFO order on the prebuild pool. On a GTA V (PPSA04263) cold boot that queue holds thousands of speculative prebuilds from resolved shader ABIs, about 9,000 at about 190 ms each, so the prebuild of a shader the next draw needs can sit behind a minute of work. The draw committer then builds the same library part synchronously. Attributing every committer part build on one boot, 15.1 s of 41.5 s came from a prebuild still queued when its draw arrived.
Each queued prebuild now carries its program address.
Driver::SubmitandDriver::executeRewindTailscan the copied commands for the program address registers written bySET_SH_REGandSET_SH_REG_INDIRECTlists, and move matching prebuilds to the front, keeping their order. The tail scan matters because this title streams most of its draws through REWIND tails, which never pass throughSubmit. InSubmitthe promotion runs afterAwaitRegistrationPreparation, so prebuilds queued during that wait are included.The scan is a potentially inaccurate scheduling hint. A pair split across submissions uses the last high half seen, predicated writes are read as if taken, and when no tagged prebuild is waiting the scan is skipped, so the retained high half can be stale. An approximate address can match a different queued program and move that prebuild forward. The pool keeps the same tasks and their order within each group, and draw behaviour does not change.
When no tagged prebuild is waiting, for example after the pool drains or with library prebuilding off, a submission pays one relaxed atomic load and no scan. Addresses are sorted and deduplicated once per submission, and the queue tests membership by binary search.
Overlap: #6867 scans the same registers at submit to narrow the registration wait. This PR orders a different queue (the library prebuild pool) and adds no wait. Whichever lands second can share one scanner; #6867's rejects partial pairs and omits
0x048, which this needs.The debt entry for prebuilt libraries still said one background thread; it now says the pool.
Tested
Windows 11, AMD Ryzen 7 5800X, NVIDIA GeForce RTX 3080, driver 621.01, Release, GTA V PPSA04263, same pad input, in one session on the same machine. Every run below is this PR's exact head
a7c1dfcd01or its base. A ise8efeed58a+ #11580 (b479f93c7a08); B is A + this PR (207067f9c900). #11580 is on both sides becausemainstops at Story load (#11425); this PR does not depend on it.Cold boots with empty shader and driver caches, alternating A, B, A, B, then a third A to rebuild its cache for the warm run. This is the claim of the PR, so these are cold by design, unlike the warm captures the Performance report form asks for.
Story load to gameplay falls by about 13 s, from 53.2 s to 40.7 s on average, and the longest frame by about 1.3 s. Fps while draining and steady frame time are unchanged within noise, and after the drain both sides stay CPU-bound on the draw committer (78 % busy, GPU busy about 36 ms per present).
Warm captures as the form describes: the scene ran once, the title was restarted on that cache, and the window is 12 s of gameplay. This shows the change costs nothing once caches are warm; it is not expected to help there.
The higher p90 and p99 in this 12 s window do not repeat over longer stretches: averaging the 10 s intervals from 100 s on, a first warm pair over about 80 s gave p50 109.0 and 106.0 ms, p90 114.3 and 111.9 ms, p99 138.4 and 138.6 ms for A and B, and this pair over about 30 s gave p50 105.1 and 103.6 ms, p90 112.2 and 114.0 ms, p99 143.2 and 138.3 ms.
tools/performance_compare.py, which reports differences and no verdict:Deviations from the form: the log is redirected and frames are dumped on every run, because the script that drives the menus reads both, so the two sides pay the same cost. The cold boots add
APS5_TRACE_SECONDSfor the window after the drain. Trace buffers reported dropped events on every run, at the defaultAPS5_TRACE_EVENTS.Overhead, measured inside
agc_driver_library_prebuild_priorityona7c1dfcd01with a temporary timer that is not committed. These are synthetic CPU measurements on this machine, using the reviewed worst case of 32,000 distinct binds in 128,000 dwords against 9,000 queued tagged prebuilds:aps5-summary.jsonllines, warm A and warm B, then cold A2 and cold B2:Traces: warm A, warm B, cold A2, cold B2.
tools/trace_digest.pysummaries:Cold A2
20 intervals, 0.0 to 324.6 s, 3647 presents
NVIDIA GeForce RTX 3080, NVIDIA 621.01, Windows 10.0.26220, 3840x2160, commit b479f93c7a08
Cold B2
21 intervals, 0.0 to 323.2 s, 3685 presents
NVIDIA GeForce RTX 3080, NVIDIA 621.01, Windows 10.0.26220, 3840x2160, commit 207067f9c900
agc_driver_library_prebuild_priorityis new: it blocks the pool, queues two tagged prebuilds and checks the bound one runs first for a pixel pair, a low-only rebind with a retained high half, and the legacy vertex pair, and that binding another program keeps FIFO order. It also runs a 32,000-bind submission against a 9,000-task backlog, checks that the bound prebuild runs first, that no task is lost or repeated and that the rest keep their order, that an unused or drained pool reports nothing waiting, and that a submission with no prebuild waiting is not scanned. That last check fails when the guard is removed, and the first ones fail with promotion disabled.Paired validation of
a7c1dfcd01merged intomain(9d4f66d0af) againstmainat21668cc9d8, on the same machine and GPU withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, patternagc_driver_prepared|library_prebuild|compute_prebuild|frame_replay|frame_capture: 43 of 43 pass on the change and 42 of 42 onmain, the extra one being the new test. No log containswas not found but was requested by env var VK_INSTANCE_LAYERS. Both logs hold the same 14VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605lines, so the change adds no newVUID-errors.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T22:47:17Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The code change appears focused, but this
perfPR does not yet provide the repository-required, comparablemainand exact-PR-head capture evidence.What I ran
Reviewed head
01b6d0486948ea69614fa0cf945a5179e2604ab9against PR basee8efeed58af48d0682ab2e0eab72cfaf996e4886; the stack/mergeability precheck passed. Environment: Linux x86-64, Python 3.11.2; no compiler, build, CTest, or GPU run was performed.Results
aps5-summary.jsonlrecords or links to attached trace files. It identifies the comparison asmain + #11580versusthis PR + #11580; the stated commits (28a914225ed4andc99f4eef257e) are not the current target basee8efeed58af48d0682ab2e0eab72cfaf996e4886and exact PR head01b6d0486948ea69614fa0cf945a5179e2604ab9. I could not runtools/trace_digest.pybecause no trace files were attached or linked.Unedited output from checks
Conventions:
Hosted checks at the last refresh:
git diff --checkemitted no output and exited 0.Findings
Blocking
The required performance evidence is incomplete and does not identify measurements for the current
maintarget and exact PR head. Without the raw summary records and corresponding trace files, the reported improvement cannot be independently matched to this change or reproduced. Please paste theaps5-summary.jsonlline for a capture on currentmainand one for this exact PR head from the same title, scene, and machine; attach both traces; and include the unedited output oftools/trace_digest.pyfor each. If #11580 is needed to reach the scene, explain the dependency and provide a comparable baseline tied to the current target state.Non-blocking
No source-level defect was confirmed from the reviewed diff.
Sources
Not verified
No local build, C++ test, Vulkan validation run, or GPU performance capture was run. Hosted Windows was pending; Linux and specialized jobs were skipped. The author-reported test and timing results were read from the PR description and were not independently reproduced.
To get this to a good state
Add the comparable current-main and exact-head performance artifacts described above. I will re-check their commit identities, machine/scene match, and digests, then re-run the same applicable checks on the new head.