test(agc): let the sgpr pattern fill keys test resubmit more often under load #9139

Merged
xXPBSXx merged 1 commit from upstream-pr/9139 into main 2026-10-24 12:34:49 +00:00
xXPBSXx commented 2026-10-21 13:14:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T13:14:28Z.


What

agc_driver_sgpr_pattern_fill_keys polls in SubmitAndRead for 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 to MaxResubmits = 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

  • Linux (WSL2 Ubuntu 24.04, GCC 13.3, Release; not a bare-metal CI), GPU from the log: 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: main 2 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.
  • Not tested: Windows, a real GPU (AMD or NVIDIA), macOS; whether the window behaves differently on real hardware.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4952170805 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9139). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-21T13:14:28Z. --- ### What `agc_driver_sgpr_pattern_fill_keys` polls in `SubmitAndRead` for 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 to `MaxResubmits` = 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 - Linux (WSL2 Ubuntu 24.04, GCC 13.3, Release; not a bare-metal CI), GPU from the log: `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: `main` 2 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. - Not tested: Windows, a real GPU (AMD or NVIDIA), macOS; whether the window behaves differently on real hardware. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes AI-assisted (Claude Code).
xXPBSXx commented 2026-10-21 15:50:26 +00:00 (Migrated from github.com)

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 with ANYPS5_GPU="RX 6400"), WinLibs GCC 15.2.0 (MinGW-w64 UCRT), Release. I built only agc_driver_sgpr_pattern_fill_keys_tests.

Results, idle host (nothing else of mine running on this card or the CPU), 20 runs each:

  • MaxResubmits 16 (main): agc_driver_sgpr_pattern_fill_keys passes 20 of 20, about 6.5 s per run.
  • MaxResubmits 512 (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).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6320198192 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9139#issuecomment-6320198192). Originally posted by [xXPBSXx](https://github.com/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 with `ANYPS5_GPU="RX 6400"`), WinLibs GCC 15.2.0 (MinGW-w64 UCRT), Release. I built only `agc_driver_sgpr_pattern_fill_keys_tests`. **Results, idle host (nothing else of mine running on this card or the CPU), 20 runs each:** - `MaxResubmits` 16 (main): `agc_driver_sgpr_pattern_fill_keys` passes 20 of 20, about 6.5 s per run. - `MaxResubmits` 512 (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).
xXPBSXx commented 2026-10-21 17:47:06 +00:00 (Migrated from github.com)

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 with ANYPS5_GPU=4080), WinLibs GCC 15.2.0 (MinGW-w64 UCRT), Release. I built only agc_driver_sgpr_pattern_fill_keys_tests.

Results, idle host, 20 runs each: MaxResubmits 16 (main) passes 20 of 20, and MaxResubmits 512 (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).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6322660503 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9139#issuecomment-6322660503). Originally posted by [xXPBSXx](https://github.com/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 with `ANYPS5_GPU=4080`), WinLibs GCC 15.2.0 (MinGW-w64 UCRT), Release. I built only `agc_driver_sgpr_pattern_fill_keys_tests`. **Results, idle host, 20 runs each:** `MaxResubmits` 16 (`main`) passes 20 of 20, and `MaxResubmits` 512 (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).
rooklz commented 2026-10-21 18:35:02 +00:00 (Migrated from github.com)

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 main fail 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 0 or 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.
  • I wrapped AgcDriver::Submit and Recorder::NewestWriteNote with 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.
  • With 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.
  • None of the driver's debug switches changed it (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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6323609512 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9139#issuecomment-6323609512). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-21T18:35:02Z. --- A deterministic reproduction, in case it helps review (data only): pinning the test to one CPU makes `main` fail 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 0` or 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. - I wrapped `AgcDriver::Submit` and `Recorder::NewestWriteNote` with 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. - With `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. - None of the driver's debug switches changed it (`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.
jotitadev commented 2026-10-22 07:03:16 +00:00 (Migrated from github.com)

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 8411e6692 applied on main da54c652e; only agc_driver_sgpr_pattern_fill_keys_tests rebuilt between the two variants. Each run is the test binary called directly with ANYPS5_REQUIRE_VULKAN=1.

Variant RTX 3070, host already busy (load ~6, a parallel build) RTX 3070, + 12 busy loops (load ~9-10) lavapipe, load ~6
main (MaxResubmits 16) 36 of 40 pass 3 of 20 pass 19 of 20 pass
this PR (512) 20 of 20 pass 20 of 20 pass 20 of 20 pass

Every failure on main is 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 ^agc suite 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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5610393343 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9139#pullrequestreview-5610393343). Originally posted by [jotitadev](https://github.com/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 8411e6692 applied on `main` da54c652e; only `agc_driver_sgpr_pattern_fill_keys_tests` rebuilt between the two variants. Each run is the test binary called directly with `ANYPS5_REQUIRE_VULKAN=1`. | Variant | RTX 3070, host already busy (load ~6, a parallel build) | RTX 3070, + 12 busy loops (load ~9-10) | lavapipe, load ~6 | |---|---|---|---| | `main` (`MaxResubmits` 16) | 36 of 40 pass | 3 of 20 pass | 19 of 20 pass | | this PR (512) | 20 of 20 pass | 20 of 20 pass | 20 of 20 pass | Every failure on `main` is 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 `^agc` suite 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.
jotitadev commented 2026-10-22 11:18:47 +00:00 (Migrated from github.com)

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 8411e6692 merged on main 4777caca3. Only agc_driver_sgpr_pattern_fill_keys_tests was 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 is ctest -R '^agc_driver_sgpr_pattern_fill_keys$' -j1 --timeout 30 with ANYPS5_REQUIRE_VULKAN=1.

Variant RTX 3070 lavapipe
main (MaxResubmits 16) 2 of 20 pass not run
this PR (512) 13 of 20 pass 13 of 20 pass
4096 14 of 20 pass not run
no count bound, only the 10 s deadline 17 of 20 pass not run
  • With 512, every failure is the dispatch completed 513 times without a pending write over the keys, after 2.4 to 4.0 s.
  • With 4096, two failures are completed 4097 times and four are the submitted dispatch never became a pending write over the keys, after 8 to 15 s.
  • With only the deadline, all three failures are the deadline message.

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 main 27 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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5613335099 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9139#pullrequestreview-5613335099). Originally posted by [jotitadev](https://github.com/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 8411e6692 merged on `main` 4777caca3. Only `agc_driver_sgpr_pattern_fill_keys_tests` was 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 is `ctest -R '^agc_driver_sgpr_pattern_fill_keys$' -j1 --timeout 30` with `ANYPS5_REQUIRE_VULKAN=1`. | Variant | RTX 3070 | lavapipe | |---|---|---| | `main` (`MaxResubmits` 16) | 2 of 20 pass | not run | | this PR (512) | 13 of 20 pass | 13 of 20 pass | | 4096 | 14 of 20 pass | not run | | no count bound, only the 10 s deadline | 17 of 20 pass | not run | - With 512, every failure is `the dispatch completed 513 times without a pending write over the keys`, after 2.4 to 4.0 s. - With 4096, two failures are `completed 4097 times` and four are `the submitted dispatch never became a pending write over the keys`, after 8 to 15 s. - With only the deadline, all three failures are the deadline message. 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 `main` 27 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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!9139
No description provided.