WIP: perf(vk): three per-draw cuts of the replay thread, measured together, each behind its own switch #3328

Draft
klimovich008 wants to merge 7 commits from klimovich008/Longshot:perf/replay-stack into main
Member

Summary

Three small cuts of the replay's CPU time per draw. Each one is about 1 % of a frame or less. Alone, that is below what
the in-game A/B can see: std_test asks for 6 pairs under a 5 % difference, and one cut's share is lost in the noise. So
they are measured together here. Each keeps its own switch, on by default; each =0 restores main's path, and the
replay bench shows the three of them at =0 recording the same commands as main at the same speed.

  1. RX_VK_PUSH_WORDS_BULK (gpu/vk/draw_key.h words_store_all, gpu/vk/vk_draw.cpp pushed_words_store).
    bind_descriptors_lean remembers a full descriptor push as 64-bit words, so the next draws of the program push only
    the writes that changed. words_append grew that vector one out-of-line push_back per word: ~19,000 calls a frame
    at Market center (~720 full pushes of ~27 words). words_store_all counts a push's words, sizes the words and the
    write offsets once and fills them; a buffer's three words are its VkDescriptorBufferInfo, copied whole
    (static_asserted). The words are the same, bit for bit. =check builds both and compares them.
  2. RX_VK_SPAN_HEAT_PLAIN (gpu/vk/ubo_ssbo_fast.h add_read_span_heat). A hit in the per-thread read spans
    (fast_read_bind's uniform and storage buffer lookups) added its pool's heat with a locked fetch_add. The lock
    prefix waits for the replay thread's earlier stores to drain. It is now a relaxed load and store. The heat is the
    mirrors' estimate of how much a pool is read (mirrors_by_heat), decayed by a quarter every 16 submissions. An add
    made at the same moment on another thread may now be lost, which that estimate absorbs.
  3. RX_VK_RECORDER_RETIRED (gpu/vk/vk_recorder.h rec::Retired, rec::ring_mark, rec::retired_on;
    gpu/vk/vk_texture.cpp pool_put, pool_take_memory; gpu/vk/vk_replay.cpp do_present).
    • pool_take_memory binds a new render target to a pooled image's memory, then destroys the pooled image and its
      views. Every vkDestroy* is a recorder boundary, so the render thread waited for the recorder to drain the ring.
      At Market center that is ~430–660 waits and 95–140 ms per 10 s.
    • Every packet that names a render target is written while it is alive, before it goes into the pool. pool_put
      now keeps the ring's position (rec::ring_mark). rec::Retired(mark), a scope around those two destroys only,
      lets them go to the driver without the wait once the recorder has run past that position.
    • do_present keeps its source image (the headless blit, the window's own) to the present's value and past what
      texture_frame's sweep reads as done. The sweep then cannot pool it, and give its memory to a new target, while
      the present still reads it.

Read first: words_store_all and pushed_words_store; add_read_span_heat; rec::Retired / ring_mark /
retired_on, then their two callers in vk_texture.cpp and the do_present hunk.

Testing

Tested: Windows 11, AMD Radeon RX 9070 XT (driver 32.0.32029.2010), Ryzen 7 5700X3D. In the game at Market center
(the fountain save), the camera turning, Threaded rendering on (the render and recorder threads). Two A/Bs of three
interleaved pairs each, the stack at its defaults against all three switches =0, in one runtime (Measurements).
Every counted run loaded the save and played its measured window at the game's own speed (0.999–1.001). Then the same spot with Khronos validation and synchronization validation, the stack against its
control: on a runtime built from this PR's head (b8238c35d), each run playing 90 s after the load. Both runs show the same
three error kinds and no synchronization hazard:

Validation errors After, defaults: this PR @ b8238c35d Before, the three switches =0: this PR @ b8238c35d
VUID-VkImageCreateInfo-imageCreateMaxMipLevels-02251 503 502
VUID-vkGetQueryPoolResults-None-09401 40 40
VUID-RuntimeSpirv-OpTypeCooperativeMatrixKHR-10163 1 1
SYNC-HAZARD-* 0 0

Every 02251 error is a BC5 or BC6H texture created with storage usage, from the texture upload path. By format, the
counts differ in both directions (BC5 SNORM 2 against 5, BC5 UNORM 492 against 488, BC6H 9 and 9), so the one extra
follows from which textures each run streamed in. None of the three changes creates an image or picks a format.

Checks (claude-perf/with_lock.sh, light):

  • tests/test_push_words_bulk.py (new) runs words_store_all with vk_draw.cpp's own Pushed,
    push_words_bulk_check and pushed_words_store (srccut) against the words_append reference:
    • a hand-written push;
    • 20,000 randomized pushes over leftover words: buffers, images, texel views, every mix of the three info pointers,
      zero-count writes with pointers set, counts 0–40, up to 80 writes;
    • modes 0, 1 and =check flipped between pushes; the same modes over a deliberately broken words_store_all
      (=0 and =check must keep words_append's words, =check must count each difference);
    • push_words_bulk_begin_recording with and without a HOS_AB host;
    • 13 broken variants that must fail through a check (a crash does not count).
  • tests/test_span_heat_plain.py (new) compiles the real ubo_ssbo_fast.h: one random trace through a table with
    the plain add and one with the locked add must leave every pool the same heat, equal to the heat counted beside
    them. On x86-64 the plain lookup's assembly must hold no lock-prefixed instruction and the locked one's must. Five
    broken variants must fail.
  • tests/test_recorder_parts.py (retired cases, tests/recorder_parts_test.cpp):
    • a mark before a held packet lets the destroys reach the driver ahead of it;
    • a mark after it waits, as do =0, destroys outside the scope and a buffer's inside it;
    • a mark over a packet written and not yet published waits;
    • Retired with no producer (the recorder off) skips nothing;
    • a source check of the scope's exact text, pool_put's mark, retired_on, and do_present's source kept
      before the sweep, with broken variants and controls for each;
    • a source check that mode_init stores the switch, then publishes the mode once with release, and that mode()
      returns what it read with acquire. 8 broken variants must fail: a relaxed publish, a relaxed read, a relaxed losing
      mode_init, the switch stored after the publish, a relaxed store over it, a second publish, mode() reading again
      relaxed, and a relaxed store of the mode elsewhere.
  • tests/test_hos_ab.py: RX_VK_PUSH_WORDS_BULK and RX_VK_SPAN_HEAT_PLAIN are WIRED (read at each recording's
    start). RX_VK_RECORDER_RETIRED is read once, at the recorder's mode_init, like RX_VK_RECORDER_PARTS, so it is
    not: the test requires WIRED to be exactly the ab_value readers.
  • Fixtures updated for the new names, not weakened: draw_stream_visibility_test.cpp, fsr_uniform_ownership_test.cpp,
    recording_admission_test.cpp, test_target_reuse_memory.py, test_upscale_independent.py,
    test_vk_draw_overhead_lean.py.
  • tests/run_all.py: on this branch on 6c06d9810, 876 passed, 14 failed, 68 skipped (since then main added two website commits only). The same 14 fail on main 6c06d9810: test_astc_decoder_gpu.py, test_device_lost_exit.py, test_fps_stats.py, test_helpers_extract.py, test_longshot_builder.py, test_lost_wait_said.py, test_parity_gates.py, test_present_acquire_ahead.py, test_present_device_loss.py, test_present_probe.py, test_present_probe_retirement.py, test_present_thread.py, test_queue_priority.py, test_submit_oom.py.
  • A second-opinion review of the whole diff (gpt-6.2-sol) found one defect in the stack. Two threads' mode_init could
    store g_retired at once, and a thread could read it before the store reached it. b8238c35d makes g_retired an
    atomic, false until mode_init stores the switch. A review of that commit found the rest: the mode was published
    relaxed, so do_present could see the recorder thread's mode and still read the switch's initial false, not keep
    its source, and a later Retired could let that image's destroys go while the present's blit was in the ring.
    3e27a4e24 publishes the mode with release and reads it in mode() with acquire. A review of that commit found its
    source check too loose: it passed with the switch stored after the publish, or a relaxed store over it. 45b99719e
    checks the order, the one publish and mode()'s whole body. That review also found that two threads in
    mode_init at once race on its plain settings (g_own, g_idle_wait and others). That is main's own; this
    PR's g_retired is an atomic and widens nothing.
    • Two findings are main's own, and this PR leaves them as they were or narrower: a frame generation pass reading the
      present's source after the present's value is done, and the headless output effects' use of a Texture that
      retire_finish may erase in the same sweep. On main too the destroys wait only for the recorder, not for the GPU.
      Here the source's last_value is kept later, and the sweep reads an earlier value.
    • One is by design: HOS_AB cannot flip RX_VK_RECORDER_RETIRED. It is read once, at the recorder's start.
  • Replay bench (Longshot #3268's game-free bench, synthetic scenes through the real replay): the Vulkan census of the
    stack at its defaults, and with every switch =0, records the same commands and picture as main in every scene.

Still to test:

  • NVIDIA on Windows: Market center with Threaded rendering on, the defaults against RX_VK_PUSH_WORDS_BULK=0 RX_VK_SPAN_HEAT_PLAIN=0 RX_VK_RECORDER_RETIRED=0. Expecting the same picture and no loss (@Beanstalk).
  • Linux, RADV (Steam Deck): the same, expecting the same (@Beanstalk).

Measurements

Verdict: about 2 % more fps and 0.8 ms less CPU a frame at Market center, the three measured together. Of 5 valid pairs over two A/Bs, 4 favour the stack and one is flat. std_test labels it "diagnostic": a difference under 5 % needs 6 pairs.

Setup: Windows 11, RX 9070 XT (driver 32.0.32029.2010), Ryzen 7 5700X3D. claude-perf/std_test.py: Market center,
16:9 at 2048x1152 (graphics scale 1), uncapped, the camera turning, 20 s measured after the load, a GPU co-load
holding the clock. Threaded rendering on. One runtime (What was measured, below): After = defaults, Before = the
three switches =0. Order ABBAAB, 3 pairs a run. CPU ms is the whole process's CPU time per frame.

Baseline: this PR's own build with its three switches =0, which restores main's paths, against the same build at its defaults, in one runtime. The switches turn off the three changes and nothing else, so the A/B holds everything else the same. Before = =0, After = defaults; both columns are 9d282c355, main f359e2621 with this PR's first four commits (What was measured).

What was measured. The in-game A/Bs and the recorder-wait counts used one runtime: main f359e2621 (2026-12-04) plus
this PR's first four commits, before the g_retired fix. That fix changes no generated code on x86-64: a relaxed atomic
bool's load and store are plain moves. The replay bench used 554d1229b on main 2d87a5c9a. The branch is now rebased onto
7a014436f without conflicts. The validation runs used a runtime built from b8238c35d. The two commits since change only the memory order of the recorder's mode publish and read (3e27a4e24: the same x86-64 instructions) and a test (45b99719e). main's commits since f359e2621
don't touch the target pool, do_present's sweep, the descriptor push or the span table. In the recorder they added
vmaDestroyPool as a boundary call. #3159 made Threaded rendering's Auto run the recorder thread at any core count,
which widens where RX_VK_RECORDER_RETIRED applies.

A/B 1, stack1205a (2026-12-05, 22:10–22:18 UTC). GPU 3,246–3,279 MHz in every run.

Pair Before, =0, fps: this PR @ 9d282c355 After, defaults, fps: this PR @ 9d282c355 Δ fps Before, =0, CPU ms: this PR @ 9d282c355 After, defaults, CPU ms: this PR @ 9d282c355 Δ CPU
0 91.74 95.14 +3.7 % 56.70 55.48 −1.22 ms
1 94.24 95.99 +1.9 % 56.53 54.87 −1.66 ms
2 93.49 95.99 +2.7 % 55.67 55.71 +0.04 ms
Median 93.49 95.99 +2.7 % 56.53 55.48 −1.05 ms

A/B 2, stack1205c (2026-12-06, 07:35–07:42 UTC). GPU 3,253–3,281 MHz in every run.

Pair Before, =0, fps: this PR @ 9d282c355 After, defaults, fps: this PR @ 9d282c355 Δ fps Before, =0, CPU ms: this PR @ 9d282c355 After, defaults, CPU ms: this PR @ 9d282c355 Δ CPU
0 95.34 95.24 −0.1 % 55.04 54.82 −0.21 ms
1 (96.49) rejected (54.32) rejected
2 94.64 97.39 +2.9 % 54.77 54.26 −0.50 ms

Pair 1 was rejected by std_test's own rule, not by choice. Its stack run had a 0.55 s frame inside the measured window, 15.7 s
after the load. The frame's present returned at once, so the time went to the game's own work. That run alone also had two
long frames before the load (332 and 278 ms); no other run of either arm did. std_test runs exactly 3 pairs and replaces none.

Void: stack1205b (2026-12-06, 06:44–06:53 UTC), not counted. The GPU clock was 2,908–3,162 MHz against ~3,270 in the
two A/Bs above. Windows Update's servicing and Defender used about 1.4 cores throughout, and one minute of outside disk load
(06:47–06:48 UTC) hit pair 0. Its medians were 75.54 fps (stack) against 74.09 (off).

The 5 valid pairs together:

Before, =0: this PR @ 9d282c355 After, defaults: this PR @ 9d282c355 Δ
fps, median 94.24 95.99 +1.9 %
CPU ms per frame, median 55.67 54.87 −0.80 ms
fps by pair +3.7, +1.9, +2.7, −0.1, +2.9 %

Four of the five pairs favour the stack. One is flat: stack1205c pair 0, −0.1 %. std_test labels both A/Bs
"diagnostic": a difference under 5 % needs 6 pairs for its admission, and each A/B has 3.

RX_VK_RECORDER_RETIRED in the same runs. The recorder's stats line counts how often the render thread waited for it.
These are the last two 10 s lines of each run, the measured window:

Off (9 runs: a, b and c) Stack (9 runs)
The render thread's waits for the recorder, per 10 s 408–662 0–87
Time in those waits, per 10 s 76–139 ms 0–5 ms

Per change, on the replay bench (Longshot #3268's game-free bench: synthetic scenes through the real replay, 7 runs a side, fastest frames;
the Vulkan census compares what each side records). Each row: the stack's DLL at its defaults against that one switch
=0, so each row is what turning that change off costs:

Change turned off Scene µs a frame Per draw Census
RX_VK_PUSH_WORDS_BULK=0 draws (2,000) +221 +0.110 µs (+9.1 %) the same commands and picture
RX_VK_PUSH_WORDS_BULK=0 mixed (2,000 + 150 dispatches) +134 +0.062 µs (+4.7 %) the same
RX_VK_SPAN_HEAT_PLAIN=0 draws +162 +0.081 µs (+6.5 %) the same
RX_VK_SPAN_HEAT_PLAIN=0 mixed +164 +0.076 µs (+5.9 %) the same
RX_VK_RECORDER_RETIRED=0 draws, render and recorder threads +18 +0.009 µs (+0.9 %) the same
  • RX_VK_RECORDER_RETIRED's bench row is within the bench's noise. Its waits in the game come from new render targets
    taking pooled targets' memory by size, a path this bench does not measure. Its measure is the recorder's own count in
    the game, above: 408–662 waits per 10 s off, 0–87 on.
  • The shares are each measured against the other changes on. They do not add up to the whole stack.
  • The whole stack against main 2d87a5c9a, same bench, fastest frames:
    • draws: −317 µs a frame (−11.3 %);
    • mixed: −306 µs (−10.0 %);
    • dispatches (no draws): +1.9 %, against a ~2.4 % run-to-run spread in that scene.
    • The stack with all three switches =0 against main: draws −0.2 %, mixed +0.2 %, dispatches +5.5 %.
    • The dispatches scene runs none of the three changes, and at =0 the build runs main's paths. So neither dispatches
      number is a change's cost: it is the difference between the two DLL builds in that scene, larger at =0 than at
      the defaults.
    • The census was the same as main's in every scene, at the defaults and at =0.

Risks

  • RX_VK_PUSH_WORDS_BULK: a wrong word makes the next draw of the program skip a write that changed, or push one
    that did not. The randomized check and =check compare it with words_append bit for bit.
  • RX_VK_SPAN_HEAT_PLAIN: a lost heat add moves the mirrors' estimate slightly, never a binding.
  • RX_VK_RECORDER_RETIRED: a destroy let go too early would free an image the recorder has yet to name. The mark is
    taken when the image is pooled, after every packet naming it was written. The scope covers those two destroys only,
    and do_present keeps the present's source out of the sweep's pool until the present is done.
  • Each switch =0 turns its change off: main's path. Nothing changes for a player after updating: no files, no
    vk_api.h change, no shader-cache stamp file (vk_shader.cpp, vk_bank.cpp, vk_state.h).

What each change leaves out:

  • RX_VK_PUSH_WORDS_BULK: only bind_descriptors_lean's full push. The delta pushes (words_same_store_lean) and the
    legacy bind_descriptors (RX_VK_DRAW_OVERHEAD_LEAN=0) are unchanged.
  • RX_VK_SPAN_HEAT_PLAIN: only a hit in the per-thread span table (ReadSpanTable::lookup's two ways). Every other
    heat add keeps its locked add.
  • RX_VK_RECORDER_RETIRED: only pool_take_memory's destroys of the pooled image and its views. Every other destroy
    waits as before. It does nothing without the recorder thread (Threaded rendering off, RX_VK_RECORDER not thread,
    or a broken ring). do_present's change applies only while it is active.

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.

🤖 Generated with Claude Code

## Summary Three small cuts of the replay's CPU time per draw. Each one is about 1 % of a frame or less. Alone, that is below what the in-game A/B can see: std_test asks for 6 pairs under a 5 % difference, and one cut's share is lost in the noise. So they are measured together here. Each keeps its own switch, on by default; each `=0` restores `main`'s path, and the replay bench shows the three of them at `=0` recording the same commands as `main` at the same speed. 1. **`RX_VK_PUSH_WORDS_BULK`** (`gpu/vk/draw_key.h` `words_store_all`, `gpu/vk/vk_draw.cpp` `pushed_words_store`). `bind_descriptors_lean` remembers a full descriptor push as 64-bit words, so the next draws of the program push only the writes that changed. `words_append` grew that vector one out-of-line `push_back` per word: ~19,000 calls a frame at Market center (~720 full pushes of ~27 words). `words_store_all` counts a push's words, sizes the words and the write offsets once and fills them; a buffer's three words are its `VkDescriptorBufferInfo`, copied whole (static_asserted). The words are the same, bit for bit. `=check` builds both and compares them. 2. **`RX_VK_SPAN_HEAT_PLAIN`** (`gpu/vk/ubo_ssbo_fast.h` `add_read_span_heat`). A hit in the per-thread read spans (`fast_read_bind`'s uniform and storage buffer lookups) added its pool's heat with a locked `fetch_add`. The lock prefix waits for the replay thread's earlier stores to drain. It is now a relaxed load and store. The heat is the mirrors' estimate of how much a pool is read (`mirrors_by_heat`), decayed by a quarter every 16 submissions. An add made at the same moment on another thread may now be lost, which that estimate absorbs. 3. **`RX_VK_RECORDER_RETIRED`** (`gpu/vk/vk_recorder.h` `rec::Retired`, `rec::ring_mark`, `rec::retired_on`; `gpu/vk/vk_texture.cpp` `pool_put`, `pool_take_memory`; `gpu/vk/vk_replay.cpp` `do_present`). - `pool_take_memory` binds a new render target to a pooled image's memory, then destroys the pooled image and its views. Every `vkDestroy*` is a recorder boundary, so the render thread waited for the recorder to drain the ring. At Market center that is ~430–660 waits and 95–140 ms per 10 s. - Every packet that names a render target is written while it is alive, before it goes into the pool. `pool_put` now keeps the ring's position (`rec::ring_mark`). `rec::Retired(mark)`, a scope around those two destroys only, lets them go to the driver without the wait once the recorder has run past that position. - `do_present` keeps its source image (the headless blit, the window's own) to the present's value and past what `texture_frame`'s sweep reads as done. The sweep then cannot pool it, and give its memory to a new target, while the present still reads it. Read first: `words_store_all` and `pushed_words_store`; `add_read_span_heat`; `rec::Retired` / `ring_mark` / `retired_on`, then their two callers in `vk_texture.cpp` and the `do_present` hunk. ## Testing **Tested:** Windows 11, AMD Radeon RX 9070 XT (driver 32.0.32029.2010), Ryzen 7 5700X3D. In the game at Market center (the fountain save), the camera turning, Threaded rendering on (the render and recorder threads). Two A/Bs of three interleaved pairs each, the stack at its defaults against all three switches `=0`, in one runtime (Measurements). Every counted run loaded the save and played its measured window at the game's own speed (0.999–1.001). Then the same spot with Khronos validation and synchronization validation, the stack against its control: on a runtime built from this PR's head (b8238c35d), each run playing 90 s after the load. Both runs show the same three error kinds and no synchronization hazard: | Validation errors | After, defaults: this PR @ b8238c35d | Before, the three switches `=0`: this PR @ b8238c35d | |---|---|---| | `VUID-VkImageCreateInfo-imageCreateMaxMipLevels-02251` | 503 | 502 | | `VUID-vkGetQueryPoolResults-None-09401` | 40 | 40 | | `VUID-RuntimeSpirv-OpTypeCooperativeMatrixKHR-10163` | 1 | 1 | | `SYNC-HAZARD-*` | 0 | 0 | Every `02251` error is a BC5 or BC6H texture created with storage usage, from the texture upload path. By format, the counts differ in both directions (BC5 SNORM 2 against 5, BC5 UNORM 492 against 488, BC6H 9 and 9), so the one extra follows from which textures each run streamed in. None of the three changes creates an image or picks a format. Checks (`claude-perf/with_lock.sh`, light): - `tests/test_push_words_bulk.py` (new) runs `words_store_all` with `vk_draw.cpp`'s own `Pushed`, `push_words_bulk_check` and `pushed_words_store` (srccut) against the `words_append` reference: - a hand-written push; - 20,000 randomized pushes over leftover words: buffers, images, texel views, every mix of the three info pointers, zero-count writes with pointers set, counts 0–40, up to 80 writes; - modes 0, 1 and `=check` flipped between pushes; the same modes over a deliberately broken `words_store_all` (`=0` and `=check` must keep `words_append`'s words, `=check` must count each difference); - `push_words_bulk_begin_recording` with and without a HOS_AB host; - 13 broken variants that must fail through a check (a crash does not count). - `tests/test_span_heat_plain.py` (new) compiles the real `ubo_ssbo_fast.h`: one random trace through a table with the plain add and one with the locked add must leave every pool the same heat, equal to the heat counted beside them. On x86-64 the plain lookup's assembly must hold no lock-prefixed instruction and the locked one's must. Five broken variants must fail. - `tests/test_recorder_parts.py` (retired cases, `tests/recorder_parts_test.cpp`): - a mark before a held packet lets the destroys reach the driver ahead of it; - a mark after it waits, as do `=0`, destroys outside the scope and a buffer's inside it; - a mark over a packet written and not yet published waits; - `Retired` with no producer (the recorder off) skips nothing; - a source check of the scope's exact text, `pool_put`'s mark, `retired_on`, and `do_present`'s source kept before the sweep, with broken variants and controls for each; - a source check that `mode_init` stores the switch, then publishes the mode once with release, and that `mode()` returns what it read with acquire. 8 broken variants must fail: a relaxed publish, a relaxed read, a relaxed losing `mode_init`, the switch stored after the publish, a relaxed store over it, a second publish, `mode()` reading again relaxed, and a relaxed store of the mode elsewhere. - `tests/test_hos_ab.py`: `RX_VK_PUSH_WORDS_BULK` and `RX_VK_SPAN_HEAT_PLAIN` are WIRED (read at each recording's start). `RX_VK_RECORDER_RETIRED` is read once, at the recorder's `mode_init`, like `RX_VK_RECORDER_PARTS`, so it is not: the test requires WIRED to be exactly the `ab_value` readers. - Fixtures updated for the new names, not weakened: `draw_stream_visibility_test.cpp`, `fsr_uniform_ownership_test.cpp`, `recording_admission_test.cpp`, `test_target_reuse_memory.py`, `test_upscale_independent.py`, `test_vk_draw_overhead_lean.py`. - `tests/run_all.py`: on this branch on 6c06d9810, 876 passed, 14 failed, 68 skipped (since then `main` added two website commits only). The same 14 fail on `main` 6c06d9810: `test_astc_decoder_gpu.py`, `test_device_lost_exit.py`, `test_fps_stats.py`, `test_helpers_extract.py`, `test_longshot_builder.py`, `test_lost_wait_said.py`, `test_parity_gates.py`, `test_present_acquire_ahead.py`, `test_present_device_loss.py`, `test_present_probe.py`, `test_present_probe_retirement.py`, `test_present_thread.py`, `test_queue_priority.py`, `test_submit_oom.py`. - A second-opinion review of the whole diff (gpt-6.2-sol) found one defect in the stack. Two threads' `mode_init` could store `g_retired` at once, and a thread could read it before the store reached it. b8238c35d makes `g_retired` an atomic, false until `mode_init` stores the switch. A review of that commit found the rest: the mode was published relaxed, so `do_present` could see the recorder thread's mode and still read the switch's initial false, not keep its source, and a later `Retired` could let that image's destroys go while the present's blit was in the ring. 3e27a4e24 publishes the mode with release and reads it in `mode()` with acquire. A review of that commit found its source check too loose: it passed with the switch stored after the publish, or a relaxed store over it. 45b99719e checks the order, the one publish and `mode()`'s whole body. That review also found that two threads in `mode_init` at once race on its plain settings (`g_own`, `g_idle_wait` and others). That is `main`'s own; this PR's `g_retired` is an atomic and widens nothing. - Two findings are `main`'s own, and this PR leaves them as they were or narrower: a frame generation pass reading the present's source after the present's value is done, and the headless output effects' use of a `Texture` that `retire_finish` may erase in the same sweep. On `main` too the destroys wait only for the recorder, not for the GPU. Here the source's `last_value` is kept later, and the sweep reads an earlier value. - One is by design: HOS_AB cannot flip `RX_VK_RECORDER_RETIRED`. It is read once, at the recorder's start. - Replay bench (Longshot #3268's game-free bench, synthetic scenes through the real replay): the Vulkan census of the stack at its defaults, and with every switch `=0`, records the same commands and picture as `main` in every scene. **Still to test:** - NVIDIA on Windows: Market center with Threaded rendering on, the defaults against `RX_VK_PUSH_WORDS_BULK=0 RX_VK_SPAN_HEAT_PLAIN=0 RX_VK_RECORDER_RETIRED=0`. Expecting the same picture and no loss (@Beanstalk). - Linux, RADV (Steam Deck): the same, expecting the same (@Beanstalk). ## Measurements **Verdict:** about 2 % more fps and 0.8 ms less CPU a frame at Market center, the three measured together. Of 5 valid pairs over two A/Bs, 4 favour the stack and one is flat. std_test labels it "diagnostic": a difference under 5 % needs 6 pairs. Setup: Windows 11, RX 9070 XT (driver 32.0.32029.2010), Ryzen 7 5700X3D. `claude-perf/std_test.py`: Market center, 16:9 at 2048x1152 (graphics scale 1), uncapped, the camera turning, 20 s measured after the load, a GPU co-load holding the clock. Threaded rendering on. One runtime (What was measured, below): After = defaults, Before = the three switches `=0`. Order ABBAAB, 3 pairs a run. CPU ms is the whole process's CPU time per frame. **Baseline:** this PR's own build with its three switches `=0`, which restores `main`'s paths, against the same build at its defaults, in one runtime. The switches turn off the three changes and nothing else, so the A/B holds everything else the same. Before = `=0`, After = defaults; both columns are 9d282c355, `main` f359e2621 with this PR's first four commits (What was measured). **What was measured.** The in-game A/Bs and the recorder-wait counts used one runtime: `main` f359e2621 (2026-12-04) plus this PR's first four commits, before the `g_retired` fix. That fix changes no generated code on x86-64: a relaxed atomic bool's load and store are plain moves. The replay bench used 554d1229b on `main` 2d87a5c9a. The branch is now rebased onto 7a014436f without conflicts. The validation runs used a runtime built from b8238c35d. The two commits since change only the memory order of the recorder's mode publish and read (3e27a4e24: the same x86-64 instructions) and a test (45b99719e). `main`'s commits since f359e2621 don't touch the target pool, do_present's sweep, the descriptor push or the span table. In the recorder they added `vmaDestroyPool` as a boundary call. #3159 made Threaded rendering's Auto run the recorder thread at any core count, which widens where `RX_VK_RECORDER_RETIRED` applies. **A/B 1, `stack1205a`** (2026-12-05, 22:10–22:18 UTC). GPU 3,246–3,279 MHz in every run. | Pair | Before, `=0`, fps: this PR @ 9d282c355 | After, defaults, fps: this PR @ 9d282c355 | Δ fps | Before, `=0`, CPU ms: this PR @ 9d282c355 | After, defaults, CPU ms: this PR @ 9d282c355 | Δ CPU | |---|---|---|---|---|---|---| | 0 | 91.74 | 95.14 | +3.7 % | 56.70 | 55.48 | −1.22 ms | | 1 | 94.24 | 95.99 | +1.9 % | 56.53 | 54.87 | −1.66 ms | | 2 | 93.49 | 95.99 | +2.7 % | 55.67 | 55.71 | +0.04 ms | | Median | 93.49 | 95.99 | +2.7 % | 56.53 | 55.48 | −1.05 ms | **A/B 2, `stack1205c`** (2026-12-06, 07:35–07:42 UTC). GPU 3,253–3,281 MHz in every run. | Pair | Before, `=0`, fps: this PR @ 9d282c355 | After, defaults, fps: this PR @ 9d282c355 | Δ fps | Before, `=0`, CPU ms: this PR @ 9d282c355 | After, defaults, CPU ms: this PR @ 9d282c355 | Δ CPU | |---|---|---|---|---|---|---| | 0 | 95.34 | 95.24 | −0.1 % | 55.04 | 54.82 | −0.21 ms | | 1 | (96.49) | rejected | | (54.32) | rejected | | | 2 | 94.64 | 97.39 | +2.9 % | 54.77 | 54.26 | −0.50 ms | Pair 1 was rejected by std_test's own rule, not by choice. Its stack run had a 0.55 s frame inside the measured window, 15.7 s after the load. The frame's present returned at once, so the time went to the game's own work. That run alone also had two long frames before the load (332 and 278 ms); no other run of either arm did. std_test runs exactly 3 pairs and replaces none. **Void: `stack1205b`** (2026-12-06, 06:44–06:53 UTC), not counted. The GPU clock was 2,908–3,162 MHz against ~3,270 in the two A/Bs above. Windows Update's servicing and Defender used about 1.4 cores throughout, and one minute of outside disk load (06:47–06:48 UTC) hit pair 0. Its medians were 75.54 fps (stack) against 74.09 (off). **The 5 valid pairs together:** | | Before, `=0`: this PR @ 9d282c355 | After, defaults: this PR @ 9d282c355 | Δ | |---|---|---|---| | fps, median | 94.24 | 95.99 | +1.9 % | | CPU ms per frame, median | 55.67 | 54.87 | −0.80 ms | | fps by pair | | | +3.7, +1.9, +2.7, −0.1, +2.9 % | Four of the five pairs favour the stack. One is flat: `stack1205c` pair 0, −0.1 %. std_test labels both A/Bs "diagnostic": a difference under 5 % needs 6 pairs for its admission, and each A/B has 3. **`RX_VK_RECORDER_RETIRED` in the same runs.** The recorder's stats line counts how often the render thread waited for it. These are the last two 10 s lines of each run, the measured window: | | Off (9 runs: a, b and c) | Stack (9 runs) | |---|---|---| | The render thread's waits for the recorder, per 10 s | 408–662 | 0–87 | | Time in those waits, per 10 s | 76–139 ms | 0–5 ms | **Per change, on the replay bench** (Longshot #3268's game-free bench: synthetic scenes through the real replay, 7 runs a side, fastest frames; the Vulkan census compares what each side records). Each row: the stack's DLL at its defaults against that one switch `=0`, so each row is what turning that change off costs: | Change turned off | Scene | µs a frame | Per draw | Census | |---|---|---|---|---| | `RX_VK_PUSH_WORDS_BULK=0` | draws (2,000) | +221 | +0.110 µs (+9.1 %) | the same commands and picture | | `RX_VK_PUSH_WORDS_BULK=0` | mixed (2,000 + 150 dispatches) | +134 | +0.062 µs (+4.7 %) | the same | | `RX_VK_SPAN_HEAT_PLAIN=0` | draws | +162 | +0.081 µs (+6.5 %) | the same | | `RX_VK_SPAN_HEAT_PLAIN=0` | mixed | +164 | +0.076 µs (+5.9 %) | the same | | `RX_VK_RECORDER_RETIRED=0` | draws, render and recorder threads | +18 | +0.009 µs (+0.9 %) | the same | - `RX_VK_RECORDER_RETIRED`'s bench row is within the bench's noise. Its waits in the game come from new render targets taking pooled targets' memory by size, a path this bench does not measure. Its measure is the recorder's own count in the game, above: 408–662 waits per 10 s off, 0–87 on. - The shares are each measured against the other changes on. They do not add up to the whole stack. - The whole stack against `main` 2d87a5c9a, same bench, fastest frames: - draws: −317 µs a frame (−11.3 %); - mixed: −306 µs (−10.0 %); - dispatches (no draws): +1.9 %, against a ~2.4 % run-to-run spread in that scene. - The stack with all three switches `=0` against `main`: draws −0.2 %, mixed +0.2 %, dispatches +5.5 %. - The dispatches scene runs none of the three changes, and at `=0` the build runs `main`'s paths. So neither dispatches number is a change's cost: it is the difference between the two DLL builds in that scene, larger at `=0` than at the defaults. - The census was the same as `main`'s in every scene, at the defaults and at `=0`. ## Risks - `RX_VK_PUSH_WORDS_BULK`: a wrong word makes the next draw of the program skip a write that changed, or push one that did not. The randomized check and `=check` compare it with `words_append` bit for bit. - `RX_VK_SPAN_HEAT_PLAIN`: a lost heat add moves the mirrors' estimate slightly, never a binding. - `RX_VK_RECORDER_RETIRED`: a destroy let go too early would free an image the recorder has yet to name. The mark is taken when the image is pooled, after every packet naming it was written. The scope covers those two destroys only, and `do_present` keeps the present's source out of the sweep's pool until the present is done. - Each switch `=0` turns its change off: `main`'s path. Nothing changes for a player after updating: no files, no `vk_api.h` change, no shader-cache stamp file (`vk_shader.cpp`, `vk_bank.cpp`, `vk_state.h`). What each change leaves out: - `RX_VK_PUSH_WORDS_BULK`: only `bind_descriptors_lean`'s full push. The delta pushes (`words_same_store_lean`) and the legacy `bind_descriptors` (`RX_VK_DRAW_OVERHEAD_LEAN=0`) are unchanged. - `RX_VK_SPAN_HEAT_PLAIN`: only a hit in the per-thread span table (`ReadSpanTable::lookup`'s two ways). Every other heat add keeps its locked add. - `RX_VK_RECORDER_RETIRED`: only `pool_take_memory`'s destroys of the pooled image and its views. Every other destroy waits as before. It does nothing without the recorder thread (Threaded rendering off, `RX_VK_RECORDER` not `thread`, or a broken ring). `do_present`'s change applies only while it is active. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). - [x] 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 - [x] 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. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
bind_descriptors_lean remembers a full push's descriptors as words, so the next draws of the program push only the
writes that changed. words_append grew that vector one push_back at a time, out of line: ~19,000 calls a frame at
Market center (~720 full pushes of ~27 words). words_store_all (draw_key.h) counts the words, sizes the vector and
the write offsets once, and fills them: a buffer's three words are its VkDescriptorBufferInfo, copied whole.

RX_VK_PUSH_WORDS_BULK: on (1) by default; =0 grows them as before; =check does both and logs any difference.
HOS_AB may flip it between recordings. tests/test_push_words_bulk.py runs the real functions against words_append
over randomized pushes, with broken variants that must fail, and times both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
From the sol review of the first commit:
- the three fixtures that compile draw_begin_recording() declare push_words_bulk_begin_recording()
- test_push_words_bulk.py builds again with words_store_all broken on purpose: =0 and =check must keep
  words_append's words and =check must count each difference, so a mode that takes the wrong path fails
- push_words_bulk_begin_recording is compiled against a fake HOS_AB host (its value used, clamped)
- the generated writes take every mix of the three info pointers, and zero-count writes with pointers set
- a broken variant counts as caught only through a failed check, not a crash
- handles cast so the harness builds on 32-bit too
- the switch's row says what =check logs: the first 20 differences and the counts every 100,000 checks

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every hit of the per-thread read spans (tl_read_span_table: the uniform and storage buffers' lookups in
fast_read_bind) added the pool's heat with a locked fetch_add. The lock prefix waits for the replay
thread's earlier stores to drain: on the replay bench (synthetic draws through the real replay) a plain
add instead made a draw 0.06 us cheaper with the uniform buffer hits alone, 1.124 -> 1.063 us (best of
7 runs; a plain relaxed load and store measured the same as no add at all).

The heat is the mirrors' estimate of how much a pool is read (mirrors_by_heat): an add made at the same
moment on another thread may now be lost, which a heuristic that decays by a quarter every 16
submissions takes in its stride.

RX_VK_SPAN_HEAT_PLAIN=0 restores the locked add; HOS_AB flips it between recordings.

tests/test_span_heat_plain.py compiles the real ubo_ssbo_fast.h: one random trace through a table with
the plain add and one with the locked add must leave every pool the same heat, equal to the heat
counted beside them; on x86-64 the plain lookup's assembly must hold no lock-prefixed instruction and
the locked one's must. Five broken variants must fail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
pool_take_memory binds a new render target to a pooled image's memory, then destroys the pooled image and its views.
Each vkDestroy* is a recorder boundary, so the render thread waited for the recorder to drain the ring: about 670-870
waits and 140-170 ms per 10 s in the Market (the recorder's stats line), 0.15-0.19 ms a frame of the replay thread's
time.

Every packet that names a render target is written while it is alive, before it goes into the pool. pool_put now keeps
the ring's position then (rec::ring_mark), and rec::Retired(mark), a scope around those two destroys only, lets them go
to the driver without the wait once the recorder has run past it: no packet in the ring can name them. This does not
rest on the image's last_value (a frame generation pass recorded after the present samples the present's source in a
recording of its own). do_present names its source's image after texture_frame's sweep (the headless blit, the window's
own): with Retired on (rec::retired_on: the recorder thread, the switch on, its ring not broken) it now keeps the
source, before the sweep, to the present's value and past what the sweep reads as done (last_value; a held present runs
after later values are done, its own among them), so the sweep cannot pool it, or give its memory back, ahead of them; a
source the sweep let go headless could be pooled with its blit still to come, and its memory taken again while the GPU
could still read it (on main too). Not past the mark, not the producer, or RX_VK_RECORDER_RETIRED=0: the destroys wait
as before, and with =0, no recorder thread or a broken one (no ring or no thread: every call made directly) do_present
is main's: no source kept, the sweep reading completed() at its call.

Tests: tests/test_recorder_parts.py's retired cases (with the mark before a held packet the destroys reach the driver
ahead of it; with the mark after it, a packet written before the image was pooled still in the ring, they wait; =0,
destroys outside the scope (an image's and a view's) and a buffer's inside it wait; RX_VK_RECORDER_PARTS=0 too; the
switch as mode_init reads it from the environment) and a source check of the scope's exact text, its mark and
pool_put's, with broken variants that must fail (the mark or the switch ignored or not read, every destroy counted, the
scope widened, moved or given no mark, pool_put without the mark). A mark taken over a packet written and not yet
published waits too (ring_mark is the write position, not the published one), and Retired on a thread with no producer
(the recorder off) reads and skips nothing, each with a broken variant (the mark the published position; the producer
read when there is none). tests/test_target_reuse_memory.py's pool fixture declares the rec:: names pool_put and
pool_take_memory use. The source check also needs do_present's source kept to the present's value and past the sweep's
reading before the one sweep, which reads that same value, with controls (the keep taken out, kept to the present's
value only, the sweep reading completed() again, the keep or the early reading with the switch off too), and
rec::retired_on's exact text, with a case of its own (on; off with =0 or the recorder broken; broken variants ignoring
either). tests/test_upscale_independent.py finds the sweep by its new call. Each retired case makes its call once the
recorder is held inside the packet, so a recorder that publishes its position past a packet before running it fails
retired_unrun (a broken variant), and the unread-mark cases destroy a view as well as the image (a recorder letting
views through whenever the switch is on fails, and one letting every view through without the hand-off by part fails
retired_drain); pool_put's mark must be taken right after the image's node is made (controls: kept in the size-class
branch only, under an if, past an early return).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(vk): RX_VK_RECORDER_RETIRED's switch an atomic, off until mode_init reads it
Some checks failed
beanstalk/approval can't be tested as asked: see the farm's comment
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
b8238c35df
From the sol review of the stack: two threads' mode_init (the startup painter's first recorded command and the replay's
first replay_mu) could store the plain bool g_retired at once, and a thread that read the mode another thread set could
read the switch before that store reached it. g_retired is now a std::atomic<bool>, stored and loaded relaxed, and false
until mode_init stores the switch: a thread that reads it early waits for the recorder, as with =0.

