WIP: perf(vk): a submit thread sends the submits the replay holds where nothing else batches them (RX_VK_SUBMIT_WORKER, off) #2156

Draft
siantm wants to merge 14 commits from siantm/Longshot:perf/vk-submit-worker into main
Contributor

Summary

Where submits are neither batched (RX_VK_BATCH) nor the recorder thread's, the thread that replays a recording makes its
vkQueueSubmit2 itself, at every part's end. #1995 had a submit thread for that; it was taken out of #1995 (4f6b9d10)
because it was unmeasured and its review found ten points in it. This brings it back on its own, with those points
answered, off by default (an attempt: RX_VK_SUBMIT_WORKER=1 turns it on) until the in-game comparison exists.

With the thread on, a recording's submit is held as a batched one is, and a thread of its own (mkw_vk submit,
submit_worker_main) sends what is held at once, under the queue's lock (dev.present_mu), in the order it was held, while
the replay goes on with the next part. Nothing waits on the thread: every wait for a value, a fence, a recording or a slot
sends what is held first, as with RX_VK_BATCH. Against the review on #1995:

  • it is started once, at the replay's start, after the batches' timeline is made and before anything can be held; a thread
    that cannot be started leaves every submit to the replaying thread, with nothing held (L1);
  • a held batch the driver refuses stops the renderer (replay_fatal) when the thread is on: none of its signals would
    come and whatever waits for them would wait for good (L3). RX_VK_BATCH's own batches keep main's handling;
  • its time in vkQueueSubmit2 and its submits are counted in atomic counters of its own, not in PROF_QSUBMIT, the
    replaying thread's phase that the stats lines and the menu read without a lock (L4);
  • its state is never destroyed (as the recorder's), and the window's close stops it (submit_worker_stop, 2 s at most)
    before the swapchain is let go; what it did not send goes with the close's own flush (L5). A stop that joined the thread
    leaves no worker behind (batch_on and the kick say so: the replaying thread submits directly again). A thread that did
    not stop in 2 s is in a driver submit, or waits for the queue's lock behind one: the close then lets nothing go and
    returns, as it does with a present still running. The back end never destroys the device (no vkDestroyDevice call),
    so that driver call cannot outlive it. The thread is started once a process: asked again it starts nothing;
  • it is never started with RADV, GCN included (L9), with RX_VK_BATCH set or batched submits, with the recorder thread,
    with RX_VK_GPU_TIMELINE (its submit times are taken where the replaying thread submits, L12) or with RX_VK_BENCH;
    the log says which;
  • with the thread on, a progress poll and a wait with a finite budget (a zero-timeout nvnSyncWait) never wait for the
    queue's lock: a busy queue is left to the thread, and a flush they make is taken from the budget (L10);
  • a submit of another game frame sends the batch held for the frame before (reflex_split_wanted), so a delayed thread
    never tags the next frame's commands with the first frame's NVIDIA Reflex id (L11);
  • every 120 presents a line gives its submits, its time in vkQueueSubmit2, and the flushes by reason with the mean time
    from held to submitted, to tell driver time moved from delay added (L17);
  • tests/test_submit_worker.py runs the source's thread against a fake queue (L14), below.

The result expected: the same picture, and the queue submit off the replaying thread; whether that saves anything is not
known: it is not measured (the A/B is in Still to test).

The switch: RX_VK_SUBMIT_WORKER (new, an attempt, bool, its row in gpu/vk/switches.def, a row for the thread in
docs/dev/reference/threads.md), off by default, as dazemc's review asks (72747): unset, empty, 0, off, false or
no is #1995's code, every submit made by the thread that replays it; 1 turns the thread on. Read once at the replay's
start. It acts only with Threaded rendering off: with it on, the recorder thread or the render thread makes the submits.

This is still on #1995 @ 9e640b66, which conflicts with current main in gpu/vk/vk_replay.cpp (as #1994 does): the stack
is not rebased in this push (their farm requests and runtimes are on their current heads); the three are rebased together
at #1995's next push.

Depends on #1995 (RX_VK_SLOT_BY_TIMELINE, formerly RX_VK_SUBMIT_BATCH, at 9e640b66) and, under it, #1994
(RX_VK_REPLAYED_CACHE): their commits show in this diff until they merge.

From the submit thread of #1995 before 4f6b9d10 (bd592530, its head then), which came from exp/x86-asm-sync.

Read first: the submit worker's block (submit_worker_main, submit_worker_kick, submit_worker_start,
submit_worker_stop, reflex_split_wanted, batch_on), then queue_flush_locked, queue_flush_for, queue_flush_poll
and submit_recording's hold in gpu/vk/vk_replay.cpp; then tests/test_submit_worker.py.

Testing

Tested: Windows 11, i7-9700, RTX 4060, the builder's llvm-mingw clang 23; head dfe6b9c5 on #1995's head 9e640b66 (#1994 under it, on main 9dd41326), not rebased (Summary). Build jobs of this PC's job queue (sw2156, sw2156b), the checks in a hidden console:

  • tests/test_submit_worker.py, copies of each commit from git: at 5825c6e0 (the new cases on the earlier code) it fails as it should: stop-resets (the worker still counted on after a stop that joined it), start-twice (std::terminate at the second start) and the close's wiring (the stop's answer not looked at); at the fix 3312f165 it passes (23 cases, the wiring, the switch read), and at the head too (24 cases: unset and =0 off, every other case with =1; the close's give-up branch before the swapchain's retire; no vkDestroyDevice call in gpu/vk).
  • Every check tests/run_all.py --strict --changed 9e640b66 picks for the files this changes, at 2219dc54 (the head before the fixture line below; log sw2156-changed.log): 166 passed, 34 failed, 9 skipped (they need Linux or a Vulkan device). 33 of the 34 fail on #1995 @ 9e640b66 too, each run alone there: tests/test_appimage_player_build.py, tests/test_auto_handheld.py, tests/test_capture_readback_visibility.py, tests/test_crash_dialog.py, tests/test_crash_record.py, tests/test_dev_ab.py, tests/test_dev_packs.py, tests/test_device_lost_exit.py, tests/test_draw_stream_visibility.py, tests/test_flush_nothing_held.py, tests/test_frame_overlap.py, tests/test_fsr_image_retirement.py, tests/test_fsr_uniform_ownership.py, tests/test_gpu_wait_stats.py, tests/test_input_background.py, tests/test_linux_pressure.py, tests/test_menu_keys.py, tests/test_mesh_conv.py, tests/test_perf_report.py, tests/test_prepare_cache_save.py, tests/test_present_queue_default.py, tests/test_present_source_crop.py, tests/test_profiling_mode.py, tests/test_recorder_own_idle.py, tests/test_recorder_sync.py, tests/test_renderer_new_handler.py, tests/test_replay_write_order.py, tests/test_slow_frames.py, tests/test_sparse_mirror.py, tests/test_target_reuse_memory.py, tests/test_ub_update_batch.py, tests/test_upscaler_rows.py, tests/test_vk_occlusion_queries.py. The 34th, tests/test_present_semaphores.py, compiles the close from its dev.closing line on and did not know the close's new worker_stopped: its fixture declares it (stopped) in 3312f165. At the head it passes, with tests/test_submit_worker.py, tests/test_quit_not_crash.py and tests/test_startup_progress.py, the other checks that read the close (log sw2156b.log).
  • gpu/vk/vk_replay.cpp and gpu/vk/vk_main.cpp compiled with the game build's own command (syntax only): pass.

It has run in the game on this PC: the A/B in Measurements (held job seg-pt-sw, 18 Kokiri Forest runs and a Market
pair, Threaded rendering off), with no FATAL, device lost or Vulkan error in any run, and every run closed by itself with
exit code 0 (no close gave up on the queue).

The Test Farm's picture at kokiri-start (HumanBean's run of this pull request, #issuecomment-70269, Windows RX 9060 XT, RX_VK_SUBMIT_WORKER=0) was taken inside the load's fade-in from black: main's two starts and one of this pull request's were a uniform black frame and the 0.865 start was the finished scene, so the comparison measured when the fade ended, not what was drawn. #1995's run #issuecomment-67740 shows the same scene and camera as main in its pictures, with only the animation's phase differing (Navi's place, Link's idle pose, the curtain).

Still to test:

  • Windows 11, i7-9700, RTX 4060 (this PC): Hyrule Field with Threaded rendering off, unset against
    RX_VK_SUBMIT_WORKER=1, and a picture of each at an input-free point beside main against itself (Kokiri Forest and the
    Market have run: Measurements), expecting the same picture (by hand)
  • Windows 11, i7-9700, RTX 4060 (this PC): the same with Threaded rendering on and Auto, expecting the log to say the
    thread is off with the recorder thread when RX_VK_SUBMIT_WORKER=1, and the frame times the same as unset (by hand)
  • Windows 11, i7-9700, RTX 4060 (this PC): close the window while playing with RX_VK_SUBMIT_WORKER=1 and Threaded
    rendering off, expecting the game to close at once with no crash report (by hand)
  • Linux NVIDIA, Windows AMD and Intel: Kokiri Forest and Hyrule Field, play three minutes each with Threaded rendering
    off: this branch unset (off) and with RX_VK_SUBMIT_WORKER=1, warmed up, ABBA, expecting the same picture, no FATAL or
    device lost, and the frame times showing whether =1 gains or loses (Test Farm: linux+nvidia, windows+amd,
    windows+intel: Kokiri Forest and Hyrule Field three minutes each, Threaded rendering off: this branch unset and with
    RX_VK_SUBMIT_WORKER=1, warmed up, ABBA, the log, frame times and a screenshot)
  • Linux AMD and Steam Deck (RADV): one start with RX_VK_SUBMIT_WORKER=1, expecting the log to say it is off with RADV
    and the frame times the same as unset (Test Farm: linux+amd, steamdeck: Kokiri Forest one minute with
    RX_VK_SUBMIT_WORKER=1 and unset, the log and frame times)
  • Linux: build the renderer and run python3 -I -B tests/test_submit_worker.py, expecting PASS (by hand)

Measurements

Verdict: the submit thread takes the driver's submits off the replaying thread, and the frame does not show it. In
the CPU-paced comparison on this PC (Kokiri Forest at an 800x600 output, Threaded rendering off, one runtime of this head,
unset against RX_VK_SUBMIT_WORKER=1, 8 runs a side; In play below), the replaying thread's queue submit went from 0.53 to
0.00 ms a frame (p = 0.0002), the submit thread making about 11 submits a frame in 0.60 ms of vkQueueSubmit2, and the
replay's submit time fell 3.5 % (p = 0.009). But the game's own code took 7 % longer on the same thread (2.88 against
3.07 ms a frame, p = 0.0002), and the median frame was 12.71 against 12.78 ms (p = 0.55): the time moved, the frame did not
gain. Frames of 50 ms or more were 77 against 116 (p = 0.049) in this one sitting, not claimed. RX_VK_SUBMIT_WORKER ships
off (an attempt), as dazemc's review asked; this run gives no reason to turn it on.

