perf(agc): wake a held compute submission when queue 0 blocks on its label #22188

Merged
muhmuhkuh merged 1 commit from upstream-pr/22188 into main 2026-11-17 21:01:07 +00:00
muhmuhkuh commented 2026-11-17 08:14:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by muhmuhkuh on 2026-11-17T08:14:07Z.


What

A submission that must run after queue 0's earlier work (a wait-free submission of another queue, the order rule of 04f12028dc) is held until the rule releases it. One release case is a queue 0 that blocks in a wait on a label the held queue writes: the held queue has to run for queue 0 to continue.

The held worker polled for that release with poll. On Windows poll unlocks the driver mutex and sleeps 0.2 ms (PollSleep), so the release came 0.2 to 0.3 ms after queue 0 began to wait. Driver::noteWaitBlocked already notifies the driver's condition variable (changed) when a queue blocks while a hold is waiting. The hold now waits on that condition variable with a 200 microsecond timeout, so it is released when the notification arrives and the stall watch still runs at the same period. The release rule (orderReleased) is unchanged.

No switch: the behaviour is the same except when the submission is released. On other platforms poll already waits on the same condition variable (1 ms timeout), so the change is for Windows' sleep-based poll; I did not run Linux.

The hold of queue 0 behind other queues (waitFreeBefore) is not changed.

Overlap with open pull requests: none found. The diffs of the 8 open PRs that touch Queues/QueueWorker.cpp were searched for order behind queue 0, orderHolders, OrderHold, poll(released) and noteWaitBlocked in changed lines.

Tested

Windows 11 Pro (10.0.26200), NVIDIA GeForce RTX 3080 Ti, driver 610.88, MinGW GCC 15.2 (UCRT, POSIX threads, SEH), Release, validation layer on (ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation). Built on the same machine on main af1208e6a4 and on this change at the same base. The three files this change touches are the same on the posting base 88fe9fbc50, so the tests were not repeated there.

  • New agc_driver_pm4_order_signal: 32 rounds. Queue 0 writes a marker and blocks in a WAIT_REG_MEM on a label; a compute submission queued right after it writes a word and then the label. The test takes the time from the marker to the word, and requires the median to be under 0.1 ms. On this change the median was 0.000 to 0.030 ms in 6 runs (largest single round 0.25 to 2.3 ms). On main the test is not registered.
  • Mutation on this change, reverted afterwards: with the hold waiting through poll again, the test fails 5 of 5 runs with a median of 0.22 to 0.39 ms ("a held submission started ... ms (median) after queue 0 began to wait on its label; it must start at once").
  • Every ctest entry that runs agc_driver_pm4_tests (25 on main, 26 with the new one): all pass on both. Every entry that runs agc_driver_recorder_tests (151): all pass on main and on this change. The Pm4 tests use no Vulkan device; the recorder run does.
  • VUID: 0 VUID- lines in all logs. The loader log shows the validation layer inserted in the 138 recorder runs of both trees (the Pm4 runs create no instance); the phrase was not found but was requested by env var VK_INSTANCE_LAYERS: 0 occurrences.
  • The timing test depends on the machine's load; the margin is 0.1 ms against 0.22 ms and more without the change.
  • Speed: the gain is the release latency measured by the test, about 0.25 ms per hold; no trace_digest run, no frame time claimed.
  • Not run: the full CPU suite, Linux, any title.

Checklist

  • Based on current main (88fe9fbc50 at posting time); 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: NVIDIA GeForce RTX 3080 Ti, driver 610.88, Windows 11 Pro 10.0.26200
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5353230658 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22188). Originally posted by [muhmuhkuh](https://github.com/muhmuhkuh) on 2026-11-17T08:14:07Z. --- ### What A submission that must run after queue 0's earlier work (a wait-free submission of another queue, the order rule of 04f12028dce) is held until the rule releases it. One release case is a queue 0 that blocks in a wait on a label the held queue writes: the held queue has to run for queue 0 to continue. The held worker polled for that release with `poll`. On Windows `poll` unlocks the driver mutex and sleeps 0.2 ms (`PollSleep`), so the release came 0.2 to 0.3 ms after queue 0 began to wait. `Driver::noteWaitBlocked` already notifies the driver's condition variable (`changed`) when a queue blocks while a hold is waiting. The hold now waits on that condition variable with a 200 microsecond timeout, so it is released when the notification arrives and the stall watch still runs at the same period. The release rule (`orderReleased`) is unchanged. No switch: the behaviour is the same except when the submission is released. On other platforms `poll` already waits on the same condition variable (1 ms timeout), so the change is for Windows' sleep-based poll; I did not run Linux. The hold of queue 0 behind other queues (`waitFreeBefore`) is not changed. Overlap with open pull requests: none found. The diffs of the 8 open PRs that touch `Queues/QueueWorker.cpp` were searched for `order behind queue 0`, `orderHolders`, `OrderHold`, `poll(released)` and `noteWaitBlocked` in changed lines. ### Tested Windows 11 Pro (10.0.26200), NVIDIA GeForce RTX 3080 Ti, driver 610.88, MinGW GCC 15.2 (UCRT, POSIX threads, SEH), Release, validation layer on (`ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`). Built on the same machine on `main` af1208e6a4f and on this change at the same base. The three files this change touches are the same on the posting base 88fe9fbc50d, so the tests were not repeated there. - New `agc_driver_pm4_order_signal`: 32 rounds. Queue 0 writes a marker and blocks in a WAIT_REG_MEM on a label; a compute submission queued right after it writes a word and then the label. The test takes the time from the marker to the word, and requires the median to be under 0.1 ms. On this change the median was 0.000 to 0.030 ms in 6 runs (largest single round 0.25 to 2.3 ms). On `main` the test is not registered. - Mutation on this change, reverted afterwards: with the hold waiting through `poll` again, the test fails 5 of 5 runs with a median of 0.22 to 0.39 ms ("a held submission started ... ms (median) after queue 0 began to wait on its label; it must start at once"). - Every `ctest` entry that runs `agc_driver_pm4_tests` (25 on `main`, 26 with the new one): all pass on both. Every entry that runs `agc_driver_recorder_tests` (151): all pass on `main` and on this change. The Pm4 tests use no Vulkan device; the recorder run does. - VUID: 0 `VUID-` lines in all logs. The loader log shows the validation layer inserted in the 138 recorder runs of both trees (the Pm4 runs create no instance); the phrase `was not found but was requested by env var VK_INSTANCE_LAYERS`: 0 occurrences. - The timing test depends on the machine's load; the margin is 0.1 ms against 0.22 ms and more without the change. - Speed: the gain is the release latency measured by the test, about 0.25 ms per hold; no trace_digest run, no frame time claimed. - Not run: the full CPU suite, Linux, any title. ### Checklist - [x] Based on current `main` (88fe9fbc50d at posting time); 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: NVIDIA GeForce RTX 3080 Ti, driver 610.88, Windows 11 Pro 10.0.26200 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!22188
No description provided.