tests/recorder_parts_test.cpp sets it for every case (each env case starts from the value it must not end with);
tests/test_recorder_parts.py checks the declaration, and its controls follow the new text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Member

Tested in game: Windows 11, AMD Radeon RX 9070 XT (driver 32.0.32029.2010), Ryzen 7 5700X3D: Market center (the fountain save), camera turning, Threaded rendering on. Two std_test A/Bs of 3 interleaved pairs, the stack at its defaults against RX_VK_PUSH_WORDS_BULK=0 RX_VK_SPAN_HEAT_PLAIN=0 RX_VK_RECORDER_RETIRED=0 in one runtime: 5 valid pairs (one rejected by std_test), medians 95.99 vs 94.24 fps (+1.9 %) and 54.87 vs 55.67 CPU ms a frame; 4 pairs for the stack, one flat (-0.1 %); std_test: diagnostic. The render thread's waits for the recorder: 0-87 per 10 s with the stack, 408-662 without. Every counted run played its window at the game's speed. Validation (Khronos + sync) on the PR head's runtime: pending.

Tested in game: Windows 11, AMD Radeon RX 9070 XT (driver 32.0.32029.2010), Ryzen 7 5700X3D: Market center (the fountain save), camera turning, Threaded rendering on. Two std_test A/Bs of 3 interleaved pairs, the stack at its defaults against RX_VK_PUSH_WORDS_BULK=0 RX_VK_SPAN_HEAT_PLAIN=0 RX_VK_RECORDER_RETIRED=0 in one runtime: 5 valid pairs (one rejected by std_test), medians 95.99 vs 94.24 fps (+1.9 %) and 54.87 vs 55.67 CPU ms a frame; 4 pairs for the stack, one flat (-0.1 %); std_test: diagnostic. The render thread's waits for the recorder: 0-87 per 10 s with the stack, 408-662 without. Every counted run played its window at the game's speed. Validation (Khronos + sync) on the PR head's runtime: pending.
Member