Baseline: this PR with RX_VK_SUBMIT_WORKER unset (#1995's path) in the same runtime as =1: one build, so the switch
is the only difference. Main itself was not run in this comparison.

In play (held job seg-pt-sw, 23:44 UTC on 2026-11-23 to 00:35 UTC on 2026-11-24): one runtime of this head dfe6b9c5
(on #1995's 9e640b66, on main 9dd41326), Threaded rendering off in every run as the menu's Off sets it (RX_VK_ASYNC=0 and
RX_VK_RECORDER=off: each run's switches line has both, and no run has the render thread's line), since the submit thread
works only with the replay on the submitting thread; RX_VK_PROF_FINE=1 on both sides. Kokiri Forest, 60 s a run,
CPU-paced on purpose (an 800x600 window), a warm-up a side, then unset and =1 interleaved (off on on off, four times);
every run in the scene's light state, loaded at create, on a desktop at 800x600 at 30 Hz. No run was left out, no load
marker or strike file appeared, and no run's log has a commit-limit line. Then the Market, one run a side, as a reference.
With Threaded rendering off the game's thread also replays and submits: calm game time is the game's own code only, and
the frame is the median frame time. Reach: the submit thread's own line every 120 presents (vk: submit thread: N submits, X ms in vkQueueSubmit2 ...) on the =1 side: in steady play 11.0 to 11.4 submits a frame, 0.58 to 0.62 ms a frame in
vkQueueSubmit2, each held 16 to 18 us before the thread sent it (0.29 to 0.33 ms a frame in the load).

a side: median (range), Kokiri Forest Before: this PR @ dfe6b9c5, unset, 8 runs After: this PR @ dfe6b9c5, RX_VK_SUBMIT_WORKER=1, 8 runs change of the means, p (swap test)
the replaying thread's queue submit, ms a frame, steady play 0.53 (0.51 to 0.55) 0.00 -99.9 %, 0.0002
the same, the load 0.25 (0.23 to 0.26) 0.00 -99.6 %, 0.0002
a frame's replay time (ms): submit 8.94 (8.46 to 9.03) 8.60 (8.30 to 8.83) -3.5 %, 0.009
calm-stretch game_ms (the game's code) 2.88 (2.72 to 2.97) 3.07 (3.01 to 3.12) +7.1 %, 0.0002
main_blocked_ms 10.14 (9.88 to 10.32) 10.01 (9.65 to 10.37) -1.0 %, 0.35
median frame time, ms 12.78 (12.51 to 12.94) 12.71 (12.24 to 13.06) -0.6 %, 0.55
frames a second 74.2 (68.7 to 75.6) 75.0 (69.6 to 77.0) +1.1 %, 0.50
p99 frame time, ms 42.8 (35.9 to 48.0) 41.3 (39.4 to 44.3) -2.8 %, 0.43
frames of 50 ms or more, all runs 116 77 0.049
draw, ms a frame 4.32 (4.16 to 4.46) 4.37 (4.22 to 4.48) +1.1 %, 0.33
a frame's replay time (ms): draw 4.42 (4.29 to 4.63) 4.45 (4.33 to 4.61) +0.9 %, 0.45

The tail is high on both sides (p99 over 40 ms), as in #2030's runs in the same sitting, both on runtimes over main
9dd41326 with Threaded rendering off; those long frames are the game's own thread (32 to 54 ms of its code, about 50 to 66
ms blocked in them) on both sides. The Market pair (one run a side, a reference): main_blocked 12.64 against 11.52 ms,
replay submit 10.90 against 9.99, p99 51.5 against 42.8, 41 against 17 frames of 50 ms or more, leaning the same way.

Risks

What could break, with the thread on (RX_VK_SUBMIT_WORKER=1; never on RADV, nor with the recorder thread): a held submit
sent out of order or twice (a wrong picture or a device lost), one never sent (a hang: every wait sends what is held
first, as with RX_VK_BATCH), the close waiting for the thread (2 s at most; a thread still in a driver submit then makes
the close let the swapchain go with the process, as a present still running does, at once), a refused batch stopping the
renderer where #1995 would go on without it, and a poll or a wait with a finite budget no longer sending what is held when
the queue's lock is busy (the thread does: it was woken when the submit was held). Unset or =0 is #1995's code. Renderer
code: the runtime is rebuilt; nothing changes for players' saves, options or caches.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def.
  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.
## Summary Where submits are neither batched (`RX_VK_BATCH`) nor the recorder thread's, the thread that replays a recording makes its `vkQueueSubmit2` itself, at every part's end. #1995 had a submit thread for that; it was taken out of #1995 (`4f6b9d10`) because it was unmeasured and its review found ten points in it. This brings it back on its own, with those points answered, off by default (an attempt: `RX_VK_SUBMIT_WORKER=1` turns it on) until the in-game comparison exists. With the thread on, a recording's submit is held as a batched one is, and a thread of its own (`mkw_vk submit`, `submit_worker_main`) sends what is held at once, under the queue's lock (`dev.present_mu`), in the order it was held, while the replay goes on with the next part. Nothing waits on the thread: every wait for a value, a fence, a recording or a slot sends what is held first, as with `RX_VK_BATCH`. Against the review on #1995: - it is started once, at the replay's start, after the batches' timeline is made and before anything can be held; a thread that cannot be started leaves every submit to the replaying thread, with nothing held (L1); - a held batch the driver refuses stops the renderer (`replay_fatal`) when the thread is on: none of its signals would come and whatever waits for them would wait for good (L3). `RX_VK_BATCH`'s own batches keep main's handling; - its time in `vkQueueSubmit2` and its submits are counted in atomic counters of its own, not in `PROF_QSUBMIT`, the replaying thread's phase that the stats lines and the menu read without a lock (L4); - its state is never destroyed (as the recorder's), and the window's close stops it (`submit_worker_stop`, 2 s at most) before the swapchain is let go; what it did not send goes with the close's own flush (L5). A stop that joined the thread leaves no worker behind (`batch_on` and the kick say so: the replaying thread submits directly again). A thread that did not stop in 2 s is in a driver submit, or waits for the queue's lock behind one: the close then lets nothing go and returns, as it does with a present still running. The back end never destroys the device (no `vkDestroyDevice` call), so that driver call cannot outlive it. The thread is started once a process: asked again it starts nothing; - it is never started with RADV, GCN included (L9), with `RX_VK_BATCH` set or batched submits, with the recorder thread, with `RX_VK_GPU_TIMELINE` (its submit times are taken where the replaying thread submits, L12) or with `RX_VK_BENCH`; the log says which; - with the thread on, a progress poll and a wait with a finite budget (a zero-timeout `nvnSyncWait`) never wait for the queue's lock: a busy queue is left to the thread, and a flush they make is taken from the budget (L10); - a submit of another game frame sends the batch held for the frame before (`reflex_split_wanted`), so a delayed thread never tags the next frame's commands with the first frame's NVIDIA Reflex id (L11); - every 120 presents a line gives its submits, its time in `vkQueueSubmit2`, and the flushes by reason with the mean time from held to submitted, to tell driver time moved from delay added (L17); - `tests/test_submit_worker.py` runs the source's thread against a fake queue (L14), below. The result expected: the same picture, and the queue submit off the replaying thread; whether that saves anything is not known: it is not measured (the A/B is in Still to test). The switch: `RX_VK_SUBMIT_WORKER` (new, an attempt, bool, its row in `gpu/vk/switches.def`, a row for the thread in `docs/dev/reference/threads.md`), off by default, as dazemc's review asks (72747): unset, empty, `0`, `off`, `false` or `no` is #1995's code, every submit made by the thread that replays it; `1` turns the thread on. Read once at the replay's start. It acts only with Threaded rendering off: with it on, the recorder thread or the render thread makes the submits. This is still on #1995 @ `9e640b66`, which conflicts with current main in `gpu/vk/vk_replay.cpp` (as #1994 does): the stack is not rebased in this push (their farm requests and runtimes are on their current heads); the three are rebased together at #1995's next push. Depends on #1995 (`RX_VK_SLOT_BY_TIMELINE`, formerly `RX_VK_SUBMIT_BATCH`, at `9e640b66`) and, under it, #1994 (`RX_VK_REPLAYED_CACHE`): their commits show in this diff until they merge. From the submit thread of #1995 before `4f6b9d10` (`bd592530`, its head then), which came from `exp/x86-asm-sync`. Read first: the submit worker's block (`submit_worker_main`, `submit_worker_kick`, `submit_worker_start`, `submit_worker_stop`, `reflex_split_wanted`, `batch_on`), then `queue_flush_locked`, `queue_flush_for`, `queue_flush_poll` and `submit_recording`'s hold in `gpu/vk/vk_replay.cpp`; then `tests/test_submit_worker.py`. ## Testing **Tested:** Windows 11, i7-9700, RTX 4060, the builder's llvm-mingw clang 23; head `dfe6b9c5` on #1995's head `9e640b66` (#1994 under it, on main `9dd41326`), not rebased (Summary). Build jobs of this PC's job queue (`sw2156`, `sw2156b`), the checks in a hidden console: - `tests/test_submit_worker.py`, copies of each commit from git: at `5825c6e0` (the new cases on the earlier code) it fails as it should: `stop-resets` (the worker still counted on after a stop that joined it), `start-twice` (std::terminate at the second start) and the close's wiring (the stop's answer not looked at); at the fix `3312f165` it passes (23 cases, the wiring, the switch read), and at the head too (24 cases: unset and `=0` off, every other case with `=1`; the close's give-up branch before the swapchain's retire; no `vkDestroyDevice` call in `gpu/vk`). - Every check `tests/run_all.py --strict --changed 9e640b66` picks for the files this changes, at `2219dc54` (the head before the fixture line below; log `sw2156-changed.log`): 166 passed, 34 failed, 9 skipped (they need Linux or a Vulkan device). 33 of the 34 fail on #1995 @ `9e640b66` too, each run alone there: `tests/test_appimage_player_build.py`, `tests/test_auto_handheld.py`, `tests/test_capture_readback_visibility.py`, `tests/test_crash_dialog.py`, `tests/test_crash_record.py`, `tests/test_dev_ab.py`, `tests/test_dev_packs.py`, `tests/test_device_lost_exit.py`, `tests/test_draw_stream_visibility.py`, `tests/test_flush_nothing_held.py`, `tests/test_frame_overlap.py`, `tests/test_fsr_image_retirement.py`, `tests/test_fsr_uniform_ownership.py`, `tests/test_gpu_wait_stats.py`, `tests/test_input_background.py`, `tests/test_linux_pressure.py`, `tests/test_menu_keys.py`, `tests/test_mesh_conv.py`, `tests/test_perf_report.py`, `tests/test_prepare_cache_save.py`, `tests/test_present_queue_default.py`, `tests/test_present_source_crop.py`, `tests/test_profiling_mode.py`, `tests/test_recorder_own_idle.py`, `tests/test_recorder_sync.py`, `tests/test_renderer_new_handler.py`, `tests/test_replay_write_order.py`, `tests/test_slow_frames.py`, `tests/test_sparse_mirror.py`, `tests/test_target_reuse_memory.py`, `tests/test_ub_update_batch.py`, `tests/test_upscaler_rows.py`, `tests/test_vk_occlusion_queries.py`. The 34th, `tests/test_present_semaphores.py`, compiles the close from its `dev.closing` line on and did not know the close's new `worker_stopped`: its fixture declares it (stopped) in `3312f165`. At the head it passes, with `tests/test_submit_worker.py`, `tests/test_quit_not_crash.py` and `tests/test_startup_progress.py`, the other checks that read the close (log `sw2156b.log`). - `gpu/vk/vk_replay.cpp` and `gpu/vk/vk_main.cpp` compiled with the game build's own command (syntax only): pass. It has run in the game on this PC: the A/B in Measurements (held job `seg-pt-sw`, 18 Kokiri Forest runs and a Market pair, Threaded rendering off), with no FATAL, device lost or Vulkan error in any run, and every run closed by itself with exit code 0 (no close gave up on the queue). The Test Farm's picture at kokiri-start (HumanBean's run of this pull request, [#issuecomment-70269](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2156#issuecomment-70269), Windows RX 9060 XT, `RX_VK_SUBMIT_WORKER=0`) was taken inside the load's fade-in from black: main's two starts and one of this pull request's were a uniform black frame and the 0.865 start was the finished scene, so the comparison measured when the fade ended, not what was drawn. #1995's run [#issuecomment-67740](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1995#issuecomment-67740) shows the same scene and camera as main in its pictures, with only the animation's phase differing (Navi's place, Link's idle pose, the curtain). **Still to test:** - Windows 11, i7-9700, RTX 4060 (this PC): Hyrule Field with Threaded rendering off, unset against `RX_VK_SUBMIT_WORKER=1`, and a picture of each at an input-free point beside main against itself (Kokiri Forest and the Market have run: Measurements), expecting the same picture (by hand) - Windows 11, i7-9700, RTX 4060 (this PC): the same with Threaded rendering on and Auto, expecting the log to say the thread is off with the recorder thread when `RX_VK_SUBMIT_WORKER=1`, and the frame times the same as unset (by hand) - Windows 11, i7-9700, RTX 4060 (this PC): close the window while playing with `RX_VK_SUBMIT_WORKER=1` and Threaded rendering off, expecting the game to close at once with no crash report (by hand) - Linux NVIDIA, Windows AMD and Intel: Kokiri Forest and Hyrule Field, play three minutes each with Threaded rendering off: this branch unset (off) and with `RX_VK_SUBMIT_WORKER=1`, warmed up, ABBA, expecting the same picture, no FATAL or device lost, and the frame times showing whether `=1` gains or loses (Test Farm: linux+nvidia, windows+amd, windows+intel: Kokiri Forest and Hyrule Field three minutes each, Threaded rendering off: this branch unset and with RX_VK_SUBMIT_WORKER=1, warmed up, ABBA, the log, frame times and a screenshot) - Linux AMD and Steam Deck (RADV): one start with `RX_VK_SUBMIT_WORKER=1`, expecting the log to say it is off with RADV and the frame times the same as unset (Test Farm: linux+amd, steamdeck: Kokiri Forest one minute with RX_VK_SUBMIT_WORKER=1 and unset, the log and frame times) - Linux: build the renderer and run `python3 -I -B tests/test_submit_worker.py`, expecting PASS (by hand) ## Measurements **Verdict:** the submit thread takes the driver's submits off the replaying thread, and the frame does not show it. In the CPU-paced comparison on this PC (Kokiri Forest at an 800x600 output, Threaded rendering off, one runtime of this head, unset against `RX_VK_SUBMIT_WORKER=1`, 8 runs a side; In play below), the replaying thread's queue submit went from 0.53 to 0.00 ms a frame (p = 0.0002), the submit thread making about 11 submits a frame in 0.60 ms of `vkQueueSubmit2`, and the replay's submit time fell 3.5 % (p = 0.009). But the game's own code took 7 % longer on the same thread (2.88 against 3.07 ms a frame, p = 0.0002), and the median frame was 12.71 against 12.78 ms (p = 0.55): the time moved, the frame did not gain. Frames of 50 ms or more were 77 against 116 (p = 0.049) in this one sitting, not claimed. `RX_VK_SUBMIT_WORKER` ships off (an attempt), as dazemc's review asked; this run gives no reason to turn it on. **Baseline:** this PR with `RX_VK_SUBMIT_WORKER` unset (#1995's path) in the same runtime as `=1`: one build, so the switch is the only difference. Main itself was not run in this comparison. **In play** (held job `seg-pt-sw`, 23:44 UTC on 2026-11-23 to 00:35 UTC on 2026-11-24): one runtime of this head dfe6b9c5 (on #1995's 9e640b66, on main 9dd41326), Threaded rendering off in every run as the menu's Off sets it (`RX_VK_ASYNC=0` and `RX_VK_RECORDER=off`: each run's switches line has both, and no run has the render thread's line), since the submit thread works only with the replay on the submitting thread; `RX_VK_PROF_FINE=1` on both sides. Kokiri Forest, 60 s a run, CPU-paced on purpose (an 800x600 window), a warm-up a side, then unset and `=1` interleaved (off on on off, four times); every run in the scene's light state, loaded at create, on a desktop at 800x600 at 30 Hz. No run was left out, no load marker or strike file appeared, and no run's log has a commit-limit line. Then the Market, one run a side, as a reference. With Threaded rendering off the game's thread also replays and submits: calm game time is the game's own code only, and the frame is the median frame time. Reach: the submit thread's own line every 120 presents (`vk: submit thread: N submits, X ms in vkQueueSubmit2 ...`) on the `=1` side: in steady play 11.0 to 11.4 submits a frame, 0.58 to 0.62 ms a frame in `vkQueueSubmit2`, each held 16 to 18 us before the thread sent it (0.29 to 0.33 ms a frame in the load). | a side: median (range), Kokiri Forest | Before: this PR @ dfe6b9c5, unset, 8 runs | After: this PR @ dfe6b9c5, `RX_VK_SUBMIT_WORKER=1`, 8 runs | change of the means, p (swap test) | |---|---|---|---| | the replaying thread's queue submit, ms a frame, steady play | 0.53 (0.51 to 0.55) | 0.00 | -99.9 %, 0.0002 | | the same, the load | 0.25 (0.23 to 0.26) | 0.00 | -99.6 %, 0.0002 | | `a frame's replay time (ms)`: submit | 8.94 (8.46 to 9.03) | 8.60 (8.30 to 8.83) | -3.5 %, 0.009 | | calm-stretch game_ms (the game's code) | 2.88 (2.72 to 2.97) | 3.07 (3.01 to 3.12) | +7.1 %, 0.0002 | | main_blocked_ms | 10.14 (9.88 to 10.32) | 10.01 (9.65 to 10.37) | -1.0 %, 0.35 | | median frame time, ms | 12.78 (12.51 to 12.94) | 12.71 (12.24 to 13.06) | -0.6 %, 0.55 | | frames a second | 74.2 (68.7 to 75.6) | 75.0 (69.6 to 77.0) | +1.1 %, 0.50 | | p99 frame time, ms | 42.8 (35.9 to 48.0) | 41.3 (39.4 to 44.3) | -2.8 %, 0.43 | | frames of 50 ms or more, all runs | 116 | 77 | 0.049 | | draw, ms a frame | 4.32 (4.16 to 4.46) | 4.37 (4.22 to 4.48) | +1.1 %, 0.33 | | `a frame's replay time (ms)`: draw | 4.42 (4.29 to 4.63) | 4.45 (4.33 to 4.61) | +0.9 %, 0.45 | The tail is high on both sides (p99 over 40 ms), as in #2030's runs in the same sitting, both on runtimes over main 9dd41326 with Threaded rendering off; those long frames are the game's own thread (32 to 54 ms of its code, about 50 to 66 ms blocked in them) on both sides. The Market pair (one run a side, a reference): main_blocked 12.64 against 11.52 ms, replay submit 10.90 against 9.99, p99 51.5 against 42.8, 41 against 17 frames of 50 ms or more, leaning the same way. ## Risks What could break, with the thread on (`RX_VK_SUBMIT_WORKER=1`; never on RADV, nor with the recorder thread): a held submit sent out of order or twice (a wrong picture or a device lost), one never sent (a hang: every wait sends what is held first, as with `RX_VK_BATCH`), the close waiting for the thread (2 s at most; a thread still in a driver submit then makes the close let the swapchain go with the process, as a present still running does, at once), a refused batch stopping the renderer where #1995 would go on without it, and a poll or a wait with a finite budget no longer sending what is held when the queue's lock is busy (the thread does: it was woken when the submit was held). Unset or `=0` is #1995's code. Renderer code: the runtime is rebuilt; nothing changes for players' saves, options or caches. ## Checklist ### Ready for review - [ ] One topic, on current `main`; the title is a Conventional Commit. - [ ] Tested on my own PC, in the game for a change the game runs, as Testing says. - [ ] `mise run test` passes (any failure that also fails on `main` is named). - [ ] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [ ] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold.
The host asks get_replayed under its recordings' lock, held exclusively (host/nvn_native.c free_dead_copies, at every
nvnCommandBufferAddControlMemory: 117 a frame in a CPU profile of Hyrule Field on the branch), to let go of the copies the
GPU is past, and every answer was a vkGetSemaphoreCounterValue there. completed() now keeps the highest value it has read
(completed_seen, it only goes up), and get_replayed answers from it, reading the driver at every 64th call so that it moves
when nothing replays. A lower answer only keeps a copy until a later call. Not while the bench holds the answer
(replayed_hold): the driver is read as before.

