test(agc): let the sgpr pattern fill keys test resubmit more often under load #9139
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9139"
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 xXPBSXx on 2026-10-21T13:14:28Z.
What
agc_driver_sgpr_pattern_fill_keyspolls inSubmitAndReadfor the short window in which the submitted dispatch is a pending write over the keys, and resubmits when the dispatch retires without being seen, up toMaxResubmits= 16 times. On a host with moderate contention the polling thread is descheduled while the llvmpipe dispatch retires, so the limit runs out with "the dispatch completed 17 times without a pending write over the keys". The limit is now 512: a retry bound inside the existing 10 second deadline; an idle host needs no resubmits. This does not make the test deterministic under heavy CPU oversubscription (see the loaded runs in the reviews); that needs a hook to hold the batch open until the read (#8708).Tested
Selected GPU name=llvmpipe .... Idle: 20 of 20 runs pass before the change. Beside 24 busy loops: 1 of 8 pass before, 8 of 8 after. Test pinned to two CPUs (taskset -c 0,1) beside 12 busy loops, 20 runs each:main2 of 20, this PR 20 of 20 (the reviewer's run of the same shape: 2 of 20 and 13 of 20, so the margin depends on the machine).python tools/check_conventions.py --base upstream/main: passes.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)AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T15:50:26Z.
Windows data point on a real GPU (data only).
Environment: Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, AMD Radeon RX 6400 (the log shows
Selected GPU name=AMD Radeon RX 6400 vendor=0x1002 device=0x743f subgroup=64, picked withANYPS5_GPU="RX 6400"), WinLibs GCC 15.2.0 (MinGW-w64 UCRT), Release. I built onlyagc_driver_sgpr_pattern_fill_keys_tests.Results, idle host (nothing else of mine running on this card or the CPU), 20 runs each:
MaxResubmits16 (main):agc_driver_sgpr_pattern_fill_keyspasses 20 of 20, about 6.5 s per run.MaxResubmits512 (this PR): passes 20 of 20, about 6.5 s per run.So on this card the limit does not matter while the host is idle, which fits the PR text: the resubmit limit only runs out when the polling thread is descheduled while a dispatch retires. I did not load the CPU for this comment, so it says nothing about the behaviour of the test on this GPU under load.
Not run: the test under CPU load, an NVIDIA card (that run follows), other platforms.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T17:47:06Z.
RTX data point (data only; the RX 6400 run is in my earlier comment).
Environment: Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, NVIDIA GeForce RTX 4080 SUPER (the log shows
Selected GPU name=NVIDIA GeForce RTX 4080 SUPER vendor=0x10de device=0x2702 subgroup=32, picked withANYPS5_GPU=4080), WinLibs GCC 15.2.0 (MinGW-w64 UCRT), Release. I built onlyagc_driver_sgpr_pattern_fill_keys_tests.Results, idle host, 20 runs each:
MaxResubmits16 (main) passes 20 of 20, andMaxResubmits512 (this PR) passes 20 of 20. As on the RX 6400, the limit makes no difference while the host is idle. I did not load the CPU, so this says nothing about the test on this GPU under load.Not run: the test under CPU load, other platforms.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-21T18:35:02Z.
A deterministic reproduction, in case it helps review (data only): pinning the test to one CPU makes
mainfail every time.Linux x86-64 container (Ubuntu 24.04, GCC 13.3, Release) under Rosetta on an Apple M5, lavapipe,
ANYPS5_REQUIRE_VULKAN=1 GALLIUM_OVERRIDE_CPU_CAPS=avx:main,taskset -c 0or two CPUs: failed 8 of 8 runs with "the dispatch completed 17 times without a pending write over the keys". With four instances on four CPUs about half failed (6 of 12, then 4 of 12). Idle on four CPUs it passed.AgcDriver::SubmitandRecorder::NewestWriteNotewith a preload shim to see why. Pinned to one CPU, the first (uncached) checkpoint is seen after 56 to 93 polls. The second checkpoint then gets 17 submits about 0.1 ms apart, and each one polls once and sees no note: the worker records, submits and retires the batch before the test thread runs again.MaxResubmits = 512, pinned to one CPU: 10 of 10 passed. The longest run of consecutive misses was 230, so 512 leaves about twice that; whole runs took 367 to 747 submits. 4096 passed 25 of 25, including four instances on two CPUs.APS5_NO_OPPORTUNISTIC_REAP,APS5_NO_UNLOCKED_DRAIN,APS5_NO_LABEL_SHORTCUT,APS5_NO_LABEL_BATCHING,ANYPS5_NO_SHADER_CACHE).On GitHub-hosted ubuntu-24.04 runners (four vCPUs) it failed in 15 of 20 of my fork's full test runs, each time after 0.5 to 1 s, which matches the resubmit limit running out rather than the 10 s deadline.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T07:03:16Z.
Review: COMMENTED
Data point on a real GPU under load, since the runs so far were lavapipe under load and AMD/NVIDIA on Windows while idle.
Machine: Ubuntu 26.04, i7-8700 (6 cores / 12 threads), GCC 15.2, Release. GPUs: NVIDIA GeForce RTX 3070 (driver 595.99.02, Linux) and lavapipe (Mesa 26.0.3, LLVM 21.1.8). Head
8411e6692applied onmainda54c652e; onlyagc_driver_sgpr_pattern_fill_keys_testsrebuilt between the two variants. Each run is the test binary called directly withANYPS5_REQUIRE_VULKAN=1.main(MaxResubmits16)Every failure on
mainis the one in the description:the dispatch completed 17 times without a pending write over the keys, after 0.6 to 1.1 s. So it is not specific to llvmpipe: on a discrete NVIDIA GPU the polling thread also misses the window once the CPU is busy, and the 3070 fails it in the plain^agcsuite on this host (it was one of 4 failures out of 861 in my baseline run). With the PR the loaded runs take 1.0 to 2.1 s, far from the 10 s deadline.GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02, Linux), lavapipe
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T11:18:47Z.
Review: COMMENTED
Follow-up to my earlier data point: with heavier contention, 512 resubmits is not enough, and neither is a larger bound.
Machine: Ubuntu 26.04, i7-8700 (6 cores / 12 threads), GCC 15.2, Release. GPUs: NVIDIA GeForce RTX 3070 (driver 595.99.02, Linux) and lavapipe (Mesa 26.0.3, LLVM 21.1.8). Head
8411e6692merged onmain4777caca3. Onlyagc_driver_sgpr_pattern_fill_keys_testswas rebuilt between variants.Load: 12 busy loops, one pinned to each CPU, and the test run under
taskset -c 0,1. That puts the test thread and the queue worker on two CPUs that also run busy loops. Each run isctest -R '^agc_driver_sgpr_pattern_fill_keys$' -j1 --timeout 30withANYPS5_REQUIRE_VULKAN=1.main(MaxResubmits16)the dispatch completed 513 times without a pending write over the keys, after 2.4 to 4.0 s.completed 4097 timesand four arethe submitted dispatch never became a pending write over the keys, after 8 to 15 s.So under this kind of load the poll misses the window on almost every resubmit, and raising the bound only moves the failure to the deadline. With a lighter load (12 unpinned busy loops, the test unpinned), the PR passes 30 of 30 on the 3070 and
main27 of 30. As in my earlier runs, the PR passes every run at that level of load.The PR is still a clear improvement for the CI case @rooklz measured. A deterministic fix would need the test to see the fill after its batch retires, or to hold the batch open until the read. That's the scheduling hook @MarcZX10 asked for in #8708.
GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02, Linux), lavapipe (Mesa 26.0.3)
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.