Possibly related, for context:

  • PR #3304 WIP: perf(vk): a whole push's words made in one pass, into vectors sized once — Overlapping descriptor word bulk-build implementation; same code path and fix
  • issue #1925 Game: Stutter in Market - Caused by - Replay thread saturated in Castle Town market with NPCs (~8 ms of 16.7) — Open report of Market stutter attributed to replay-thread CPU saturation
Possibly related, for context: - PR #3304 WIP: perf(vk): a whole push's words made in one pass, into vectors sized once — Overlapping descriptor word bulk-build implementation; same code path and fix - issue #1925 Game: Stutter in Market - Caused by - Replay thread saturated in Castle Town market with NPCs (~8 ms of 16.7) — Open report of Market stutter attributed to replay-thread CPU saturation
Author
Member

@Beanstalk measure this PR's three switches together on Windows with NVIDIA and on the Steam Deck. They are CPU cuts on the replay's render and recorder threads, so the question is whether they also help, or at least don't hurt, off this author's AMD PC.

  • In the PR's own build: its defaults against RX_VK_PUSH_WORDS_BULK=0 RX_VK_SPAN_HEAT_PLAIN=0 RX_VK_RECORDER_RETIRED=0, all three set together on one side (main's paths). A [[pass.compare]] on average frame time, 3 runs a side, interleaved.
  • Market center at the fountain (Market_Child), the camera turning, 30 s measured after the load, Threaded rendering on.
  • Uncapped: frame_rate_cap = 6, vsync = 2, frame_generation = 0, windowed.
  • Keep run_hitch_count and run_frametime_max_ms report-only.
  • Take a picture at the fountain on each side and compare them: they should match.
  • From each side's log, report the recorder's stats lines, "the render thread (the replay lock's holder) waited for it N times". With the defaults, the count should be far lower.