From the branch's replay-parts work (bd3ea307). Not measured: neither on the branch nor in play.

Test: tests/test_replayed_cache.py cuts completed(), replayed_cache_on() and get_replayed() from vk_replay.cpp and runs
them against a stand-in driver (63 of 64 answers without a driver call, the bench's hold and =0 read every time).

Switch: RX_VK_REPLAYED_CACHE (kill), on; =0 reads the driver at every call, as before.

Switch reads: the test also runs RX_VK_REPLAYED_CACHE as the source reads it, in fresh processes (unset, 0, 1, 2, off, each twice, the variable flipped after the first read: read once).

Assisted-by: Claude Code
tests/test_replayed_cache.py runs the real completed(), replayed_cache_on() and get_replayed() (gpu/vk/vk_replay.cpp) with
the host's free_dead_copies() and dead_copy_add() (host/nvn_native.c) in one fixture against a stand-in driver, each case
in a fresh process:

- a read that fails after writing a larger value keeps nothing and answers nothing above the last good read;
- a read that comes back VK_ERROR_DEVICE_LOST goes to device_lost();
- RX_VK_REPLAYED_CACHE as the renderer's start reads it: unset, empty, 0, 1, 2, off and no, each twice, the variable
  flipped after the read (the flip checked); off reads the driver at every call and keeps no value;
- a copy the GPU is past stays while the answer is the one last read, and goes at the read that follows.

The compiler: --cxx, CXX, LONGSHOT_MINGW's clang++ on Windows only, then clang++, g++ or c++ on PATH (run_all.py no longer
resolves one for it). Fails at this commit: the failed read is kept, the lost device is not reported, the off switch keeps
the value.

Assisted-by: Claude Code
completed() kept the counter value vkGetSemaphoreCounterValue wrote whatever it returned: a read that fails after writing a
larger value could become the last-read value the host's copies are let go by. Now a read that fails keeps nothing and
answers 0 (nothing taken as done), and VK_ERROR_DEVICE_LOST goes to device_lost(), as the GPU hang watch's read does.

RX_VK_REPLAYED_CACHE was read at the host's first question, under its recordings' lock held exclusively, and logged there;
and with it off completed() still kept the last-read value at every caller. It is now read and logged once by replay_start,
before the timeline is made and the renderer is given to the host, into an atomic; off, completed() keeps nothing and
get_replayed asks the driver at every call, as main.

