perf(agc): prepare registered shaders outside the publication lock #2363
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2363"
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 jweidenh on 2026-10-09T16:23:45Z.
What
Driver::RegisterShaderholds the process-wide preparation writer lock while planning a private shader registration. Independent registering threads therefore wait behind that work, including full preparation whenAPS5_SYNC_SHADER_PREPARE=1.Move that acquisition to publication. For an identical registration, capture the matching immutable snapshot under the driver mutex, release the mutex, acquire the preparation writer, then reacquire the driver mutex and publish through
PublishRegisteredShader. Fresh registrations plan privately before acquiring the same locks in that order. The transaction still exists from function entry, so a caught registration failure aborts an enclosing preparation transaction.Current head
871012973005bae1e7e40c63d6c099e010ea4489is based onmain5aaf26bd325607f65bde28741a4e82ceaaf586c0. It preserves upstream94cffec3's lazy transaction implementation and existingHold()API unchanged;Read,EditandHoldacquire the writer, while an emptyCommitdoes not. No new transaction constructor or locking API is needed. The production diff is confined to registration lookup, planning and publication. Background scheduling, pending/failure waits, header reuse, ABI preparation and rollback retain upstream behavior.This is a concurrency correction, with no demonstrated affected-title startup benefit. The original reporter has already supplied the requested #2292 measurements; they are summarized below. No startup or
FThreadHeartBeatfix is claimed.Tested
git diff --checkpass for871012973.72fcef76d84a5ae356a746c8d8ed078d0bb4840c:871012973plus the Windows build guard from #4021 at121b16fb4bbd47ff4ce9302c40631bab858e3e71. That historical overlay fixed upstreamHostPollcompilation errors; onlySocket.cppdiffers from this PR. #4021 has since merged asbca7a29d259299aaa8972c94d12694232bb3bb08on October 11; the recorded validation source remains unchanged, and this PR does not duplicate its patch. Source pins, test inventory, separate preparation modes, exact completion markers, GPU identities, raw JUnit/logs, and 30-second limits were verified. No earlier benchmark or baseline failure was rerun.The concurrency tests explicitly hold the publication writer, verify that private registration reaches its expected planning/translation failure without waiting, and check that a duplicate registration does not hold the driver mutex while waiting for publication. They also cover lazy
Read/Edit/Hold, nested locking and rollback, eight concurrent registrations/resolutions, and subsequent dispatch. Both asynchronous and explicitly synchronous preparation modes remain separate tests, with 30-second limits.Affected-title measurements already supplied
The original #2292 reporter's October 11 results identify STAR WARS: Galactic Racer (PPSA28416), Windows 11, RTX 5090, MinGW-w64 GCC 15.2.0, Release. Both arms used newer
main1e8fff68with identical referenced and unpublished bring-up patches; the reported only difference was this PR's earlier five commits through58d31147. This is independent integration evidence, not a reproduction of the current rebased head.Both shader and Vulkan pipeline caches were warm, save data absent,
APS5_PROFILE_DRAW=1andAPS5_NO_SNAPSHOT_CHECK=1; the title's command line keptFThreadHeartBeatactive. The milestone was the first[present]statistics line, printed per 10-second window containing presents—a coarse upper bound, not exact first-frame latency.All six runs remained alive at the 150-second cap without a heartbeat kill. The results show no clear startup benefit or regression. For cold caches, the reporter observed no preparation-transaction waiters and attributed the remaining heartbeat kill to long NVIDIA compute-pipeline compilation; they attributed removal of the original registration-lock stall to #2583. These are the reporter's observations, not independently reproduced here.
The reporter also saw intermittent heap corruption in parallel preparation-test batches: 3/10 with this PR, 3/10 without it, and 3/10 on clean
main1e8fff68. That comparison does not establish a regression from this PR. The earlier changes-requested review predates the supplied title measurements; maintainer acceptance remains pending.Historical correctness and synthetic performance evidence — older revisions only
58d31147on basee8d6de4a, private self-hosted Linux run 38097454684 passed the Release/patched-library builds and 26 executions across 14 preparation/frontend test names, with no failures or CTest skips. Its inventory check found all 598 test executables registered; it did not execute the full suite. A duplicate-path lock-inversion mutation failed both concurrency modes at the intended assertion; restoring the exact source passed both. Environment: Ubuntu 24.04, GCC 13.3, Mesa 25.2.8 lavapipe/LLVM 20.1.2, SPIRV-Tools, required Vulkan and fresh caches.58d31147integrated into then-current main. No exact integration SHA or toolchain was specified. This is reported integration evidence, not validation of871012973.2567e8f997e8e0728943e801076d3fab07ca13ad, comparede8d6de4awith58d31147, both including asynchronous preparation. All 16 pilot and 240 full processes passed output/cache checks. Five paired trials per case used 12 tiny/arithmetic compute shaders, one/two/four callers and cold/warm caches; registration return and artifact/ABI readiness were timed separately, with dispatch/readback outside timing. Default-async readiness ratios ranged from 0.898–1.204×, showing mixed results and no consistent overall improvement. The separate synchronous control favored the candidate in all 40 multi-caller pairs, with readiness ratios of 1.763–1.985× for two callers and 2.572–3.412× for four. CPU work did not uniformly decrease. These synthetic results do not measure title startup or this rebased head; physical-host exclusivity was not established.346a6e73with the earlier #3159 implementation passed 32 selected executions and lock-order negative controls in run 38138738761. Its transaction design is superseded by upstream's now-merged lazyHold()implementation; those results are not attributed to this head.7371e448passed both concurrency modes and an eager-lock negative control. It included no title or performance measurements. Older synthetic synchronous speedups, including the approximately 3× four-caller results in run 38029920550, predate asynchronous preparation and do not establish current default-path gains.26a670a7reported 490 passes, 26 capability skips and oneagc_driver_flat_storetimeout among 517 tests. The same fence-wait failure was reproduced on unmodifiedd70b8998; the test and timeout remain unchanged. These historical outcomes are not a current full-suite result.Author-run Linux evidence used only locally managed self-hosted runners. Linked private workflows/artifacts require validation-repository access. The historical synthetic benchmarks, independently reported title results and current correctness validation are separate evidence sets.
Checklist
main5aaf26bd; preserves merged lazy transaction behaviorImported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-09T17:52:29Z.
Tested on Linux (CachyOS x86_64, Intel RPL-S iGPU / Mesa 26.3.0-devel / Vulkan 1.4.363, GCC 16.2.1) at
26a670a7:/tmp/anyps5_build) with zero warnings/errors.python3 tools/check_conventions.py --base origin/main --head HEAD-> PASS (0 errors).LGTM!
Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T19:42:30Z.
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
26a670a7, merged ontomain8b393b6ein one build with 31 other PRs that had no Windows run.agc_driver_registration_concurrency.guest_offline_imports, broken by #2359 (reported there).No title was run.
🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T05:19:00Z.
Does the title from #2292 get past the
FThreadHeartBeatkill with this change? Perf PRs need before/after numbers for the change alone (#218); start-up time on that title with and without it would do.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T07:32:08Z.
@oneandonlydean you asked whether the title from #2292 gets past the
FThreadHeartBeatkill and for before/after numbers for this change alone (#218).8e5e9a3:agc_driver_registration_concurrencybuilds and passes locally.Question: is the synthetic A/B enough for #218, or do you want a start-up measurement on the #2292 title first? If so, @mrk1987 could you time the title with and without this branch?
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T08:06:40Z.
The synthetic A/B covers #218 for the lock change itself. The PR is for the #2292 kill, though, so I'd like the start-up time on that title with and without it before merging; the single-worker case is slower, so it should show a gain there.
Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-10T13:43:12Z.
Independent validation on real hardware (correctness/concurrency, not performance)
Built and ran the PR head
7371e448on my own box:Release,BUILD_TESTING=ON.Results:
agc_driver_registration_concurrency(async,APS5_SYNC_SHADER_PREPAREunset) — PASSES (exit 0) on the 5090.agc_driver_registration_concurrency_sync(APS5_SYNC_SHADER_PREPARE=1) — PASSES (exit 0) on the 5090.Rigor check (is the test real?): I reverted
Driver::RegisterShaderto the eager constructor (ShaderPreparationTransaction transaction;instead of(std::defer_lock)), i.e. the base behavior, rebuilt, and the async test failed — "private shader preparation waited for an unrelated publication transaction" (exit 1) — which is exactly the negative-control assertion you describe. Restoringdefer_lock→ both modes PASS again. So the concurrency test genuinely exercises the deferred-lock change rather than passing unconditionally.Honest limits of what I verified:
FThreadHeartBeatoutcome.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T08:26:59Z.
Review: CHANGES_REQUESTED
Thanks for the rebase onto #2856 and the extra regression. Checked on Linux at
58d31147merged on current main: AGC driver scope build, 371/371 ctest,agc_driver_registration_concurrencyand_syncpass.One blocker, already asked by @oneandonlydean above and not yet addressed:
FThreadHeartBeatkill). The synthetic A/B covers the lock change for #218, but the PR exists for that kill, and the body says that outcome is unverified. Also, the benchmark predates the async preparation from #2583, so it doesn't show the gain on the current base (single worker was ~13 % slower in the tiny/warm case).If the title isn't available to you, ask in #2292 whether mrk1987 can run the two builds and post the numbers. Once that is posted this is ready from our side.
Heads-up: #3159 changes the same transaction defaults; whichever lands second needs a rebase.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-12T07:37:14Z.
Closing: on the #2292 title start-up is the same with and without this (23.2-23.9 s against 22.6-23.9 s, no heartbeat kill in either), and the registration stall went away with #2583. Reopen with a title where registration measurably waits on the writer lock.
Pull request closed