@Beanstalk measure this PR's three switches together on Windows with NVIDIA and on the Steam Deck. They are CPU cuts on the replay's render and recorder threads, so the question is whether they also help, or at least don't hurt, off this author's AMD PC. - In the PR's own build: its defaults against `RX_VK_PUSH_WORDS_BULK=0 RX_VK_SPAN_HEAT_PLAIN=0 RX_VK_RECORDER_RETIRED=0`, all three set together on one side (main's paths). A `[[pass.compare]]` on average frame time, 3 runs a side, interleaved. - Market center at the fountain (Market_Child), the camera turning, 30 s measured after the load, Threaded rendering on. - Uncapped: `frame_rate_cap = 6`, `vsync = 2`, `frame_generation = 0`, windowed. - Keep `run_hitch_count` and `run_frametime_max_ms` report-only. - Take a picture at the fountain on each side and compare them: they should match. - From each side's log, report the recorder's stats lines, "the render thread (the replay lock's holder) waited for it N times". With the defaults, the count should be far lower.
Member

Beanstalk test farm

Commit 45b9971 · 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 `45b9971` · approved by nobody yet · [dashboard](https://beanstalk.magicbean.dev/prs/3328) A member of `BigBeans` can review this commit and comment `@Beanstalk` to test it.
fix(vk): the recorder's mode published with release, read with acquire
Some checks failed
beanstalk/approval not approved yet
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
3e27a4e243
mode_init stores RX_VK_RECORDER_RETIRED's g_retired (and the recorder's other switches) and then publishes the mode, both
relaxed. A thread that read the mode as THREAD could still read g_retired's initial false: do_present then would not
keep its source past the sweep's reading, the sweep could pool it with a ring mark taken before the present's blit, and
a later Retired, reading the switch on, could let that image's destroys go while the blit was still in the ring.