The host's report every 50,000 recordings (host/nvn_native.c) also says the bytes of the copies let go and waiting for the
replay, their peak, and the passes that let them go with their time under the copies' lock, since the last report: what a
run needs to tell a shorter lock from larger, rarer let-go passes. The switch's row says what empty does and the cadence
(the first call and every 64th after, calls under the bench's hold not counted), and that copies can stay up to 63 calls.

Test: tests/test_replayed_cache.py (failed at the previous commit) passes.

Assisted-by: Claude Code
docs(vk): RX_VK_REPLAYED_CACHE's row says =0 is not exactly main, and the host says where the cached answer shows
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Description follows the template (pull_request_target) Successful in 5s
50b6ade9fc
The off text of the switch row says what stays changed with the switch off: every reader of the timeline
(completed()) takes a failed read as nothing done and ends the renderer on VK_ERROR_DEVICE_LOST, where main took
what the driver wrote, so an A/B side with RX_VK_REPLAYED_CACHE=0 is not main.

host/nvn_native.c: the nvnSyncWait sync log (debug) says its `done` is the host's answer, up to 63 calls old with
the switch on, and that its call counts as one of the 64; free_dead_copies says it times only the passes that let a
copy go (dead_first is the least `after` exactly, so a pass past the early return always lets one go).

Assisted-by: Claude Code
Needs "the host's question how far the replay is answered from the timeline as last read" (RX_VK_REPLAYED_CACHE) first:
it uses that commit's completed_seen.

- A slot is free again by its recording's number on the recordings' timeline (slot_free_by_seq): every recording's
  submit already signals that number, so the fence beside it said the same thing twice: a fence in each submit, and a
  wait for it and a reset at each reuse, 48 recordings later. The timeline's value is kept as last read and read again
  only for a number past it, about once a frame. Both submit_recording's own submit and the recorder thread's
  (part_submit, RX_VK_RECORDER_PARTS) carry no fence then; a held submit is sent first, as recording_wait does for one.
- The GPU timestamps of every recording that is done are read once a present (gpu_time_collect_done, one
  vkGetQueryPoolResults a run of neighbouring slots), not slot by slot as each comes round: 1.0 % of a core in a CPU
  profile of Hyrule Field on the branch. Each is counted as gpu_time_collect counts it (its time, its
  RX_VK_GPU_TIMELINE line, the A/B's side); with the frame overlap's tracking on, every slot is read as it comes round,
  as before, since fo_collect takes them in recording order.
- A later part of a submission (split_part) takes the GPU's progress as last read for the memory work's bookkeeping,
  instead of a driver call: a lower value only keeps what could go a part longer.
- Where submits are neither batched (RX_VK_BATCH unset, not RADV) nor the recorder thread's, a recording's submit is held
  as a batched one is and a submit thread sends it at once (mkw_vk submit), while the replay goes on with the next part:
  submit_recording was 3.1 % of a core on the replaying threads on the branch (i7-9700, Kokiri Forest). With the recorder
  thread main already does this in its own form (RX_VK_RECORDER_PARTS: the recorder ends and submits each part), so the
  submit thread is not started there; it serves the render thread alone (Auto with 4 or 5 cores) and the submitting
  thread's replay. Not with the bench.

From the branch's replay-parts work (bd3ea307). Not measured as a whole, neither on the branch nor in play.

Tests: tests/test_submit_batch.py compiles the real gpu_time_note and gpu_time_collect_done with a stand-in driver (a call
a run of done slots, a slot not done or not there left for its own read, the counts, tracking and =0 reading nothing)
and reads submit_recording, part_submit, recording_wait, the submit thread and split_part for their order;
tests/test_fsr_uniform_ownership.py runs the real slot_free_by_seq through recording_wait and begin_recording (a slot by
its number, a held one sent first, a number reached already needing no driver call). The fixtures that cut
submit_recording, begin_recording or split_part (draw_stream_visibility, fsr_image_retirement, early_split_before_draw)
have the new stand-ins, and test_device_policy finds the batch policy in batch_wanted.

Switch: RX_VK_SUBMIT_BATCH (kill), on; =0 a fence a slot, timestamps read slot by slot, the timeline read at every
recording and the submit made by the replaying thread, as before.

Switch reads: the test also runs RX_VK_SUBMIT_BATCH as the source reads it, in fresh processes (unset, 0, 1, 2, off, each twice, the variable flipped after the first read: read once). If the submit thread cannot be started, the replaying thread submits, as with =0.

Assisted-by: Claude Code
Two of the four parts of RX_VK_SUBMIT_BATCH are taken out:

- the submit thread (mkw_vk submit, which sent held submits where nothing else batches them): it is unmeasured, on by
  default, and BeanBot's review 63010 found ten points in it (its start after held work, its lifetime at exit, profiling
  from another thread, RADV GCN, blocking polls, Reflex frames, RX_VK_GPU_TIMELINE's submit time, its tests, its counters).
  It is to be reviewed on its own once fixed and measured in play, off by default; batch_on is main's again;
- split_part's next recording taking the timeline as last read (completed_for_recording): a value read before an earlier
  GPU write finished can keep a uniform range's pending writer and change what a draw reads (review 63010 L8).
  begin_recording reads the timeline at every recording, as main.

What stays: a slot free again by its recording's number on the recordings' timeline (no fence), and the timestamps of the
recordings that are done read once a present. The fixtures lose the submit thread's stand-ins; test_device_policy,
test_early_split_before_draw and test_ub_snapshot_gpu_writes are main's again; test_submit_batch.py no longer reads them.

Assisted-by: Claude Code
tests/fsr_uniform_ownership_test.cpp (the real slot_free_by_seq through begin_recording and recording_wait): the
recordings' timeline is a handle of its own, its read and wait check it, and the wait must be for the slot's own
recording's number; a wait that fails (VK_ERROR_OUT_OF_HOST_MEMORY) must stop the renderer (replay_fatal) and one that
comes back VK_ERROR_DEVICE_LOST, or a lost device at the timeline's read, must go to device_lost(), the slot not reused.

tests/test_submit_batch.py (the real gpu_time_collect_done): VK_ERROR_DEVICE_LOST from the timeline's read or the queries'
goes to device_lost(); with RX_VK_GPU_TIMELINE on nothing is read there (each slot is read when it comes round, after the
recorder's submit that wrote its submit time). The switch's cases add empty and no, and the flip after the first read is
checked. The compiler: --cxx, CXX, LONGSHOT_MINGW's clang++ on Windows only, then clang++, g++ or c++ on PATH.

tests/test_fsr_image_retirement.py and tests/test_draw_stream_visibility.py run their fixtures without RX_VK_BATCH_MAX,
which the real submit_recording reads: a developer's own cap sent the batch the cases hold.

Fails at this commit: the failed wait reuses the slot, the lost devices are not reported, the timestamps are collected
with RX_VK_GPU_TIMELINE on.

Assisted-by: Claude Code
slot_free_by_seq freed the slot whatever vkWaitSemaphores returned: a wait that failed (an allocation error) with the
recording still running let begin_recording reset its pools and reuse its streams. A lost device at that wait or at the
timeline's read now goes to device_lost(); a wait that failed otherwise stops the renderer (replay_fatal): the slot is
never reused without its recording's completion.

gpu_time_collect_done ignored a lost device at the timeline's and the queries' read; both now go to device_lost(). With
RX_VK_GPU_TIMELINE on it no longer reads: a slot's submit time is written by the thread that submits it (the recorder's
part_submit with RX_VK_RECORDER=thread), and only the slot's own read (recording_wait, after the recorder's ticket) is
ordered after that write; each slot is then read when it comes round, as before.

Test: tests/test_fsr_uniform_ownership.py and tests/test_submit_batch.py (failed at the previous commit) pass.

Assisted-by: Claude Code
Nothing is batched by the switch since the submit thread went: it frees a recording slot by its recording's number on
the recordings' timeline (no fence in the submit) and reads the done recordings' timestamps once a present. The old
name read as a relative of RX_VK_BATCH / RX_VK_BATCH_MAX, which hold submits, so a tester setting it to 0 to turn
batching off would have got neither. The row (moved to its place in the table), submit_batch_on (now
slot_by_timeline_on), the log line, the comments, the fixtures' stand-ins and the test (tests/test_submit_batch.py,
now tests/test_slot_by_timeline.py) all take the new name; no behaviour changes.

The row also says that the timestamp half runs only while the frame overlap's tracking is off (the render thread off:
Threaded rendering Off, or Auto below 4 cores), that nothing here holds submits, and that both this switch and
RX_VK_REPLAYED_CACHE at 0 still differ from main on a failed timeline read.

Suggested by dyst in review.

Assisted-by: Claude Code
test(vk): RX_VK_SLOT_BY_TIMELINE: a submit given its recording's number carries no fence, a switched-off one does
Some checks failed
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval approved by HumanBean (reviewed)
beanstalk/any 2/1 fail
PR description / Description follows the template (pull_request_target) Successful in 5s
9e640b6694
tests/fsr_image_retirement_test.cpp's new slot-fence case runs the real submit_recording three times and checks the
fence it hands vkQueueSubmit2: none with the switch on and a recordings' timeline (the slot keeps its number), the
slot's own fence with the switch off, and the slot's own fence with no recordings' timeline (no number), as before.
Until now the fence-less submit was checked only as source text in tests/test_slot_by_timeline.py.

The fixture does not build on main 9dd41326 (its stand-ins are behind main's recording code); #2037 repairs it, so
the case runs once both are in.

Suggested by dyst in review.

Assisted-by: Claude Code
perf(vk): a submit thread sends the submits the replay holds where nothing else batches them (RX_VK_SUBMIT_WORKER)
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 6s
beanstalk/approval approved by HumanBean (reviewed)
beanstalk/any 1/1 fail
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
6c7991cb74
The submit thread taken out of #1995 (4f6b9d10), back on its own, on by default, with the review's points on it (#1995,
review 63010: L1, L3, L4, L5, L9, L10, L11, L12, L14, L17):

- Where submits are neither batched (RX_VK_BATCH) nor the recorder thread's, a recording's submit is held as a batched one
  is and a thread of its own (mkw_vk submit, submit_worker_main) sends what is held at once, under dev.present_mu, in the
  order it was held; the replay goes on with the next part. Nothing waits on it: every wait sends what is held first, as
  with RX_VK_BATCH.
- Started once, at the replay's start, after the batches' timeline is made and before anything can be held (L1); a thread
  that cannot be started leaves every submit to the replaying thread, with nothing held.
- A held batch the driver refuses stops the renderer (replay_fatal) when the worker is on: none of its signals would come
  and its waiters would wait for good (L3). RX_VK_BATCH's own batches keep main's handling.
- The worker's vkQueueSubmit2 time and count are its own atomic counters (sw_submit_ns, sw_submits), not PROF_QSUBMIT, the
  replaying thread's phase (L4).
- Its state is never destroyed (as the recorder's), and the close stops it (submit_worker_stop, 2 s at most) before the
  swapchain is let go (L5).
- Never with RADV, GCN included (L9), RX_VK_BATCH set, batched submits, the recorder thread, RX_VK_GPU_TIMELINE (its
  submit time is the replaying thread's, L12) or RX_VK_BENCH; the log says which.
- With the worker, a progress poll and a wait with a finite budget never wait for the queue's lock (a busy queue is left
  to the worker), and a flush they make is taken from the budget (L10).
- A submit of another game frame sends the batch held for the frame before (reflex_split_wanted, FR_REFLEX) (L11).
- Every 120 presents a line gives the worker's submits, its time in vkQueueSubmit2, and the flushes by reason with the
  mean time from held to submitted (L17).
- Switch RX_VK_SUBMIT_WORKER (kill, on; empty, 0, off, false or no: off), read once at the replay's start; off gives
  #1995's code. Not measured in play.
- Test: tests/test_submit_worker.py compiles the source's worker, its start, stop, kick and Reflex split, batch_on,
  queue_flush_locked, queue_flush_for and queue_flush_poll against a fake queue: an idle worker wakes and sends a held
  submit once, fifty in order once each, the counters apart, the Reflex split, an injected thread failure, every case it
  must stay off in, the stop asleep and with a submit held, a refused batch, the polls with the lock busy (and off as
  before), and the switch read once in fresh processes; it reads the wiring in submit_recording, replay_start and the close.
  The two fixtures that compile submit_recording get the worker's stand-ins (off).

Assisted-by: Claude Code
Author
Contributor

@Beanstalk This gives the Vulkan replay's submits a thread of their own when the replay runs on the submitting thread, that is with Threaded rendering off (gpu/vk); RADV is left out; RX_VK_SUBMIT_WORKER=0 turns it off. It sits on #1995 (9e640b66, itself on #1994), so its diff against its merge base includes those PRs' commits; the farm cannot take them as the comparison, so please compare with main. Please start from the kokiri-start save and take the picture right after it loads and settles, before any input, with a main-against-itself picture on the same PC at that point; then, for frame times only, play Kokiri Forest and Hyrule Field, two minutes each; at least two starts a side, interleaved, the PR against main on the same PC, on the PR's side unset (the default, on) and with RX_VK_SUBMIT_WORKER=0 (off), on Windows with an RTX 4070, Windows with an Arc B580 and Linux with an RTX 3080 Ti (not RADV, which this change leaves out). The farm cannot set Threaded rendering, so with the default settings this run checks that nothing changes; the Threaded-rendering-off path, where the submit thread runs, is checked by hand, unless a tester has a CPU with fewer than 4 cores, where the game runs with Threaded rendering off. The same picture as main within main's own difference from itself; with it unset, frame time p99 equal to main's or better, within the run-to-run spread, and equal to RX_VK_SUBMIT_WORKER=0 or better. The log must have no FATAL, device lost or validation error line. Where Threaded rendering is off, the log must have the submit thread's line every 120 presents with the switch unset and none with RX_VK_SUBMIT_WORKER=0; please report it either way.

@Beanstalk This gives the Vulkan replay's submits a thread of their own when the replay runs on the submitting thread, that is with Threaded rendering off (gpu/vk); RADV is left out; RX_VK_SUBMIT_WORKER=0 turns it off. It sits on #1995 (9e640b66, itself on #1994), so its diff against its merge base includes those PRs' commits; the farm cannot take them as the comparison, so please compare with main. Please start from the kokiri-start save and take the picture right after it loads and settles, before any input, with a main-against-itself picture on the same PC at that point; then, for frame times only, play Kokiri Forest and Hyrule Field, two minutes each; at least two starts a side, interleaved, the PR against main on the same PC, on the PR's side unset (the default, on) and with RX_VK_SUBMIT_WORKER=0 (off), on Windows with an RTX 4070, Windows with an Arc B580 and Linux with an RTX 3080 Ti (not RADV, which this change leaves out). The farm cannot set Threaded rendering, so with the default settings this run checks that nothing changes; the Threaded-rendering-off path, where the submit thread runs, is checked by hand, unless a tester has a CPU with fewer than 4 cores, where the game runs with Threaded rendering off. The same picture as main within main's own difference from itself; with it unset, frame time p99 equal to main's or better, within the run-to-run spread, and equal to RX_VK_SUBMIT_WORKER=0 or better. The log must have no FATAL, device lost or validation error line. Where Threaded rendering is off, the log must have the submit thread's line every 120 presents with the switch unset and none with RX_VK_SUBMIT_WORKER=0; please report it either way.
Member

@siantm only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@siantm only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
Owner

@Beanstalk

@Beanstalk
Member
Beanstalk test farm · an earlier run: commit 6c7991c (the newer results are in a comment below)

Commit 6c7991c · approved by HumanBean (reviewed) · dashboard

⚠️ Note: The default rendering configuration may use the recorder thread, and RADV disables the submit worker; in either case the worker-on and worker-off runs exercise the same worker path.
⚠️ Note: The farm cannot set Threaded rendering or compare main against itself for a picture-noise threshold; it also cannot compare the PR’s unset switch directly against its off cell here.
⚠️ Note: The requested exact hardware, three-way comparison against the dependency branch, active play, and window-close test are not included.

Summary, written by AI (gpt-6.1-terra) from the numbers below:

The change failed on the “any” target: the Windows RX 9060 XT report failed, while the Linux Radeon 760M report passed. With the submit worker off, the Windows report’s maximum screenshot difference rose from 0 to 0.865, exceeding the 0.05 limit; its field frame-time p99 was essentially unchanged at 18.90 → 18.91 ms. On Linux, frame-time p99 improved from 48.55 → 42.91 ms in Hyrule Field and 85.75 → 51.83 ms in Kokiri Forest.

Done (started 2026-11-21 23:30 UTC, last report 01:41 UTC). Comment @Beanstalk to run it again.

Target Result Reports Frame time p99 (ms), main → PR VRAM peak (MB) Crashes
any ❌ fail (an outlier) 2 1 2 33.7 → 30.9 (−8%) — none

Why it failed

  • any: forest-field · RX_VK_SUBMIT_WORKER=0 (PR only) screenshot.max_diff: 0.0 → 0.9; limit 0.1
What was tested

What will be tested · AI plan (gpt-6.1-terra)

The plan compares main with the PR’s default and submit-worker-off configurations, starting at the Kokiri checkpoint and measuring two minutes each in Kokiri Forest and Hyrule Field. It compares the settled starting picture and frame times, and fails on crashes, fatal or device-lost logs, validation errors, substantial picture differences, or a p99 frame-time regression over 15%. The run takes roughly an hour per tester; the worker may be inactive under the tester’s default rendering configuration.

  • Where: any (any PC, 1-2 reports).
  • Matrix: 1 cell, each on main and the PR: RX_VK_SUBMIT_WORKER 0 (PR only).
  • forest-field: from the repository's save kokiri-start, then take the picture kokiri-start to compare with main, teleport to Kokiri Forest, measure forest for 2 min (after 10 s warm-up), teleport to Hyrule Field, measure field for 2 min (after 10 s warm-up); 2 runs on each side.
  • Measured: crashes, frame times, stutters and hitches, the game's log.
  • The PR fails if: it crashes; or a picture differs from main by more than 5%; or frame time (p99) is more than 15% above main; or forbidden log lines is above 0.
  • Time: about 38 min of game runs per tester (4 game starts), plus the two builds.
Measurements on `any`, for the PR description

Verdict: fail on any (2 reports): forest-field screenshot.max_diff failed.

Hardware: 1: windows+amd+amd-proprietary+dgpu AMD Radeon RX 9060 XT, 2.0.416 AMD Ryzen 5 5600 6-Core Processor, 32 GB RAM; 2: linux+amd+radv+igpu AMD Radeon 760M Graphics (RADV PHOENIX), 26.0.8 AMD Ryzen 5 230 w/ Radeon 760M Graphics, 16 GB RAM
Scene: forest-field, from the repository's save kokiri-start; each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); forest-field: 2 game starts a side, forest 120 s after 10 s warm-up, field 120 s after 10 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (@Beanstalk on this PR runs it again)

Before: main @ 9dd4132 After: this PR @ 6c7991c
forest-field · RX_VK_SUBMIT_WORKER=0 (PR only) · field · frame time (p99) (ms) 33.7 30.9 (−8%)
forest-field · RX_VK_SUBMIT_WORKER=0 (PR only) · forest · frame time (p99) (ms) 52.4 35.3 (−33%)
forest-field · RX_VK_SUBMIT_WORKER=0 (PR only) · forbidden log lines 0.0 0.0

Flags and settings

Flag What it is Values tried Before this PR After this PR Effect (frame time (p99)) Helps / doesn't help / untested
RX_VK_SUBMIT_WORKER switch the PR adds (set on the PR side only) 0 not in main the PR's default forest-field, main without it → the PR with 0: 33.7 → 30.9 (−8%) helps

As Markdown for the PR description:

## Measurements

**Verdict:** fail on any (2 reports): `forest-field screenshot.max_diff` failed.

Hardware: 1: windows+amd+amd-proprietary+dgpu `AMD Radeon RX 9060 XT, 2.0.416` `AMD Ryzen 5 5600 6-Core Processor, 32 GB RAM`; 2: linux+amd+radv+igpu `AMD Radeon 760M Graphics (RADV PHOENIX), 26.0.8` `AMD Ryzen 5 230 w/ Radeon 760M Graphics, 16 GB RAM`  
Scene: forest-field, from the repository's save kokiri-start; each cell's settings and switches as the table names them  
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); forest-field: 2 game starts a side, forest 120 s after 10 s warm-up, field 120 s after 10 s warm-up; each number the median of the runs, then of 2 reports  
How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again)

| | Before: main @ 9dd4132 | After: this PR @ 6c7991c |
|---|---|---|
| forest-field · `RX_VK_SUBMIT_WORKER=0 (PR only)` · field · frame time (p99) (ms) | 33.7 | 30.9 (−8%) |
| forest-field · `RX_VK_SUBMIT_WORKER=0 (PR only)` · forest · frame time (p99) (ms) | 52.4 | 35.3 (−33%) |
| forest-field · `RX_VK_SUBMIT_WORKER=0 (PR only)` · forbidden log lines | 0.0 | 0.0 |

**Flags and settings**

| Flag | What it is | Values tried | Before this PR | After this PR | Effect (frame time (p99)) | Helps / doesn't help / untested |
|---|---|---|---|---|---|---|
| `RX_VK_SUBMIT_WORKER` | switch the PR adds (set on the PR side only) | `0` | not in main | the PR's default | forest-field, main without it → the PR with 0: 33.7 → 30.9 (−8%) | helps |
The testers' hardware
Target Report Ran on
any 1 windows+amd+amd-proprietary+dgpu AMD Radeon RX 9060 XT, 2.0.416 AMD Ryzen 5 5600 6-Core Processor, 32 GB RAM
any 2 linux+amd+radv+igpu AMD Radeon 760M Graphics (RADV PHOENIX), 26.0.8 AMD Ryzen 5 230 w/ Radeon 760M Graphics, 16 GB RAM
<!-- beanstalk:previous --> <details><summary>Beanstalk test farm · an earlier run: commit <code>6c7991c</code> (the newer results are in a comment below)</summary> Commit `6c7991c` · approved by HumanBean (reviewed) · [dashboard](https://beanstalk.magicbean.dev/prs/2156) ⚠️ **Note:** The default rendering configuration may use the recorder thread, and RADV disables the submit worker; in either case the worker-on and worker-off runs exercise the same worker path. ⚠️ **Note:** The farm cannot set Threaded rendering or compare main against itself for a picture-noise threshold; it also cannot compare the PR’s unset switch directly against its off cell here. ⚠️ **Note:** The requested exact hardware, three-way comparison against the dependency branch, active play, and window-close test are not included. > **Summary**, written by AI (`gpt-6.1-terra`) from the numbers below: > > The change failed on the “any” target: the Windows RX 9060 XT report failed, while the Linux Radeon 760M report passed. With the submit worker off, the Windows report’s maximum screenshot difference rose from 0 to 0.865, exceeding the 0.05 limit; its field frame-time p99 was essentially unchanged at 18.90 → 18.91 ms. On Linux, frame-time p99 improved from 48.55 → 42.91 ms in Hyrule Field and 85.75 → 51.83 ms in Kokiri Forest. Done (started 2026-11-21 23:30 UTC, last report 01:41 UTC). Comment `@Beanstalk` to run it again. | Target | Result | Reports | Frame time p99 (ms), main → PR | VRAM peak (MB) | Crashes | | --- | --- | --- | --- | --- | --- | | `any` | ❌ fail (an outlier) | 2 [1](https://beanstalk.magicbean.dev/reports/rp_21f5665de94c15dd) [2](https://beanstalk.magicbean.dev/reports/rp_42b2be9830e7a8ce) | 33.7 → 30.9 (−8%) | — | none | **Why it failed** - `any`: `forest-field · RX_VK_SUBMIT_WORKER=0 (PR only)` `screenshot.max_diff`: `0.0 → 0.9; limit 0.1` <details><summary>What was tested</summary> **What will be tested** · AI plan (`gpt-6.1-terra`) The plan compares main with the PR’s default and submit-worker-off configurations, starting at the Kokiri checkpoint and measuring two minutes each in Kokiri Forest and Hyrule Field. It compares the settled starting picture and frame times, and fails on crashes, fatal or device-lost logs, validation errors, substantial picture differences, or a p99 frame-time regression over 15%. The run takes roughly an hour per tester; the worker may be inactive under the tester’s default rendering configuration. - **Where:** any (any PC, 1-2 reports). - **Matrix:** 1 cell, each on main and the PR: RX_VK_SUBMIT_WORKER `0` (PR only). - **forest-field:** from the repository's save `kokiri-start`, then take the picture kokiri-start to compare with main, teleport to Kokiri Forest, measure forest for 2 min (after 10 s warm-up), teleport to Hyrule Field, measure field for 2 min (after 10 s warm-up); 2 runs on each side. - **Measured:** crashes, frame times, stutters and hitches, the game's log. - **The PR fails if:** it crashes; or a picture differs from main by more than 5%; or frame time (p99) is more than 15% above main; or forbidden log lines is above 0. - **Time:** about 38 min of game runs per tester (4 game starts), plus the two builds. </details> <details><summary>Measurements on `any`, for the PR description</summary> **Verdict:** fail on any (2 reports): `forest-field screenshot.max_diff` failed. Hardware: 1: windows+amd+amd-proprietary+dgpu `AMD Radeon RX 9060 XT, 2.0.416` `AMD Ryzen 5 5600 6-Core Processor, 32 GB RAM`; 2: linux+amd+radv+igpu `AMD Radeon 760M Graphics (RADV PHOENIX), 26.0.8` `AMD Ryzen 5 230 w/ Radeon 760M Graphics, 16 GB RAM` Scene: forest-field, from the repository's save kokiri-start; each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); forest-field: 2 game starts a side, forest 120 s after 10 s warm-up, field 120 s after 10 s warm-up; each number the median of the runs, then of 2 reports How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) | | Before: main @ 9dd4132 | After: this PR @ 6c7991c | |---|---|---| | forest-field · `RX_VK_SUBMIT_WORKER=0 (PR only)` · field · frame time (p99) (ms) | 33.7 | 30.9 (−8%) | | forest-field · `RX_VK_SUBMIT_WORKER=0 (PR only)` · forest · frame time (p99) (ms) | 52.4 | 35.3 (−33%) | | forest-field · `RX_VK_SUBMIT_WORKER=0 (PR only)` · forbidden log lines | 0.0 | 0.0 | **Flags and settings** | Flag | What it is | Values tried | Before this PR | After this PR | Effect (frame time (p99)) | Helps / doesn't help / untested | |---|---|---|---|---|---|---| | `RX_VK_SUBMIT_WORKER` | switch the PR adds (set on the PR side only) | `0` | not in main | the PR's default | forest-field, main without it → the PR with 0: 33.7 → 30.9 (−8%) | helps | As Markdown for the PR description: ```markdown ## Measurements **Verdict:** fail on any (2 reports): `forest-field screenshot.max_diff` failed. Hardware: 1: windows+amd+amd-proprietary+dgpu `AMD Radeon RX 9060 XT, 2.0.416` `AMD Ryzen 5 5600 6-Core Processor, 32 GB RAM`; 2: linux+amd+radv+igpu `AMD Radeon 760M Graphics (RADV PHOENIX), 26.0.8` `AMD Ryzen 5 230 w/ Radeon 760M Graphics, 16 GB RAM` Scene: forest-field, from the repository's save kokiri-start; each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); forest-field: 2 game starts a side, forest 120 s after 10 s warm-up, field 120 s after 10 s warm-up; each number the median of the runs, then of 2 reports How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) | | Before: main @ 9dd4132 | After: this PR @ 6c7991c | |---|---|---| | forest-field · `RX_VK_SUBMIT_WORKER=0 (PR only)` · field · frame time (p99) (ms) | 33.7 | 30.9 (−8%) | | forest-field · `RX_VK_SUBMIT_WORKER=0 (PR only)` · forest · frame time (p99) (ms) | 52.4 | 35.3 (−33%) | | forest-field · `RX_VK_SUBMIT_WORKER=0 (PR only)` · forbidden log lines | 0.0 | 0.0 | **Flags and settings** | Flag | What it is | Values tried | Before this PR | After this PR | Effect (frame time (p99)) | Helps / doesn't help / untested | |---|---|---|---|---|---|---| | `RX_VK_SUBMIT_WORKER` | switch the PR adds (set on the PR side only) | `0` | not in main | the PR's default | forest-field, main without it → the PR with 0: 33.7 → 30.9 (−8%) | helps | ``` </details> <details><summary>The testers' hardware</summary> | Target | Report | Ran on | | --- | --- | --- | | `any` | [1](https://beanstalk.magicbean.dev/reports/rp_21f5665de94c15dd) | windows+amd+amd-proprietary+dgpu `AMD Radeon RX 9060 XT, 2.0.416` `AMD Ryzen 5 5600 6-Core Processor, 32 GB RAM` | | `any` | [2](https://beanstalk.magicbean.dev/reports/rp_42b2be9830e7a8ce) | linux+amd+radv+igpu `AMD Radeon 760M Graphics (RADV PHOENIX), 26.0.8` `AMD Ryzen 5 230 w/ Radeon 760M Graphics, 16 GB RAM` | </details> </details>
Author
Contributor

@HumanBean thank you for this run. In its pictures (#issuecomment-70269, report rp_21f5665de94c15dd, Windows RX 9060 XT, RX_VK_SUBMIT_WORKER=0), main's two starts and the pull request's first are a uniform black frame at kokiri-start, and the 0.865 start is the finished scene: the capture point falls inside the load's fade-in from black, so the comparison measured when the fade ended, not what was drawn. Frame times in that cell were flat (p99 18.8 to 19.0 ms on both sides), with no crash and no forbidden log line. #1995's run #issuecomment-67740 shows the same scene and camera as main in its pictures, with only the animation's phase differing. The request is being restated with the picture taken after the fade-in, and Testing here and on #1995 now says this.

@HumanBean thank you for this run. In its pictures ([#issuecomment-70269](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2156#issuecomment-70269), report rp_21f5665de94c15dd, Windows RX 9060 XT, `RX_VK_SUBMIT_WORKER=0`), main's two starts and the pull request's first are a uniform black frame at kokiri-start, and the 0.865 start is the finished scene: the capture point falls inside the load's fade-in from black, so the comparison measured when the fade ended, not what was drawn. Frame times in that cell were flat (p99 18.8 to 19.0 ms on both sides), with no crash and no forbidden log line. #1995's run [#issuecomment-67740](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1995#issuecomment-67740) shows the same scene and camera as main in its pictures, with only the animation's phase differing. The request is being restated with the picture taken after the fade-in, and Testing here and on #1995 now says this.
Author
Contributor

@Beanstalk This replaces my request 70219 on this head, so that it follows the farm's picture and hardware rules. Run 70269 took its pictures during the load's fade-in from black in 3 of 4 starts, so the picture difference it reported does not count. This gives the Vulkan replay's submits a thread of their own when the replay runs on the submitting thread, that is with Threaded rendering off (gpu/vk); RADV is left out; RX_VK_SUBMIT_WORKER=0 turns it off. It sits on #1995 (9e640b66, itself on #1994), so its diff against its merge base includes those PRs' commits; the farm cannot take them as the comparison, so please compare with main. Please start from the kokiri-start save and take the picture 5 s (300 frames at 60 fps) after the first frame whose picture is not a single uniform colour, with no input in between (a picture during the load's fade-in from black is not comparable), with a main-against-itself picture on the same PC from the same point; then, for frame times only, play Kokiri Forest and Hyrule Field, two minutes each; at least two starts a side, interleaved, the PR against main on the same PC, on the PR's side unset (the default, on) and with RX_VK_SUBMIT_WORKER=0 (off), on Windows with an RX 9060 XT, Windows with an RTX 4070, Windows with an Arc B580 and Linux with an RTX 3080 Ti (not RADV, which this change leaves out). The farm cannot set Threaded rendering, so with the default settings this run checks that nothing changes; the Threaded-rendering-off path, where the submit thread runs, is checked by hand, unless a tester has a CPU with fewer than 4 cores, where the game runs with Threaded rendering off. The same picture as main within main's own difference from itself; with it unset, frame time p99 equal to main's or better, within the run-to-run spread, and equal to RX_VK_SUBMIT_WORKER=0 or better. The log must have no FATAL, device lost or validation error line. Where Threaded rendering is off, the log must have the submit thread's line every 120 presents with the switch unset and none with RX_VK_SUBMIT_WORKER=0; please report it either way.

@Beanstalk This replaces my request 70219 on this head, so that it follows the farm's picture and hardware rules. Run 70269 took its pictures during the load's fade-in from black in 3 of 4 starts, so the picture difference it reported does not count. This gives the Vulkan replay's submits a thread of their own when the replay runs on the submitting thread, that is with Threaded rendering off (gpu/vk); RADV is left out; RX_VK_SUBMIT_WORKER=0 turns it off. It sits on #1995 (9e640b66, itself on #1994), so its diff against its merge base includes those PRs' commits; the farm cannot take them as the comparison, so please compare with main. Please start from the kokiri-start save and take the picture 5 s (300 frames at 60 fps) after the first frame whose picture is not a single uniform colour, with no input in between (a picture during the load's fade-in from black is not comparable), with a main-against-itself picture on the same PC from the same point; then, for frame times only, play Kokiri Forest and Hyrule Field, two minutes each; at least two starts a side, interleaved, the PR against main on the same PC, on the PR's side unset (the default, on) and with RX_VK_SUBMIT_WORKER=0 (off), on Windows with an RX 9060 XT, Windows with an RTX 4070, Windows with an Arc B580 and Linux with an RTX 3080 Ti (not RADV, which this change leaves out). The farm cannot set Threaded rendering, so with the default settings this run checks that nothing changes; the Threaded-rendering-off path, where the submit thread runs, is checked by hand, unless a tester has a CPU with fewer than 4 cores, where the game runs with Threaded rendering off. The same picture as main within main's own difference from itself; with it unset, frame time p99 equal to main's or better, within the run-to-run spread, and equal to RX_VK_SUBMIT_WORKER=0 or better. The log must have no FATAL, device lost or validation error line. Where Threaded rendering is off, the log must have the submit thread's line every 120 presents with the switch unset and none with RX_VK_SUBMIT_WORKER=0; please report it either way.
Member

@siantm only members of BigBeans can start the farm.

One of them can approve this request by reacting 👍 to it or to this comment. This request was for 6c7991c, and the PR has changed since (dfe6b9c), so a 👍 no longer approves it. Comment @Beanstalk again to ask for the new commit.

@siantm only members of `BigBeans` can start the farm. ~~One of them can approve this request by reacting 👍 to it or to this comment.~~ This request was for `6c7991c`, and the PR has changed since (`dfe6b9c`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
dazemc left a comment

The switch ships on, but the on path has never run in the game: not on this PC, and the only farm run was RX_VK_SUBMIT_WORKER=0 with an invalid (fade-in) timing. The game-free test is strong, but it cannot catch a driver's real submit behaviour, a device lost, or a stalled close.

Default / evidence (strongest finding). RX_VK_SUBMIT_WORKER is kill, env_on_or(..., 1): unset means on, not off. The PR's own Measurements says "RX_VK_SUBMIT_WORKER ships on (its default, unset); no measurement chose that default yet", and Testing says "It has NOT run in the game on this PC yet." The Test Farm's kokiri-start run was taken with RX_VK_SUBMIT_WORKER=0 and its timing was inside the fade-in, so it exercises the off path only. The checklist's "ships at the default the measurements chose" and "measured against main" boxes are unticked. A perf change whose Risks include "a wrong picture or a device lost", "one never sent (a hang)", and a close delay should be RX_VK_SUBMIT_WORKER=0 (or an attempt switch) until the on/off/#1995 A/B exists; the game-free test does not substitute for one real queue.

Queue ownership and synchronization. The design looks sound: every vkQueueSubmit2(dev.queue, ...) is under dev.present_mu. The worker's queue_flush_locked takes std::lock_guard qk(dev.present_mu); the replaying thread's flushes (queue_flush_for, queue_flush_poll, the cap/reflex split, queue_flush, device_wait_idle_locked) hold it; the present's copy submit is under the qk taken in present_image_with_trial; part_submit takes it, and the worker is off with the recorder thread. So two threads cannot submit the same queue concurrently. The lock order is consistent: the kick holds present_mu and takes submit_worker.mu; the worker holds w.mu only while waiting, releases it before taking present_mu, and the stop takes w.mu only. No inversion. sw_reason_ns is written under present_mu and the stats line at present_image_with_trial holds the same lock; sw_submit_ns/sw_submits are atomics; t_submit_worker is thread-local. The worker's replay_fatal path (_Exit(3), no present_mu) does not deadlock.

Batching condition. batch_on() is (on || submit_worker_on()) && batch_tl != VK_NULL_HANDLE: the worker reuses the batch hold, the cap, batch_gpu_idle, the timeline (batch_tl) and the Reflex split. It is off with RADV/GCN, RX_VK_BATCH set, the device policy's batched submits, the recorder thread, RX_VK_GPU_TIMELINE, RX_VK_BENCH or no batch_tl, and the log names which. The held submit is appended under present_mu, pend_held is released, the kick wakes the worker, and the worker sends it in hold order. reflex_split_wanted flushes another game frame's batch first (FR_REFLEX). This matches the PR's description.

Fallback. A std::thread that throws std::system_error is caught; submit_worker_started stays false, so batch_on() is false on NVIDIA and every submit is made by the replaying thread, with nothing held. The test injects the error and covers it.

Test. I ran python -I -B tests/test_submit_worker.py --cxx clang++ on 6c7991cb: PASS, 4 lines / 20 cases — wake/order, own counter vs PROF_QSUBMIT, Reflex split, start failure, the off matrix, stop/join and a post-stop kick, a refused/lost held batch, polls and zero-budget waits, and the switch read in fresh processes (unset, empty, 0, 1, 2, off, no). It also checks the wiring in submit_recording, replay_start and the close. What it cannot cover: a real driver's vkQueueSubmit2, a device lost, a stalled submit during close, and the in-game picture. Those are all in Still to test.

Threading / lifetime hazards to tighten:

  • The close calls submit_worker_stop() and ignores its bool. The 2 s stop is followed by the close's 5 s present_mu try-lock; if the worker is stuck in vkQueueSubmit2, the close gives up, logs "the swapchain goes with the process", and the held submits are not sent. The Risks' "the close waiting for the thread (2 s at most)" understates the close (2 s + 5 s), and the skipped retire means the held batch is not flushed. If the host then destroys the device while the worker is still in vkQueueSubmit2, that is a lifetime hazard; today the comment says the process ends next, so it is bounded, but the bool should be used and the worker's driver call should be known not to outlive the device.
  • submit_worker_started is never cleared by submit_worker_stop(). After the stop, batch_on() remains true and the replaying thread keeps the hold/try-lock path (submit_worker_kick() returns false), not the direct submit. It is harmless while the process is closing, but the state is not reset, and the present line keeps printing the worker's counters.
  • submit_worker_start() is not idempotent: a second replay_start in one process would assign to a joinable std::thread and call std::terminate. started_up()/start() is once per process today; if a renderer restart can call it twice, guard it.
  • The finite-budget queue_flush_for path (a zero-timeout wait included) returns with the budget unreduced when the queue's lock is busy and leaves the held submit to the worker. That is the intended L10, but the caller must treat "not ready" as possible while a held submit is queued; the test covers the path, not a real driver's timing.

What remains. The in-game A/B (on, =0, and #1995) on Windows/Linux/AMD/Intel, the close-while-playing run, and the RADV off-log check; the PR is WIP/draft and not mergeable, with the #1995/#1994 commits still in its diff. The head is 6c7991cb on #1995's 9e640b66; this review is the submit-worker commit only.

No approval, no claim.

**The switch ships on, but the on path has never run in the game: not on this PC, and the only farm run was `RX_VK_SUBMIT_WORKER=0` with an invalid (fade-in) timing. The game-free test is strong, but it cannot catch a driver's real submit behaviour, a device lost, or a stalled close.** **Default / evidence (strongest finding).** `RX_VK_SUBMIT_WORKER` is `kill`, `env_on_or(..., 1)`: unset means **on**, not off. The PR's own Measurements says "`RX_VK_SUBMIT_WORKER` ships on (its default, unset); no measurement chose that default yet", and Testing says "It has NOT run in the game on this PC yet." The Test Farm's kokiri-start run was taken with `RX_VK_SUBMIT_WORKER=0` and its timing was inside the fade-in, so it exercises the **off** path only. The checklist's "ships at the default the measurements chose" and "measured against main" boxes are unticked. A perf change whose Risks include "a wrong picture or a device lost", "one never sent (a hang)", and a close delay should be `RX_VK_SUBMIT_WORKER=0` (or an `attempt` switch) until the on/off/#1995 A/B exists; the game-free test does not substitute for one real queue. **Queue ownership and synchronization.** The design looks sound: every `vkQueueSubmit2(dev.queue, ...)` is under `dev.present_mu`. The worker's `queue_flush_locked` takes `std::lock_guard qk(dev.present_mu)`; the replaying thread's flushes (`queue_flush_for`, `queue_flush_poll`, the cap/reflex split, `queue_flush`, `device_wait_idle_locked`) hold it; the present's copy submit is under the `qk` taken in `present_image_with_trial`; `part_submit` takes it, and the worker is off with the recorder thread. So **two threads cannot submit the same queue concurrently**. The lock order is consistent: the kick holds `present_mu` and takes `submit_worker.mu`; the worker holds `w.mu` only while waiting, releases it before taking `present_mu`, and the stop takes `w.mu` only. No inversion. `sw_reason_ns` is written under `present_mu` and the stats line at `present_image_with_trial` holds the same lock; `sw_submit_ns`/`sw_submits` are atomics; `t_submit_worker` is thread-local. The worker's `replay_fatal` path (`_Exit(3)`, no `present_mu`) does not deadlock. **Batching condition.** `batch_on()` is `(on || submit_worker_on()) && batch_tl != VK_NULL_HANDLE`: the worker reuses the batch hold, the cap, `batch_gpu_idle`, the timeline (`batch_tl`) and the Reflex split. It is off with RADV/GCN, `RX_VK_BATCH` set, the device policy's batched submits, the recorder thread, `RX_VK_GPU_TIMELINE`, `RX_VK_BENCH` or no `batch_tl`, and the log names which. The held submit is appended under `present_mu`, `pend_held` is released, the kick wakes the worker, and the worker sends it in hold order. `reflex_split_wanted` flushes another game frame's batch first (FR_REFLEX). This matches the PR's description. **Fallback.** A `std::thread` that throws `std::system_error` is caught; `submit_worker_started` stays false, so `batch_on()` is false on NVIDIA and every submit is made by the replaying thread, with nothing held. The test injects the error and covers it. **Test.** I ran `python -I -B tests/test_submit_worker.py --cxx clang++` on `6c7991cb`: **PASS**, 4 lines / 20 cases — wake/order, own counter vs `PROF_QSUBMIT`, Reflex split, start failure, the off matrix, stop/join and a post-stop kick, a refused/lost held batch, polls and zero-budget waits, and the switch read in fresh processes (unset, empty, 0, 1, 2, off, no). It also checks the wiring in `submit_recording`, `replay_start` and the close. What it cannot cover: a real driver's `vkQueueSubmit2`, a device lost, a stalled submit during close, and the in-game picture. Those are all in Still to test. **Threading / lifetime hazards to tighten:** - The close calls `submit_worker_stop()` and **ignores its bool**. The 2 s stop is followed by the close's 5 s `present_mu` try-lock; if the worker is stuck in `vkQueueSubmit2`, the close gives up, logs "the swapchain goes with the process", and the held submits are not sent. The Risks' "the close waiting for the thread (2 s at most)" understates the close (2 s + 5 s), and the skipped retire means the held batch is not flushed. If the host then destroys the device while the worker is still in `vkQueueSubmit2`, that is a lifetime hazard; today the comment says the process ends next, so it is bounded, but the bool should be used and the worker's driver call should be known not to outlive the device. - `submit_worker_started` is never cleared by `submit_worker_stop()`. After the stop, `batch_on()` remains true and the replaying thread keeps the hold/try-lock path (`submit_worker_kick()` returns false), not the direct submit. It is harmless while the process is closing, but the state is not reset, and the present line keeps printing the worker's counters. - `submit_worker_start()` is not idempotent: a second `replay_start` in one process would assign to a joinable `std::thread` and call `std::terminate`. `started_up()`/`start()` is once per process today; if a renderer restart can call it twice, guard it. - The finite-budget `queue_flush_for` path (a zero-timeout wait included) returns with the budget unreduced when the queue's lock is busy and leaves the held submit to the worker. That is the intended L10, but the caller must treat "not ready" as possible while a held submit is queued; the test covers the path, not a real driver's timing. **What remains.** The in-game A/B (on, `=0`, and #1995) on Windows/Linux/AMD/Intel, the close-while-playing run, and the RADV off-log check; the PR is WIP/draft and not mergeable, with the #1995/#1994 commits still in its diff. The head is `6c7991cb` on #1995's `9e640b66`; this review is the submit-worker commit only. No approval, no claim.
dazemc's review of #2156 (72747), the lifetime points. Fail at 6c7991cb:
- stop-resets: after a stop that joined the thread, submit_worker_on() and batch_on() stay true, so the replaying thread
  keeps holding its submits for a worker that is gone;
- start-twice: a second submit_worker_start() assigns a std::thread to a joinable one (std::terminate);
- the close calls submit_worker_stop() and does not look at what it says: with the worker still in a driver call it goes
  on to the queue's lock and the swapchain's retire.
Pass there already, kept as guards: stop-stuck (a worker stuck in vkQueueSubmit2: the stop gives up after 2 s, says
false, and the worker is still counted on), and the back end never calls vkDestroyDevice (a worker's driver call cannot
outlive the device: it lives until the process ends).

Assisted-by: Claude Code
dazemc's review of #2156 (72747), points 2a-2c:
- submit_worker_stop() clears submit_worker_started once the thread is joined: batch_on() and the kick say no worker, so
  the replaying thread submits directly again (what is still held goes with the next flush), and the present's line stops
  printing the worker's counts. A stop that timed out leaves it set: the thread is still there.
- submit_worker_start() runs once a process: asked again it logs and starts nothing (a second std::thread assigned over a
  joinable one ended the process with std::terminate), nor after a stop.
- the close looks at what the stop says: a worker still in a driver submit (or waiting for the queue's lock behind one)
  makes the close let nothing go, as a present still running does, at once instead of after the queue lock's 5 s. The
  device is never destroyed by the back end (no vkDestroyDevice call), so that driver call cannot outlive it.

Assisted-by: Claude Code
fix(vk): RX_VK_SUBMIT_WORKER off until measured in play (attempt)
Some checks are pending
CI / Website build and checks (pull_request) Blocked by required conditions
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Description follows the template (pull_request_target) Successful in 7s
dfe6b9c56d
dazemc's review of #2156 (72747), point 1: the on path has never run in the game, and the only farm run was =0. The
switch is an attempt now: unset, empty or 0 is #1995's path (every submit made by the thread that replays it); 1 turns
the submit thread on. Its row, the reader, the log line, docs/dev/reference/threads.md and the test (unset and =0 off;
every other case sets =1) say so.

Assisted-by: Claude Code
Member

Beanstalk test farm

Commit dfe6b9c · approved by nobody yet · dashboard

A member of BigBeans can review this commit and comment @Beanstalk to test it.

<!-- beanstalk:sticky --> ### Beanstalk test farm Commit `dfe6b9c` · approved by nobody yet · [dashboard](https://beanstalk.magicbean.dev/prs/2156) A member of `BigBeans` can review this commit and comment `@Beanstalk` to test it.
siantm changed title from WIP: perf(vk): a submit thread sends the submits the replay holds where nothing else batches them (RX_VK_SUBMIT_WORKER) to WIP: perf(vk): a submit thread sends the submits the replay holds where nothing else batches them (RX_VK_SUBMIT_WORKER, off) 2026-11-22 10:45:53 +00:00
Author
Contributor

@dazemc thank you for the review (72747), and for running the test. I pushed 5825c6e0, 3312f165 and dfe6b9c5 on top of 6c7991cb. They sit on #1995's 9e640b66 as before. This push does not rebase the stack: #1995 and #1994 conflict with current main in vk_replay.cpp, and their farm requests and runtimes are on their current heads, so the three are rebased together at #1995's next push. The description and the title are updated.

  1. Default. dfe6b9c5: RX_VK_SUBMIT_WORKER is now an attempt row and ships off. Unset or 0 is #1995's path, and 1 turns the submit thread on. The A/B (unset against =1, with Threaded rendering off) is in Still to test.

  2. Lifetime. The tests for (a) to (c) are 5825c6e0; it fails at 6c7991cb (stop-resets, start-twice and the close's wiring) and passes after the fix in 3312f165.

    • (a) The close. It now uses what submit_worker_stop() returns. If the thread has not stopped after 2 s, it is in a driver submit or waiting for the queue's lock behind one. The close then lets nothing go and returns at once, as it already does when a present is still running, so there is no further 5 s wait on the queue's lock. The driver call cannot outlive the device because the back end never destroys the device: there is no vkDestroyDevice call in gpu/vk, and the device goes with the process. The test checks the close's give-up branch, checks that no gpu/vk/*.cpp calls vkDestroyDevice, and covers a worker stuck in vkQueueSubmit2: the stop gives up after 2 s, returns false, and the worker is still counted as there (stop-stuck). Risks now says this instead of "2 s at most".

    • (b) The stop clears submit_worker_started once the thread is joined. batch_on() and the kick then say there is no worker, the replaying thread submits directly again, and the present line stops printing the worker's counts. A stop that timed out leaves it set, since the thread is still there (stop-resets).

    • (c) submit_worker_start() now runs once per process. Asked again, or after a stop, it logs and starts nothing. Today replay_start runs once, so this is a guard (start-twice).

    • (d) I checked the callers and made no change. The finite-budget callers are the capture's write-back wait (250 ms), the fence wait (the game's timeout, its zero-time poll loop included), and readback_wait_value (RX_VK_READBACK_WAIT_MS, 250 ms). Each then waits on the driver with what is left of its budget, and each already handles a timeout:

      • the capture logs it and reads memory as it is;
      • the fence wait returns not-signalled to the game;
      • the readback returns false, and the CPU reads memory as on a timeout.

      A busy lock leaves the held submit to the worker, which was woken when the submit was held and sends it as soon as the lock is free, so the driver wait that follows can still see it finish within the budget.

Testing is in the description. tests/test_present_semaphores.py compiles the close from its dev.closing line on, so its fixture now declares the close's new worker_stopped (as stopped). At the head it passes, along with the other checks that read the close. Of the checks that read the changed files, 33 fail, and each fails on #1995's 9e640b66 too. The two changed sources compile with the game build's command. It has not run in the game yet.

@dazemc thank you for the review (72747), and for running the test. I pushed 5825c6e0, 3312f165 and dfe6b9c5 on top of 6c7991cb. They sit on #1995's 9e640b66 as before. This push does not rebase the stack: #1995 and #1994 conflict with current main in `vk_replay.cpp`, and their farm requests and runtimes are on their current heads, so the three are rebased together at #1995's next push. The description and the title are updated. 1. **Default.** dfe6b9c5: `RX_VK_SUBMIT_WORKER` is now an `attempt` row and ships off. Unset or `0` is #1995's path, and `1` turns the submit thread on. The A/B (unset against `=1`, with Threaded rendering off) is in Still to test. 2. **Lifetime.** The tests for (a) to (c) are 5825c6e0; it fails at 6c7991cb (`stop-resets`, `start-twice` and the close's wiring) and passes after the fix in 3312f165. - **(a) The close.** It now uses what `submit_worker_stop()` returns. If the thread has not stopped after 2 s, it is in a driver submit or waiting for the queue's lock behind one. The close then lets nothing go and returns at once, as it already does when a present is still running, so there is no further 5 s wait on the queue's lock. The driver call cannot outlive the device because the back end never destroys the device: there is no `vkDestroyDevice` call in `gpu/vk`, and the device goes with the process. The test checks the close's give-up branch, checks that no `gpu/vk/*.cpp` calls `vkDestroyDevice`, and covers a worker stuck in `vkQueueSubmit2`: the stop gives up after 2 s, returns false, and the worker is still counted as there (`stop-stuck`). Risks now says this instead of "2 s at most". - **(b)** The stop clears `submit_worker_started` once the thread is joined. `batch_on()` and the kick then say there is no worker, the replaying thread submits directly again, and the present line stops printing the worker's counts. A stop that timed out leaves it set, since the thread is still there (`stop-resets`). - **(c)** `submit_worker_start()` now runs once per process. Asked again, or after a stop, it logs and starts nothing. Today `replay_start` runs once, so this is a guard (`start-twice`). - **(d)** I checked the callers and made no change. The finite-budget callers are the capture's write-back wait (250 ms), the fence wait (the game's timeout, its zero-time poll loop included), and `readback_wait_value` (`RX_VK_READBACK_WAIT_MS`, 250 ms). Each then waits on the driver with what is left of its budget, and each already handles a timeout: - the capture logs it and reads memory as it is; - the fence wait returns not-signalled to the game; - the readback returns false, and the CPU reads memory as on a timeout. A busy lock leaves the held submit to the worker, which was woken when the submit was held and sends it as soon as the lock is free, so the driver wait that follows can still see it finish within the budget. Testing is in the description. `tests/test_present_semaphores.py` compiles the close from its `dev.closing` line on, so its fixture now declares the close's new `worker_stopped` (as stopped). At the head it passes, along with the other checks that read the close. Of the checks that read the changed files, 33 fail, and each fails on #1995's 9e640b66 too. The two changed sources compile with the game build's command. It has not run in the game yet.
Author
Contributor

@Beanstalk This replaces my request 71056, made for the earlier head 6c7991cb, where the switch was on by default. This adds RX_VK_SUBMIT_WORKER, an attempt off by default: with RX_VK_SUBMIT_WORKER=1 the Vulkan replay's submits go to a thread of their own when the replay runs on the submitting thread, that is with Threaded rendering off (gpu/vk); never on RADV; unset, it is #1995's path. It sits on #1995 (9e640b66, itself on #1994), so its diff against its merge base includes those PRs' commits; the farm cannot take them as the comparison, so please compare with main. Please start from the kokiri-start save and take the picture 5 s (300 frames at 60 fps) after the first frame whose picture is not a single uniform colour, with no input in between (a picture during the load's fade-in from black is not comparable), with a main-against-itself picture on the same PC from the same point; then, for frame times only, play Kokiri Forest and Hyrule Field, two minutes each; at least two starts a side, interleaved, the PR against main on the same PC, on the PR's side unset (the default, off) and with RX_VK_SUBMIT_WORKER=1 (on), on Windows with an RX 9060 XT, Windows with an RTX 4070, Windows with an Arc B580 and Linux with an RTX 3080 Ti (not RADV, which this change leaves out). The worker only acts with Threaded rendering off, so please set RX_VK_ASYNC=0 (the switch behind the Threaded rendering row) on every side, main's included. The same picture as main within main's own difference from itself; unset, frame time p99 equal to main's; with RX_VK_SUBMIT_WORKER=1, equal to unset or better, within the run-to-run spread. The log must have no FATAL, device lost or validation error line. With RX_VK_SUBMIT_WORKER=1 the log must have the submit thread's line every 120 presents, and unset none. The game must close promptly at the end of each run.

@Beanstalk This replaces my request 71056, made for the earlier head 6c7991cb, where the switch was on by default. This adds RX_VK_SUBMIT_WORKER, an attempt off by default: with RX_VK_SUBMIT_WORKER=1 the Vulkan replay's submits go to a thread of their own when the replay runs on the submitting thread, that is with Threaded rendering off (gpu/vk); never on RADV; unset, it is #1995's path. It sits on #1995 (9e640b66, itself on #1994), so its diff against its merge base includes those PRs' commits; the farm cannot take them as the comparison, so please compare with main. Please start from the kokiri-start save and take the picture 5 s (300 frames at 60 fps) after the first frame whose picture is not a single uniform colour, with no input in between (a picture during the load's fade-in from black is not comparable), with a main-against-itself picture on the same PC from the same point; then, for frame times only, play Kokiri Forest and Hyrule Field, two minutes each; at least two starts a side, interleaved, the PR against main on the same PC, on the PR's side unset (the default, off) and with RX_VK_SUBMIT_WORKER=1 (on), on Windows with an RX 9060 XT, Windows with an RTX 4070, Windows with an Arc B580 and Linux with an RTX 3080 Ti (not RADV, which this change leaves out). The worker only acts with Threaded rendering off, so please set RX_VK_ASYNC=0 (the switch behind the Threaded rendering row) on every side, main's included. The same picture as main within main's own difference from itself; unset, frame time p99 equal to main's; with RX_VK_SUBMIT_WORKER=1, equal to unset or better, within the run-to-run spread. The log must have no FATAL, device lost or validation error line. With RX_VK_SUBMIT_WORKER=1 the log must have the submit thread's line every 120 presents, and unset none. The game must close promptly at the end of each run.
Member

@siantm only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@siantm only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
Author
Contributor

@Beanstalk One more correction to my request 72820 above: RX_VK_ASYNC=0 alone is only half of Threaded rendering off; the recorder thread follows the row separately. Wherever I asked for RX_VK_ASYNC=0, please set RX_VK_RECORDER=off with it, on every side, main's included: the two together are what the Threaded rendering row's Off sets, and this change does not run with the recorder thread on.

@Beanstalk One more correction to my request 72820 above: RX_VK_ASYNC=0 alone is only half of Threaded rendering off; the recorder thread follows the row separately. Wherever I asked for RX_VK_ASYNC=0, please set RX_VK_RECORDER=off with it, on every side, main's included: the two together are what the Threaded rendering row's Off sets, and this change does not run with the recorder thread on.
Member

@siantm only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@siantm only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
Author
Contributor

@Beanstalk This replaces my request 72820 on this head and the corrections under it, in a form the farm can run: it cannot time a picture from the first frame that is not a uniform colour (its answer on #2131), so each picture here follows a fixed wait after the map event. This adds RX_VK_SUBMIT_WORKER, an attempt off by default: with RX_VK_SUBMIT_WORKER=1 the Vulkan replay's submits go to a thread of their own when the replay runs on the submitting thread, that is with Threaded rendering off (gpu/vk); never on RADV; unset, it is #1995's path. It sits on #1995 (9e640b66, itself on #1994), so its diff against its merge base includes those PRs' commits; the farm cannot take them as the comparison, so please compare with main. Please start from the kokiri-start save and take the picture 10 s (600 frames at 60 fps) after the map event that ends the load, a fixed wait with no input in between (the farm cannot time it from the first frame that is not a uniform colour), with a main-against-itself picture on the same PC from the same point; then, for frame times only, play Kokiri Forest and Hyrule Field, two minutes each; at least two starts a side, interleaved, the PR against main on the same PC, on the PR's side unset (the default, off) and with RX_VK_SUBMIT_WORKER=1 (on), on Windows with an RX 9060 XT, Windows with an RTX 4070, Windows with an Arc B580 and Linux with an RTX 3080 Ti (not RADV, which this change leaves out). The worker only acts with Threaded rendering off, so please set RX_VK_ASYNC=0 and RX_VK_RECORDER=off (together, the Threaded rendering row's Off) on every side, main's included. The same picture as main within main's own difference from itself; unset, frame time p99 equal to main's; with RX_VK_SUBMIT_WORKER=1, equal to unset or better, within the run-to-run spread. The log must have no FATAL, device lost or validation error line. With RX_VK_SUBMIT_WORKER=1 the log must have the submit thread's line every 120 presents, and unset none. The game must close promptly at the end of each run.

@Beanstalk This replaces my request 72820 on this head and the corrections under it, in a form the farm can run: it cannot time a picture from the first frame that is not a uniform colour (its answer on #2131), so each picture here follows a fixed wait after the map event. This adds RX_VK_SUBMIT_WORKER, an attempt off by default: with RX_VK_SUBMIT_WORKER=1 the Vulkan replay's submits go to a thread of their own when the replay runs on the submitting thread, that is with Threaded rendering off (gpu/vk); never on RADV; unset, it is #1995's path. It sits on #1995 (9e640b66, itself on #1994), so its diff against its merge base includes those PRs' commits; the farm cannot take them as the comparison, so please compare with main. Please start from the kokiri-start save and take the picture 10 s (600 frames at 60 fps) after the map event that ends the load, a fixed wait with no input in between (the farm cannot time it from the first frame that is not a uniform colour), with a main-against-itself picture on the same PC from the same point; then, for frame times only, play Kokiri Forest and Hyrule Field, two minutes each; at least two starts a side, interleaved, the PR against main on the same PC, on the PR's side unset (the default, off) and with RX_VK_SUBMIT_WORKER=1 (on), on Windows with an RX 9060 XT, Windows with an RTX 4070, Windows with an Arc B580 and Linux with an RTX 3080 Ti (not RADV, which this change leaves out). The worker only acts with Threaded rendering off, so please set RX_VK_ASYNC=0 and RX_VK_RECORDER=off (together, the Threaded rendering row's Off) on every side, main's included. The same picture as main within main's own difference from itself; unset, frame time p99 equal to main's; with RX_VK_SUBMIT_WORKER=1, equal to unset or better, within the run-to-run spread. The log must have no FATAL, device lost or validation error line. With RX_VK_SUBMIT_WORKER=1 the log must have the submit thread's line every 120 presents, and unset none. The game must close promptly at the end of each run.
Member

@siantm only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@siantm only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
Author
Contributor

@dazemc the on/off A/B your review asked for has run (Measurements, "In play"): this head on #1995's, Threaded rendering off, Kokiri Forest CPU-paced at an 800x600 output, unset against RX_VK_SUBMIT_WORKER=1 in one runtime, 8 runs a side, and the Market one a side. On a real driver here (RTX 4060, Windows), the on path ran in every =1 run: about 11 submits a frame made by the submit thread, 0.60 ms a frame of vkQueueSubmit2 there, the replaying thread's own queue submit down from 0.53 to 0.00 ms; no device lost, FATAL or Vulkan error, and every run closed by itself with exit code 0 (no close gave up on the queue).

What it does to the frame: the replay's submit time fell 3.5 % (p = 0.009), but the game's own code on that thread took 7 % longer (p = 0.0002), and the median frame was level (p = 0.55). So it ships off, as you asked, and this gives no reason to turn it on. Not covered yet: the picture against main and Hyrule Field (Still to test).

@dazemc the on/off A/B your review asked for has run (Measurements, "In play"): this head on #1995's, Threaded rendering off, Kokiri Forest CPU-paced at an 800x600 output, unset against `RX_VK_SUBMIT_WORKER=1` in one runtime, 8 runs a side, and the Market one a side. On a real driver here (RTX 4060, Windows), the on path ran in every `=1` run: about 11 submits a frame made by the submit thread, 0.60 ms a frame of `vkQueueSubmit2` there, the replaying thread's own queue submit down from 0.53 to 0.00 ms; no device lost, FATAL or Vulkan error, and every run closed by itself with exit code 0 (no close gave up on the queue). What it does to the frame: the replay's submit time fell 3.5 % (p = 0.009), but the game's own code on that thread took 7 % longer (p = 0.0002), and the median frame was level (p = 0.55). So it ships off, as you asked, and this gives no reason to turn it on. Not covered yet: the picture against main and Hyrule Field (Still to test).
Contributor

@siantm thank you — that answers the point the review raised (72747): the on path has now run in the game, on a real driver.

At dfe6b9c5, one runtime with Threaded rendering off (RX_VK_ASYNC=0, RX_VK_RECORDER=off), 8 runs a side plus a Market pair, the =1 runs show the outcome the review asked about: the submit thread made the queue submits (about 11 a frame, 0.60 ms a frame of vkQueueSubmit2 there) and the replaying thread's own submit went from 0.53 to 0.00 ms. The driver's submits are off the replaying thread, not just moved in a counter. The runs are at this PR's head (dfe6b9c5 on #1995's 9e640b66), so the A/B is at the current head, not an older one. No device lost, FATAL or Vulkan error, and every run closed by itself with exit code 0 (no close gave up on the queue), which covers the clean-exit and driver-call side for this path. Shipping it off as an attempt, with no claim to turn it on, is what those numbers support.

Not settled by this run, and separate from this point: the picture against main, Hyrule Field, the close-while-playing run and the RADV off-log check remain in Still to test, as do the other hardware targets.

@siantm thank you — that answers the point the review raised (72747): the on path has now run in the game, on a real driver. At dfe6b9c5, one runtime with Threaded rendering off (`RX_VK_ASYNC=0`, `RX_VK_RECORDER=off`), 8 runs a side plus a Market pair, the `=1` runs show the outcome the review asked about: the submit thread made the queue submits (about 11 a frame, 0.60 ms a frame of `vkQueueSubmit2` there) and the replaying thread's own submit went from 0.53 to 0.00 ms. The driver's submits are off the replaying thread, not just moved in a counter. The runs are at this PR's head (dfe6b9c5 on #1995's 9e640b66), so the A/B is at the current head, not an older one. No device lost, FATAL or Vulkan error, and every run closed by itself with exit code 0 (no close gave up on the queue), which covers the clean-exit and driver-call side for this path. Shipping it off as an attempt, with no claim to turn it on, is what those numbers support. Not settled by this run, and separate from this point: the picture against main, Hyrule Field, the close-while-playing run and the RADV off-log check remain in Still to test, as do the other hardware targets.
Author
Contributor

@dazemc thank you. The picture against main, Hyrule Field, the close-while-playing run, the RADV off-log check and the other hardware stay in Still to test.

@dazemc thank you. The picture against main, Hyrule Field, the close-while-playing run, the RADV off-log check and the other hardware stay in Still to test.
Some checks are pending
CI / Website build and checks (pull_request) Blocked by required conditions
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Description follows the template (pull_request_target) Successful in 7s
This pull request has changes conflicting with the target branch.
  • docs/dev/reference/threads.md
  • gpu/vk/switches.def
  • gpu/vk/vk_replay.cpp
Some workflows are waiting to be reviewed.
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'perf/vk-submit-worker:siantm-perf/vk-submit-worker'
git switch 'siantm-perf/vk-submit-worker'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2156
No description provided.