The compare-exchange that publishes the mode is now release (acquire when another thread published it first), and
mode() reads it with acquire, so a thread that sees THREAD through mode() sees the switches stored before it. On
x86-64 these are the same instructions as before. tests/test_recorder_parts.py checks both orders, with broken
variants that must fail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
test(vk): the recorder mode's order checked whole: the switch stored before the one publish
Some checks are pending
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
CI / What the change needs (pull_request) Waiting to run
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Waiting to run
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Waiting to run
beanstalk/approval not approved yet
45b99719e0
A review of the release/acquire commit found its source check too loose: it passed with RX_VK_RECORDER_RETIRED's store
moved after mode_init's publish, or a relaxed store of the mode over it, and either brings the race back.

The check now cuts mode_init and set_mode: the switch is stored before the compare-exchange that publishes the mode,
mode_init touches the mode nowhere else, mode() returns what it read with acquire or mode_init's result, and the only
other write of the mode in the file is set_mode's (the checks'). 8 broken variants must fail: a relaxed publish, a relaxed
read, a relaxed losing mode_init, the switch stored after the publish, a relaxed store over it, a second publish, mode()
reading again relaxed, and a relaxed store of the mode elsewhere.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Some checks are pending
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
CI / What the change needs (pull_request) Waiting to run
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Waiting to run
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Waiting to run
beanstalk/approval not approved yet
This pull request is marked as a work in progress.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'perf/replay-stack:klimovich008-perf/replay-stack'
git switch 'klimovich008-perf/replay-stack'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 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!3328
No description provided.