WIP: perf(vk): report words looked up through a hash index and merged in place #1993

Draft
siantm wants to merge 4 commits from siantm/Longshot:perf/vk-report-words into main
Contributor

Summary

The replay keeps two sorted sets of the words the CPU noted as its own (cpu_words_merge, the report words), and
each merge of a report's new words looked every word up with two binary searches over those sets (the big one is
mostly cache misses) and merged with std::inplace_merge, which asks for a temporary buffer at every merge.

With this, a hash index (WordIndex) holds both sets' words, so the two binary searches a noted word took are one hash
lookup (one slot, or a few on a collision); only the fresh words are sorted, and sorted_merge merges them from the back
in place, with no separate merge buffer (the destination vector can still grow, as before). The index looks a word up
before it grows, so a batch of known words never grows it. Its table is optional: 32 KB at first, doubled as it fills,
at most 1 MB (65,536 words half full, the most memory_cpu_owned keeps), asked for with a nothrow new in a
NewNothrow scope; one it cannot have (refused at the commit limit, or past 1 MB) and the merge looks the words up in
the sets as main does, and the index is built again, fit to the sets, at the next merge. memory_cpu_owned's forget
frees the table with the sets. cut_cpu_words is unchanged. The sets hold the same words as before after every merge;
the result expected is less CPU time on the replaying thread at each merge.

RX_VK_LOG_WRITEBACK=1 (diagnostics) also logs, every 600 write-back submissions, the merges' count, mean and max time
by kind (plain, building the index, growing it, without it) and the index's slots: what a frame-time outlier at a
merge cost. The line is built under cpu_words_mu and logged after it is let go, so a slow log write does not hold up
the guest CPU's memory_cpu_owned.

No switch: a revert gives back main's code.

From 92fa6e19 on exp/x86-asm-sync.

Read first: WordIndex, sorted_merge and cpu_words_merge in gpu/vk/vk_memory.cpp, then
tests/test_report_words.py.

Testing

Tested: Windows 11, i7-9700, RTX 4060, the builder's llvm-mingw clang 23. Head 4422e0fd on main 9dd41326
(rebased from f1f2dc5b without a conflict; git range-diff: the three earlier commits unchanged), light job
fb-dy1993-1 of this PC's job queue, the checks in a hidden console: tests/test_report_words.py and
tests/test_mirror_bookkeeping.py pass, and gpu/vk/vk_memory.cpp compiled (syntax) with the game build's own
command; the --changed run below was not repeated on this main. Earlier, at the head then, ecd1b8a4 on main
f1f2dc5b, build jobs of this PC's job queue (fb-1993-1, fb-1996-1, fb-1993-base, fb-1993-2):
tests/test_report_words.py of the test commit acda2f8d against the PR's own code (ceb34693) fails, at each new
check run first (the forget growing the table to 2 MB and keeping it; a known-only batch doubling it; the run stopped at the refused
table), and passes at the head, with --cxx and with the compiler it picks itself; tests/test_mirror_bookkeeping.py
passes; every check tests/run_all.py --strict --changed origin/main picks at the head: 905 checks, 728 passed, 129
failed, 48 skipped (Linux only, or a tool this PC lacks). 66 of the 129 are renderer checks that did not compile in that
run, at the head or on main (no Vulkan headers under --strict: not run); run again with the Vulkan headers (RX_CPM set, --strict, 20 min per check) in build job fb-vkfix-1 at the head and on main @ f1f2dc5b: passes here and on main (46): tests/test_antilag.py, tests/test_async_safe_frees.py, tests/test_capture_dimensions.py, tests/test_capture_resources.py, tests/test_coopmat_probe_failures.py, tests/test_desc_counts.py, tests/test_device_policy.py, tests/test_dummy_views.py, tests/test_dump_readback.py, tests/test_fallback_pipeline_state.py, tests/test_framegen_resources.py, tests/test_framelog_sink.py, tests/test_fsr3_release_frees.py, tests/test_fsr3fi_hud_mask.py, tests/test_fsr4_bind_dispatch.py, tests/test_image_view_retry.py, tests/test_import_buffer_binding.py, tests/test_import_reach.py, tests/test_inline_write_order.py, tests/test_lost_wait_said.py, tests/test_pass_hazard.py, tests/test_pcache_header_read.py, tests/test_pipeline_key_values.py, tests/test_pipeline_state_portable.py, tests/test_pipeline_states.py, tests/test_program_answer_domains.py, tests/test_push_state.py, tests/test_recorder_parts.py, tests/test_same_draw.py, tests/test_same_dyn.py, tests/test_sparse_bind_failure.py, tests/test_sparse_bind_ranges.py, tests/test_split_ub_flush.py, tests/test_taau_typed_dispatch.py, tests/test_table_track.py, tests/test_texture_staging_publication.py, tests/test_ub_snapshot_default.py, tests/test_ui_texture_upload.py, tests/test_vendor_fixes.py, tests/test_vertex_bind.py, tests/test_vertex_bind_range.py, tests/test_vulkan_clear_mip.py, tests/test_vulkan_copy_span.py, tests/test_vulkan_copy_span_gpu_compile.py, tests/test_wb_diff_observations_gpu.py, tests/test_widen_alpha.py; passes here, fails on main (1): tests/test_recording_admission.py (on main: FAIL: worker slot ownership); fails on main too, headers found (19): tests/test_capture_readback_visibility.py, tests/test_draw_binds.py, tests/test_draw_stream_visibility.py, tests/test_fsr_image_retirement.py, tests/test_fsr_uniform_ownership.py, tests/test_low_vram_texture_mips.py, tests/test_pass_barrier.py, tests/test_present_queue_default.py, tests/test_present_source_crop.py, tests/test_recorder_own_idle.py, tests/test_recorder_sync.py, tests/test_replay_write_order.py, tests/test_sampler_admission.py, tests/test_staging_burst.py, tests/test_target_reuse_memory.py, tests/test_texel_buffer_ownership.py, tests/test_ub_update_batch.py, tests/test_ui_record.py, tests/test_vk_occlusion_queries.py. Of the other 63, 61 fail on main @ f1f2dc5b too, run from a base worktree (most for a tool this PC lacks under --strict; tests/test_vbytes.py a 600 s timeout on both, not run again: it hangs on this PC), and
the other two (tests/test_mesh_args_cleanup.py, tests/test_oot_wide_bubble.py) timed out compiling under that
run's load, pass on main, and pass at the head run again alone; gpu/vk/vk_memory.cpp compiled (syntax) with the game
build's own command.

It has NOT run in the game on this PC yet.

Still to test:

  • Windows 11, i7-9700, RTX 4060 (this PC): Kokiri Forest, play three minutes turning the camera and walking into Link's
    house and out, and a heavy area (Hyrule Field, three minutes running and turning the camera): main @ 9dd41326
    against this branch, same build type, driver, save, route and settings, each warmed up a minute in the scene first,
    interleaved (ABBA), at least two runs each, with RX_VK_LOG_WRITEBACK=1 on this branch, expecting the same picture
    through the scene changes and no FATAL; report average FPS, 1% lows, median and p99 frame times, the process's RAM and
    VRAM, and the report words' merge line (count, mean and max by kind); a gain is median and p99 frame time lower than
    on main with no merge kind's max near a frame (by hand)
  • Linux NVIDIA and AMD, Windows AMD and Intel, Steam Deck: the same scenes, three minutes: main @ 9dd41326 against this
    branch, warmed up, ABBA, expecting the same picture and no FATAL, and the same figures as above (by hand or on the
    farm, not run yet)
  • Linux: build the renderer at the head, run python3 -I -B tests/test_report_words.py with GCC and with Clang
    (--cxx g++, --cxx clang++), expecting PASS, and the full tests/run_all.py and the lint (by hand)
  • Windows: the full tests/run_all.py and the lint at the head (by hand)

Measurements

Verdict: not measured: no micro-benchmark of this port and no run in the game on this PC yet; the in-game A/B is
in Still to test. No switch: the in-game A/B is this branch against main @ 9dd41326. How the gain on the number this
change targets (the merge time) will be shown against main (a replay-thread profile of both sides, or the
micro-benchmark rerun with main's and this head's cpu_words_merge): pending.

Risks

What could break: a word lost or kept twice in the sets would show as a CPU write the replay treats as the GPU's (or
the other way round): a wrong value read back, a flicker or a stale texture in any scene. The test runs 800 rounds of
merges (known words only, new only, mixed, repeats) against std::set over 16,384 addresses, the recent set promoted
on the way, and checks the sets equal after each; the forget at 65,536 words and a forgotten word noted again are
check_clear's, a known-only batch at the half-full boundary check_known_at_boundary's, and a table refused in the
middle of a batch check_refused's (the fixture's operator new refusing as the renderer's new_handler does at the
commit limit). RAM: the index keeps at most 1 MB (131,072 slots) and needs 1.5 MB at the moment it grows to that (the
old table and the new); 32 KB at first; freed when the sets are forgotten. Turn it off: a revert is enough. 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 check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • 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 The replay keeps two sorted sets of the words the CPU noted as its own (`cpu_words_merge`, the report words), and each merge of a report's new words looked every word up with two binary searches over those sets (the big one is mostly cache misses) and merged with `std::inplace_merge`, which asks for a temporary buffer at every merge. With this, a hash index (`WordIndex`) holds both sets' words, so the two binary searches a noted word took are one hash lookup (one slot, or a few on a collision); only the fresh words are sorted, and `sorted_merge` merges them from the back in place, with no separate merge buffer (the destination vector can still grow, as before). The index looks a word up before it grows, so a batch of known words never grows it. Its table is optional: 32 KB at first, doubled as it fills, at most 1 MB (65,536 words half full, the most `memory_cpu_owned` keeps), asked for with a nothrow new in a `NewNothrow` scope; one it cannot have (refused at the commit limit, or past 1 MB) and the merge looks the words up in the sets as main does, and the index is built again, fit to the sets, at the next merge. `memory_cpu_owned`'s forget frees the table with the sets. `cut_cpu_words` is unchanged. The sets hold the same words as before after every merge; the result expected is less CPU time on the replaying thread at each merge. `RX_VK_LOG_WRITEBACK=1` (diagnostics) also logs, every 600 write-back submissions, the merges' count, mean and max time by kind (plain, building the index, growing it, without it) and the index's slots: what a frame-time outlier at a merge cost. The line is built under `cpu_words_mu` and logged after it is let go, so a slow log write does not hold up the guest CPU's `memory_cpu_owned`. No switch: a revert gives back main's code. From 92fa6e19 on `exp/x86-asm-sync`. Read first: `WordIndex`, `sorted_merge` and `cpu_words_merge` in `gpu/vk/vk_memory.cpp`, then `tests/test_report_words.py`. ## Testing **Tested:** Windows 11, i7-9700, RTX 4060, the builder's llvm-mingw clang 23. Head `4422e0fd` on main `9dd41326` (rebased from `f1f2dc5b` without a conflict; `git range-diff`: the three earlier commits unchanged), light job `fb-dy1993-1` of this PC's job queue, the checks in a hidden console: `tests/test_report_words.py` and `tests/test_mirror_bookkeeping.py` pass, and `gpu/vk/vk_memory.cpp` compiled (syntax) with the game build's own command; the `--changed` run below was not repeated on this main. Earlier, at the head then, `ecd1b8a4` on main `f1f2dc5b`, build jobs of this PC's job queue (`fb-1993-1`, `fb-1996-1`, `fb-1993-base`, `fb-1993-2`): `tests/test_report_words.py` of the test commit `acda2f8d` against the PR's own code (`ceb34693`) fails, at each new check run first (the forget growing the table to 2 MB and keeping it; a known-only batch doubling it; the run stopped at the refused table), and passes at the head, with `--cxx` and with the compiler it picks itself; `tests/test_mirror_bookkeeping.py` passes; every check `tests/run_all.py --strict --changed origin/main` picks at the head: 905 checks, 728 passed, 129 failed, 48 skipped (Linux only, or a tool this PC lacks). 66 of the 129 are renderer checks that did not compile in that run, at the head or on main (no Vulkan headers under `--strict`: not run); run again with the Vulkan headers (`RX_CPM` set, `--strict`, 20 min per check) in build job `fb-vkfix-1` at the head and on main @ f1f2dc5b: passes here and on main (46): `tests/test_antilag.py`, `tests/test_async_safe_frees.py`, `tests/test_capture_dimensions.py`, `tests/test_capture_resources.py`, `tests/test_coopmat_probe_failures.py`, `tests/test_desc_counts.py`, `tests/test_device_policy.py`, `tests/test_dummy_views.py`, `tests/test_dump_readback.py`, `tests/test_fallback_pipeline_state.py`, `tests/test_framegen_resources.py`, `tests/test_framelog_sink.py`, `tests/test_fsr3_release_frees.py`, `tests/test_fsr3fi_hud_mask.py`, `tests/test_fsr4_bind_dispatch.py`, `tests/test_image_view_retry.py`, `tests/test_import_buffer_binding.py`, `tests/test_import_reach.py`, `tests/test_inline_write_order.py`, `tests/test_lost_wait_said.py`, `tests/test_pass_hazard.py`, `tests/test_pcache_header_read.py`, `tests/test_pipeline_key_values.py`, `tests/test_pipeline_state_portable.py`, `tests/test_pipeline_states.py`, `tests/test_program_answer_domains.py`, `tests/test_push_state.py`, `tests/test_recorder_parts.py`, `tests/test_same_draw.py`, `tests/test_same_dyn.py`, `tests/test_sparse_bind_failure.py`, `tests/test_sparse_bind_ranges.py`, `tests/test_split_ub_flush.py`, `tests/test_taau_typed_dispatch.py`, `tests/test_table_track.py`, `tests/test_texture_staging_publication.py`, `tests/test_ub_snapshot_default.py`, `tests/test_ui_texture_upload.py`, `tests/test_vendor_fixes.py`, `tests/test_vertex_bind.py`, `tests/test_vertex_bind_range.py`, `tests/test_vulkan_clear_mip.py`, `tests/test_vulkan_copy_span.py`, `tests/test_vulkan_copy_span_gpu_compile.py`, `tests/test_wb_diff_observations_gpu.py`, `tests/test_widen_alpha.py`; passes here, fails on main (1): `tests/test_recording_admission.py` (on main: `FAIL: worker slot ownership`); fails on main too, headers found (19): `tests/test_capture_readback_visibility.py`, `tests/test_draw_binds.py`, `tests/test_draw_stream_visibility.py`, `tests/test_fsr_image_retirement.py`, `tests/test_fsr_uniform_ownership.py`, `tests/test_low_vram_texture_mips.py`, `tests/test_pass_barrier.py`, `tests/test_present_queue_default.py`, `tests/test_present_source_crop.py`, `tests/test_recorder_own_idle.py`, `tests/test_recorder_sync.py`, `tests/test_replay_write_order.py`, `tests/test_sampler_admission.py`, `tests/test_staging_burst.py`, `tests/test_target_reuse_memory.py`, `tests/test_texel_buffer_ownership.py`, `tests/test_ub_update_batch.py`, `tests/test_ui_record.py`, `tests/test_vk_occlusion_queries.py`. Of the other 63, 61 fail on main @ f1f2dc5b too, run from a base worktree (most for a tool this PC lacks under `--strict`; `tests/test_vbytes.py` a 600 s timeout on both, not run again: it hangs on this PC), and the other two (`tests/test_mesh_args_cleanup.py`, `tests/test_oot_wide_bubble.py`) timed out compiling under that run's load, pass on main, and pass at the head run again alone; `gpu/vk/vk_memory.cpp` compiled (syntax) with the game build's own command. **It has NOT run in the game on this PC yet.** **Still to test:** - Windows 11, i7-9700, RTX 4060 (this PC): Kokiri Forest, play three minutes turning the camera and walking into Link's house and out, and a heavy area (Hyrule Field, three minutes running and turning the camera): main @ 9dd41326 against this branch, same build type, driver, save, route and settings, each warmed up a minute in the scene first, interleaved (ABBA), at least two runs each, with `RX_VK_LOG_WRITEBACK=1` on this branch, expecting the same picture through the scene changes and no FATAL; report average FPS, 1% lows, median and p99 frame times, the process's RAM and VRAM, and the report words' merge line (count, mean and max by kind); a gain is median and p99 frame time lower than on main with no merge kind's max near a frame (by hand) - Linux NVIDIA and AMD, Windows AMD and Intel, Steam Deck: the same scenes, three minutes: main @ 9dd41326 against this branch, warmed up, ABBA, expecting the same picture and no FATAL, and the same figures as above (by hand or on the farm, not run yet) - Linux: build the renderer at the head, run `python3 -I -B tests/test_report_words.py` with GCC and with Clang (`--cxx g++`, `--cxx clang++`), expecting PASS, and the full `tests/run_all.py` and the lint (by hand) - Windows: the full `tests/run_all.py` and the lint at the head (by hand) ## Measurements **Verdict:** not measured: no micro-benchmark of this port and no run in the game on this PC yet; the in-game A/B is in Still to test. No switch: the in-game A/B is this branch against main @ 9dd41326. How the gain on the number this change targets (the merge time) will be shown against main (a replay-thread profile of both sides, or the micro-benchmark rerun with main's and this head's `cpu_words_merge`): pending. ## Risks What could break: a word lost or kept twice in the sets would show as a CPU write the replay treats as the GPU's (or the other way round): a wrong value read back, a flicker or a stale texture in any scene. The test runs 800 rounds of merges (known words only, new only, mixed, repeats) against `std::set` over 16,384 addresses, the recent set promoted on the way, and checks the sets equal after each; the forget at 65,536 words and a forgotten word noted again are `check_clear`'s, a known-only batch at the half-full boundary `check_known_at_boundary`'s, and a table refused in the middle of a batch `check_refused`'s (the fixture's operator new refusing as the renderer's new_handler does at the commit limit). RAM: the index keeps at most 1 MB (131,072 slots) and needs 1.5 MB at the moment it grows to that (the old table and the new); 32 KB at first; freed when the sets are forgotten. Turn it off: a revert is enough. Renderer code: the runtime is rebuilt; nothing changes for players' saves, options or caches. ## Checklist ### Ready for review - [x] 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 - [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] 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.
perf(vk): report words looked up through a hash index and merged in place
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 7s
Website / Website on Cloudflare (pull_request_target) Has been skipped
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
da36759f52
- cpu_words_merge: a WordIndex holds both sets' words, so whether a noted word is kept already is one probe instead of
  two binary searches (the 512 KB big set's mostly cache misses); only the fresh words are sorted, and sorted_merge
  merges from the back in place with no allocation (std::inplace_merge allocated a buffer at every merge). The index is
  built again when its count differs from the sets' (memory_cpu_owned forgot them). cut_cpu_words is unchanged.
- Why: in a Kokiri profile on the branch the merge was 1.36% of a core (0.30 ms a frame) on the replay.
- Micro-benchmark on the branch (92fa6e19), per merge at 2,000 reports a frame: 56.5 -> 20.2 us (50% new words),
  54.0 -> 8.1 us (10% new); the sets compared equal to the old code's after all 22,800 merges. Not measured in play
  on main's renderer.
- Test: tests/test_report_words.py now cuts WordIndex too and checks the index is built again after the sets are
  forgotten (800 rounds against std::set as before). No switch.

Assisted-by: Claude Code
BeanBot left a comment

Recommendation: Request changes. A batch containing only known report words can trigger a full rehash on the replay thread. The new index also adds a wait or shutdown path under memory pressure, and the exact-head tests and gameplay runs have yet to establish a net gain.

The patch keeps CPU-written counter reports out of mirrored GPU write-backs as before. It trades two binary searches per word and a temporary merge buffer for a persistent hash table and a backward merge. The game-free check covers ownership and write-back cuts. Players with mirrors enabled pay the extra RAM and replay-thread work on growth and reset.

@fix will do (7)

  1. L1 gpu/vk/vk_memory.cpp:4494: Check whether the word already exists before growing the table. (more on the line)
  2. L2 gpu/vk/vk_memory.cpp:4504: Make the index optional when its allocation fails. (more on the line)
  3. L3 (its part an edit can do) gpu/vk/vk_memory.cpp:4509: Make reset proportional to occupied slots or use generation tags. Handle the forget threshold without growing the index for words about to be discarded.
  4. L4 tests/test_report_words.py:21: Declare RUN_ALL_ARGS = ["--cxx", "{cxx}"] so the check uses the runner's selected C++ compiler. A Windows setup with only llvm-mingw clang++ on PATH can fail looking for g++, and on Linux CXX=clang++ can silently exercise g++ again. Honor CXX for direct invocation too while keeping the explicit --cxx override.
  5. L5 (its part an edit can do): Record merge timings with growth and reset identified separately, so the frame-time outliers can be attributed.
  6. L7 (minor): Qualify the Summary's allocation and lookup claims. A collision can inspect several slots, sorted_merge can still grow its destination vector, and the index allocates on first use and growth. Say that it replaces the two binary searches with one hash lookup and removes the separate merge scratch buffer. List retained and peak index RAM in Risks.
  7. L8 (minor): The 800-round set comparison never reaches the forget threshold because it uses only 16,384 possible addresses. Credit the separate check_clear case for testing whether a forgotten word can be added again.

For the author (3) (a run, a measurement or a decision)

  • L3 gpu/vk/vk_memory.cpp:4509: Measure the first merge after ownership is forgotten and the retained RAM after a high-water mark. (more on the line)
  • L5 (minor): The renderer change opened before the author's required in-game run. Compare the final head with its base using the same build type, driver, save, route, and settings. Cover Kokiri and a heavy area on Tier 1 hardware. Report replay merge time, average FPS, 1% lows, median and p99 frame time, RAM and VRAM, and verify the picture through scene transitions. A median-only pass can miss the occasional rehash or reset hitch.
  • L6 (minor): The reported Windows run covers the selected checks. The required full suite and lint have no results, and the planned Linux check covers a fixture rather than renderer linking. Record the full suite and lint, compile the fixture with GCC and Clang, and verify a Linux renderer build at the final head.

Checks: Still running: CI / Conventional Commit title (pull_request), CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request), CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request), CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request), CI / Workflow lint (actionlint) (pull_request), CI / Website build and checks (pull_request), Guide screenshots / Guide images and local UI source review (pull_request), Third-party parts / As their notes say (pull_request), Third-party parts / The same as upstream (pull_request), PR description / Description follows the template (pull_request_target).

More: does it help, other systems, switches, what was read

Does it help: Unproven. The commit reports 56.5 to 20.2 µs per merge at 50% new words and 54.0 to 8.1 µs at 10%, with equal sets after 22,800 merges on experimental commit 92fa6e19. Those figures do not compare da36759f with 75317e1f. There are no exact-head gameplay, frame-tail, or memory measurements.

Other systems: All Windows and Linux GPUs with VRAM mirrors enabled share this path, including ordinary, sparse, and diff write-backs. Tests model ownership and byte cuts. No gameplay run verifies the picture or pacing in those modes. Mirror-disabled paths, including the default on integrated GPUs and Steam Deck, bypass the index. Allocation adds system RAM and no Vulkan resources. The patch leaves the renderer ABI, cache formats, saves, audio, input, and build flags alone.

Switches: None added, changed, or removed. The existing mirror policy still controls whether report words are tracked.

Reviewed: da36759f52 against 75317e1f31: Read AGENTS.md, CONTRIBUTING.md, the Forgejo template, docs/dev/standards.md, both file diffs, and tests/test_report_words.py in full. Read the full changed region of vk_memory.cpp and traced both callers, report address translation, mirror policy, the allocation handler, the neighboring source-cut check, and compiler selection. Read the relevant architecture and development rules. The rest of vk_memory.cpp and unrelated renderer paths were outside the traced regions. No local review checklist, sibling Tooling checkout, matching recorded run, or experimental benchmark commit was available. No translations or generated files changed.; nothing run (a code review).

Checked and fine:

  • Both production callers hold cpu_words_mu through lookup, compaction, promotion, and write-back cuts. The index has no lock-free readers or thread-local allocation.
  • The backward merge uses separate source and destination vectors at both call sites, and pending-word compaction only writes at or behind the current input element. Aligned guest words cannot equal the sentinel.
  • The reset check would fail if stale index entries survived the forget. Existing checks still cover partial overlaps, promotion, and repeated words. Mirror behavior is fixed by the stand-in, so renderer environment switches cannot change the result.
  • The existing mirror bookkeeping fixture extracts the entire changed helper region. The change adds no project script, download, external action, CPU instruction requirement, or runtime file API.
  • One topic and a valid Conventional Commit title under the WIP prefix. The commit has an Assisted-by trailer. No game data, generated files, vendor SDKs, or third-party code were added. No switch-table or API-version update applies.

Testing: Read-only review. The author reports 68 of 76 selected Windows checks passed, including the report-word fixture, and all eight failures also occurred on the base. CI is pending. No game run, Linux renderer build, full-suite result, or independently verifiable exact-head benchmark was supplied.

Overlaps and merge order: None found in the available refs. The local main has advanced to 6e1521a7 (#1948), which does not touch either changed file. Use current main for the final comparison.


Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** A batch containing only known report words can trigger a full rehash on the replay thread. The new index also adds a wait or shutdown path under memory pressure, and the exact-head tests and gameplay runs have yet to establish a net gain. The patch keeps CPU-written counter reports out of mirrored GPU write-backs as before. It trades two binary searches per word and a temporary merge buffer for a persistent hash table and a backward merge. The game-free check covers ownership and write-back cuts. Players with mirrors enabled pay the extra RAM and replay-thread work on growth and reset. **`@fix` will do (7)** 1. **L1** `gpu/vk/vk_memory.cpp:4494`: Check whether the word already exists before growing the table. (more on the line) 2. **L2** `gpu/vk/vk_memory.cpp:4504`: Make the index optional when its allocation fails. (more on the line) 3. **L3** (its part an edit can do) `gpu/vk/vk_memory.cpp:4509`: Make reset proportional to occupied slots or use generation tags. Handle the forget threshold without growing the index for words about to be discarded. 4. **L4** `tests/test_report_words.py:21`: Declare RUN_ALL_ARGS = ["--cxx", "{cxx}"] so the check uses the runner's selected C++ compiler. A Windows setup with only llvm-mingw clang++ on PATH can fail looking for g++, and on Linux CXX=clang++ can silently exercise g++ again. Honor CXX for direct invocation too while keeping the explicit --cxx override. 5. **L5** (its part an edit can do): Record merge timings with growth and reset identified separately, so the frame-time outliers can be attributed. 6. **L7** (minor): Qualify the Summary's allocation and lookup claims. A collision can inspect several slots, sorted_merge can still grow its destination vector, and the index allocates on first use and growth. Say that it replaces the two binary searches with one hash lookup and removes the separate merge scratch buffer. List retained and peak index RAM in Risks. 7. **L8** (minor): The 800-round set comparison never reaches the forget threshold because it uses only 16,384 possible addresses. Credit the separate check_clear case for testing whether a forgotten word can be added again. **For the author (3)** (a run, a measurement or a decision) - **L3** `gpu/vk/vk_memory.cpp:4509`: Measure the first merge after ownership is forgotten and the retained RAM after a high-water mark. (more on the line) - **L5** (minor): The renderer change opened before the author's required in-game run. Compare the final head with its base using the same build type, driver, save, route, and settings. Cover Kokiri and a heavy area on Tier 1 hardware. Report replay merge time, average FPS, 1% lows, median and p99 frame time, RAM and VRAM, and verify the picture through scene transitions. A median-only pass can miss the occasional rehash or reset hitch. - **L6** (minor): The reported Windows run covers the selected checks. The required full suite and lint have no results, and the planned Linux check covers a fixture rather than renderer linking. Record the full suite and lint, compile the fixture with GCC and Clang, and verify a Linux renderer build at the final head. **Checks:** Still running: `CI / Conventional Commit title (pull_request)`, `CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request)`, `CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request)`, `CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request)`, `CI / Workflow lint (actionlint) (pull_request)`, `CI / Website build and checks (pull_request)`, `Guide screenshots / Guide images and local UI source review (pull_request)`, `Third-party parts / As their notes say (pull_request)`, `Third-party parts / The same as upstream (pull_request)`, `PR description / Description follows the template (pull_request_target)`. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven. The commit reports 56.5 to 20.2 µs per merge at 50% new words and 54.0 to 8.1 µs at 10%, with equal sets after 22,800 merges on experimental commit 92fa6e19. Those figures do not compare da36759f with 75317e1f. There are no exact-head gameplay, frame-tail, or memory measurements. **Other systems:** All Windows and Linux GPUs with VRAM mirrors enabled share this path, including ordinary, sparse, and diff write-backs. Tests model ownership and byte cuts. No gameplay run verifies the picture or pacing in those modes. Mirror-disabled paths, including the default on integrated GPUs and Steam Deck, bypass the index. Allocation adds system RAM and no Vulkan resources. The patch leaves the renderer ABI, cache formats, saves, audio, input, and build flags alone. **Switches:** None added, changed, or removed. The existing mirror policy still controls whether report words are tracked. **Reviewed:** da36759f52c5 against 75317e1f31ff: Read AGENTS.md, CONTRIBUTING.md, the Forgejo template, docs/dev/standards.md, both file diffs, and tests/test_report_words.py in full. Read the full changed region of vk_memory.cpp and traced both callers, report address translation, mirror policy, the allocation handler, the neighboring source-cut check, and compiler selection. Read the relevant architecture and development rules. The rest of vk_memory.cpp and unrelated renderer paths were outside the traced regions. No local review checklist, sibling Tooling checkout, matching recorded run, or experimental benchmark commit was available. No translations or generated files changed.; nothing run (a code review). **Checked and fine:** - Both production callers hold cpu_words_mu through lookup, compaction, promotion, and write-back cuts. The index has no lock-free readers or thread-local allocation. - The backward merge uses separate source and destination vectors at both call sites, and pending-word compaction only writes at or behind the current input element. Aligned guest words cannot equal the sentinel. - The reset check would fail if stale index entries survived the forget. Existing checks still cover partial overlaps, promotion, and repeated words. Mirror behavior is fixed by the stand-in, so renderer environment switches cannot change the result. - The existing mirror bookkeeping fixture extracts the entire changed helper region. The change adds no project script, download, external action, CPU instruction requirement, or runtime file API. - One topic and a valid Conventional Commit title under the WIP prefix. The commit has an Assisted-by trailer. No game data, generated files, vendor SDKs, or third-party code were added. No switch-table or API-version update applies. **Testing:** Read-only review. The author reports 68 of 76 selected Windows checks passed, including the report-word fixture, and all eight failures also occurred on the base. CI is pending. No game run, Linux renderer build, full-suite result, or independently verifiable exact-head benchmark was supplied. **Overlaps and merge order:** None found in the available refs. The local main has advanced to 6e1521a7 (#1948), which does not touch either changed file. Use current main for the final comparison. </details> --- <sub>Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.</sub>
@ -4484,0 +4491,4 @@
size_t n = 0;
bool add(uint64_t w) { // (true: it was not there)
if ((n + 1) * 2 > slot.size()) grow();
const size_t mask = slot.size() - 1;
Member

L1: Check whether the word already exists before growing the table. At exactly 65,536 retained words, one repeated report makes the index allocate 2 MiB and reinsert all 65,536 entries even though the batch adds nothing. Probe first, grow only on a miss, and test that a known-only batch at the half-full boundary leaves capacity unchanged.

**L1**: Check whether the word already exists before growing the table. At exactly 65,536 retained words, one repeated report makes the index allocate 2 MiB and reinsert all 65,536 entries even though the batch adds nothing. Probe first, grow only on a miss, and test that a known-only batch at the half-full boundary leaves capacity unchanged.
@ -4484,0 +4501,4 @@
std::vector<uint64_t> old;
old.swap(slot);
slot.assign(old.empty() ? (size_t)1 << 16 : old.size() * 2, kEmpty), n = 0;
for (const uint64_t w : old)
Member

L2: Make the index optional when its allocation fails. Even a single new report now asks for 512 KiB when the destination vector may already have room. At the Windows commit limit that extra request can stall replay or end the game. Allocate replacement storage before changing index state, use the renderer's NewNothrow scope for the optional allocation, and fall back to sorted-set lookup with the full pending batch intact. Exercise allocation refusal during growth after some words in the batch have already been classified.

**L2**: Make the index optional when its allocation fails. Even a single new report now asks for 512 KiB when the destination vector may already have room. At the Windows commit limit that extra request can stall replay or end the game. Allocate replacement storage before changing index state, use the renderer's NewNothrow scope for the optional allocation, and fall back to sorted-set lookup with the full pending batch intact. Exercise allocation refusal during growth after some words in the batch have already been classified.
@ -4484,0 +4506,4 @@
}
void clear() {
if (n) std::fill(slot.begin(), slot.end(), kEmpty), n = 0;
}
Member

L3: Measure the first merge after ownership is forgotten and the retained RAM after a high-water mark. A stream of fresh reports can push the table to 262,144 slots just before the ownership sets are forgotten. Every subsequent forget then makes the next small merge sweep the entire table under the replay lock. The merge averages in the commit do not isolate this cost.

**L3**: Measure the first merge after ownership is forgotten and the retained RAM after a high-water mark. A stream of fresh reports can push the table to 262,144 slots just before the ownership sets are forgotten. Every subsequent forget then makes the next small merge sweep the entire table under the replay lock. The merge averages in the commit do not isolate this cost.
siantm force-pushed perf/vk-report-words from da36759f52
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 7s
Website / Website on Cloudflare (pull_request_target) Has been skipped
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
to ecd1b8a499
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 5s
beanstalk/approval approved by dyst (reviewed)
beanstalk/linux+nvidia 0/1 pass, 1 running, 1 queued
beanstalk/linux+amd+radv 2/1 fail
beanstalk/windows+amd 0/1 pass, 2 running, 0 queued
beanstalk/windows+intel 0/1 pass, 0 running, 2 queued
beanstalk/steamdeck 0/1 pass, 0 running, 2 queued
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
2026-11-21 04:49:06 +00:00
Compare
Author
Contributor

Thanks for the review (#1993 (comment)). The branch is rebased onto main @ f1f2dc5b, and the rebase left the PR's own commit unchanged (now ceb34693). On top of it are two commits: acda2f8d (the tests) and ecd1b8a4 (the fix). Point by point:

  • L1 (#1993 (comment)): right. WordIndex::add now looks the word up first and grows the table only for a word it does not hold (ecd1b8a4). check_known_at_boundary fills the index to exactly half (32,768 words in 65,536 slots), merges a batch of known words only, and checks the table did not change. On the PR's code it fails (the table doubles).
  • L2 (#1993 (comment)): right. The table is now allocated with new (std::nothrow) inside a NewNothrow scope, before the index changes (ecd1b8a4). If that allocation is refused, or the table would pass 1 MB, the rest of the batch is looked up in the sets as main does. The words the index already dropped were known words or repeats of fresh ones still at the front, so every word of the batch is still there. The index is built again, sized to the sets, at the next merge. The first table is 32 KB, not 512 KB. check_refused refuses the bigger table after a known and a fresh word of the batch were already classified. The fixture's operator new refuses as the renderer's new_handler does at the commit limit: a nothrow new inside a NewNothrow scope gets null, and any other new stops the run. On the PR's code the run stops.
  • L3 (#1993 (comment)): the part an edit can do is in ecd1b8a4. memory_cpu_owned's forget frees the table along with the sets, so the next merge does not sweep a high-water table; it builds one sized to what the sets hold. The table stops at 1 MB (131,072 slots, 65,536 words half full, the most the sets keep before the forget), so the merge just before a forget does not grow it for words about to be dropped. check_clear checks that no block over 1 MB is asked for across that forget and that the table is given back (it fails on the PR's code). Measuring the first merge after a forget and the RAM kept after a high-water mark needs a run in the game; it is pending, with the log line from L5.
  • L4 (review item 4): right. The test now declares RUN_ALL_ARGS = ["--cxx", "{cxx}"]. Run on its own it uses CXX, else the first of clang++, g++ or c++ on PATH, and --cxx still overrides (acda2f8d).
  • L5 (review item 5): with RX_VK_LOG_WRITEBACK=1, every 600 write-back submissions now log the merges' count, mean and max time by kind (plain, built the index, grew it, without it) and the index's slots (ecd1b8a4; the switch row says so). The in-game comparison is pending and in Still to test: final head against main @ f1f2dc5b, same build, driver, save, route and settings, Kokiri Forest and Hyrule Field, reporting that line with average FPS, 1% lows, median and p99 frame times, RAM and VRAM.
  • L6 (review, for the author): pending. On this PC the fixture ran with clang (llvm-mingw), the checks --changed picks ran, and vk_memory.cpp was compiled with the game build's own command (see below). Still to test now lists the GCC and Clang fixture runs, the Linux renderer build at the head, and the full suite and lint.
  • L7 (review item 6): right. The Summary now says the two binary searches become one hash lookup (a few slots on a collision) and the separate merge buffer is gone, while the destination vector can still grow. Risks gives the index's RAM: at most 1 MB kept, 1.5 MB at the moment it grows to that, 32 KB at first, freed at the forget.
  • L8 (review item 7): right. Risks now says the 800-round comparison runs over 16,384 addresses and never reaches the forget. The forget, and a forgotten word noted again, are covered by check_clear (with check_known_at_boundary and check_refused named beside it).

Checked on this PC at the head ecd1b8a4 (main f1f2dc5b), through the job queue (fb-1993-1, fb-1996-1, fb-1993-base, fb-1993-2): the test commit's checks fail against the PR's code, each run first in turn, and pass at the head; test_mirror_bookkeeping passes; of the 905 checks --changed picks, 129 failed: 127 fail on main @ f1f2dc5b too, and the other two had timed out compiling under that run's load, and pass on main and at the head run alone; vk_memory.cpp compiled with the game build's own command. The description's Summary, Testing and Risks are updated. Not run in the game on this PC yet.

Thanks for the review (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1993#issuecomment-62976). The branch is rebased onto main @ f1f2dc5b, and the rebase left the PR's own commit unchanged (now ceb34693). On top of it are two commits: acda2f8d (the tests) and ecd1b8a4 (the fix). Point by point: - **L1** (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1993#issuecomment-62973): right. `WordIndex::add` now looks the word up first and grows the table only for a word it does not hold (ecd1b8a4). `check_known_at_boundary` fills the index to exactly half (32,768 words in 65,536 slots), merges a batch of known words only, and checks the table did not change. On the PR's code it fails (the table doubles). - **L2** (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1993#issuecomment-62974): right. The table is now allocated with `new (std::nothrow)` inside a `NewNothrow` scope, before the index changes (ecd1b8a4). If that allocation is refused, or the table would pass 1 MB, the rest of the batch is looked up in the sets as main does. The words the index already dropped were known words or repeats of fresh ones still at the front, so every word of the batch is still there. The index is built again, sized to the sets, at the next merge. The first table is 32 KB, not 512 KB. `check_refused` refuses the bigger table after a known and a fresh word of the batch were already classified. The fixture's operator new refuses as the renderer's new_handler does at the commit limit: a nothrow new inside a `NewNothrow` scope gets null, and any other new stops the run. On the PR's code the run stops. - **L3** (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1993#issuecomment-62975): the part an edit can do is in ecd1b8a4. `memory_cpu_owned`'s forget frees the table along with the sets, so the next merge does not sweep a high-water table; it builds one sized to what the sets hold. The table stops at 1 MB (131,072 slots, 65,536 words half full, the most the sets keep before the forget), so the merge just before a forget does not grow it for words about to be dropped. `check_clear` checks that no block over 1 MB is asked for across that forget and that the table is given back (it fails on the PR's code). Measuring the first merge after a forget and the RAM kept after a high-water mark needs a run in the game; it is pending, with the log line from L5. - **L4** (review item 4): right. The test now declares `RUN_ALL_ARGS = ["--cxx", "{cxx}"]`. Run on its own it uses `CXX`, else the first of clang++, g++ or c++ on PATH, and `--cxx` still overrides (acda2f8d). - **L5** (review item 5): with `RX_VK_LOG_WRITEBACK=1`, every 600 write-back submissions now log the merges' count, mean and max time by kind (plain, built the index, grew it, without it) and the index's slots (ecd1b8a4; the switch row says so). The in-game comparison is pending and in Still to test: final head against main @ f1f2dc5b, same build, driver, save, route and settings, Kokiri Forest and Hyrule Field, reporting that line with average FPS, 1% lows, median and p99 frame times, RAM and VRAM. - **L6** (review, for the author): pending. On this PC the fixture ran with clang (llvm-mingw), the checks `--changed` picks ran, and `vk_memory.cpp` was compiled with the game build's own command (see below). Still to test now lists the GCC and Clang fixture runs, the Linux renderer build at the head, and the full suite and lint. - **L7** (review item 6): right. The Summary now says the two binary searches become one hash lookup (a few slots on a collision) and the separate merge buffer is gone, while the destination vector can still grow. Risks gives the index's RAM: at most 1 MB kept, 1.5 MB at the moment it grows to that, 32 KB at first, freed at the forget. - **L8** (review item 7): right. Risks now says the 800-round comparison runs over 16,384 addresses and never reaches the forget. The forget, and a forgotten word noted again, are covered by `check_clear` (with `check_known_at_boundary` and `check_refused` named beside it). Checked on this PC at the head ecd1b8a4 (main f1f2dc5b), through the job queue (`fb-1993-1`, `fb-1996-1`, `fb-1993-base`, `fb-1993-2`): the test commit's checks fail against the PR's code, each run first in turn, and pass at the head; `test_mirror_bookkeeping` passes; of the 905 checks `--changed` picks, 129 failed: 127 fail on main @ f1f2dc5b too, and the other two had timed out compiling under that run's load, and pass on main and at the head run alone; `vk_memory.cpp` compiled with the game build's own command. The description's Summary, Testing and Risks are updated. Not run in the game on this PC yet.
Author
Contributor

@Beanstalk This changes how the Vulkan replay merges the report words the CPU owns (gpu/vk): a hash index answers whether a word is kept already and the fresh words are merged in place, with no allocation; the words kept are the same as before. No switch: a revert gives back main's code. It has not run in the game on these PCs yet. Please play Kokiri Forest for three minutes after a minute's warm-up, the PR against main on the same PC, with a picture compared with main's, on Linux with NVIDIA, Linux with AMD (RADV), Windows with AMD, Windows with Intel and the Steam Deck. The same picture (no stale or flickering values), no crash and no FATAL line; frame time p99 equal to main's or better, within the run-to-run spread.

@Beanstalk This changes how the Vulkan replay merges the report words the CPU owns (gpu/vk): a hash index answers whether a word is kept already and the fresh words are merged in place, with no allocation; the words kept are the same as before. No switch: a revert gives back main's code. It has not run in the game on these PCs yet. Please play Kokiri Forest for three minutes after a minute's warm-up, the PR against main on the same PC, with a picture compared with main's, on Linux with NVIDIA, Linux with AMD (RADV), Windows with AMD, Windows with Intel and the Steam Deck. The same picture (no stale or flickering values), no crash and no FATAL line; frame time p99 equal to main's or better, within the run-to-run spread.
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

Description corrected (Testing; no push, the head is still ecd1b8a4). 66 of the 129 checks the --changed run counted as failing (and as failing on main as well) were renderer checks that had not compiled, at the head or on main: this PC's run had no Vulkan headers, and under --strict they stopped at not found: vulkan_headers. Run again with the headers (RX_CPM set, --strict, 20 min per check) in build job fb-vkfix-1 at ecd1b8a4 and on main @ f1f2dc5b: 46 pass here and on main, 19 fail on main too with the headers found, and tests/test_recording_admission.py passes here and fails on main (worker slot ownership). None fails only at this head. The per-check list is in Testing; tests/test_vbytes.py was not run again (it hangs on this PC).

Description corrected (Testing; no push, the head is still ecd1b8a4). 66 of the 129 checks the `--changed` run counted as failing (and as failing on main as well) were renderer checks that had not compiled, at the head or on main: this PC's run had no Vulkan headers, and under `--strict` they stopped at `not found: vulkan_headers`. Run again with the headers (`RX_CPM` set, `--strict`, 20 min per check) in build job `fb-vkfix-1` at ecd1b8a4 and on main @ f1f2dc5b: 46 pass here and on main, 19 fail on main too with the headers found, and `tests/test_recording_admission.py` passes here and fails on main (`worker slot ownership`). None fails only at this head. The per-check list is in Testing; `tests/test_vbytes.py` was not run again (it hangs on this PC).
dyst left a comment

Verdict: Comment. Would approve once out of WIP and the farm run is in, because the index keeps the same words main keeps. Every point of BeanBot's review is now fixed in the code, each with a check that fails on the first commit. The fallback is main's own lookup. What is still open is evidence: the in-game A/B, and a measured gain on the number the change targets, which the standards ask for before merge.

For players with VRAM mirrors on (every discrete card), the replay thread spends less time on each write-back's report-word merge: one hash probe per noted word instead of two binary searches, only the fresh words sorted, and no inplace_merge buffer. The cost is up to 1 MB of RAM (1.5 MB while it grows to that), freed at the forget. Without mirrors (the Steam Deck, integrated GPUs) memory_cpu_owned returns early and nothing changes.

Reviewed: ecd1b8a4 against f1f2dc5b (the merge base). Read in full: the WordIndex, MergeTimes, sorted_merge, cpu_words_merge, memory_cpu_owned and cut_cpu_words region of gpu/vk/vk_memory.cpp, the new log block in memory_end_submission, gpu/vk/vk_new.h, tests/test_report_words.py, tests/mirror_bookkeeping_test.cpp and the switches.def row. BeanBot's commit da36759f is no longer on the forge, so its points were judged against the current code and the reply. Nothing run (a code review). It merges cleanly onto current main (9dd41326) in a git merge-tree.
Fixed in this review: nothing.
Checked and fine:

  • L1: add probes before it grows, so a batch of known words never grows the table. check_known_at_boundary fills it to exactly half and would fail without the lookup that comes first.
  • L2: resize asks for the table with new (std::nothrow) inside a NewNothrow scope (the same pattern as the staging block at :1174), and leaves the index as it was on a refusal. In the fallback, [fresh, i) holds only known words and repeats of fresh words, so erasing it before the sort and binary searches keeps every new word. The fresh words already added to the index are not in the sets yet, so they still come out fresh. check_refused covers a refusal in mid-batch and a refused first table, through an operator new that stops the run as the new_handler does.
  • L3: the forget frees the table. The next merge builds one sized to the sets (32 KB when they are empty), so a high-water table is never swept. kMax (1 MB, 65,536 words) means the merge just before a forget falls back to main's path instead of doubling to 2 MB. check_clear's biggest <= 1 MB would catch the cap being removed.
  • The n == sizes invariant: nothing but cpu_words_merge and the forget changes the two sets (cut_cpu_words only reads them), so the steady state never rebuilds. Sets past 65,536 (a cut_cpu_words merge before the next memory_cpu_owned forgets) fail build at the size check before any allocation and take main's path.
  • sorted_merge from the back is correct, with ties, an empty into and an empty batch. Its source and destination are different vectors at both call sites.
  • resize's swap-and-reinsert, probe with cap == 0 guarded, and kEmpty can never be an 8-aligned word.
  • L4: RUN_ALL_ARGS = ["--cxx", "{cxx}"], with CXX and then the PATH order when run on its own.
  • L5: the merge times are counted only when RX_VK_LOG_WRITEBACK is set, a steady_clock pair a merge. The switch row describes the new line.
  • L7 and L8: the Summary and Risks now say what BeanBot asked for.
  • No switch is right here: this changes a data structure, the sets come out the same, and a revert is the way back. Nothing is shipped turned off.

Suggestions (the author may take or leave)

  • vk_memory.cpp:7381: logf runs inside the cpu_words_mu scope. memory_cpu_owned takes that lock on the guest-CPU side, so a slow log write stalls a report write. Build m (and copy cap) under the lock, and call logf after it. This only happens with diagnostics on.

Questions

  • How will Measurements show the gain against main? The targeted number (merge time) is logged only on this branch, and ~1% of a replay-thread core is unlikely to show in p99 frame time beyond the run-to-run spread. Two ways: a replay-thread profile of both sides (where the 0.7 and 0.4 % came from), or the micro-benchmark from 92fa6e19 rerun with main's and this head's cpu_words_merge. Either would give the "number the change targets" column.

Testing: the author ran the fixture and --changed checks on Windows (llvm-mingw clang), with the failures matched against main. CI is pending (blocked on approval). No in-game run yet. The farm request (comment 63660) is waiting for a BigBean. Still missing: the in-game A/B on Tier 1 discrete cards (Windows and Linux, NVIDIA and AMD), the merge-time line from a branch run, and the Linux build, full suite and lint (BeanBot's L6). These hold the merge, not this verdict.
Overlaps and merge order: #2029 adds retired_held right after cut_cpu_words (context only, no shared lines). The other PRs that touch vk_memory.cpp (#2052, #2051, #2028, #2027, #2002, #759) change other parts of the file. No duplicate. Any order works. The switches.def row will need the usual rebase.

**Verdict: Comment.** Would approve once out of WIP and the farm run is in, because the index keeps the same words main keeps. Every point of BeanBot's review is now fixed in the code, each with a check that fails on the first commit. The fallback is main's own lookup. What is still open is evidence: the in-game A/B, and a measured gain on the number the change targets, which the standards ask for before merge. For players with VRAM mirrors on (every discrete card), the replay thread spends less time on each write-back's report-word merge: one hash probe per noted word instead of two binary searches, only the fresh words sorted, and no `inplace_merge` buffer. The cost is up to 1 MB of RAM (1.5 MB while it grows to that), freed at the forget. Without mirrors (the Steam Deck, integrated GPUs) `memory_cpu_owned` returns early and nothing changes. **Reviewed:** ecd1b8a4 against f1f2dc5b (the merge base). Read in full: the `WordIndex`, `MergeTimes`, `sorted_merge`, `cpu_words_merge`, `memory_cpu_owned` and `cut_cpu_words` region of `gpu/vk/vk_memory.cpp`, the new log block in `memory_end_submission`, `gpu/vk/vk_new.h`, `tests/test_report_words.py`, `tests/mirror_bookkeeping_test.cpp` and the `switches.def` row. BeanBot's commit da36759f is no longer on the forge, so its points were judged against the current code and the reply. Nothing run (a code review). It merges cleanly onto current main (9dd41326) in a `git merge-tree`. **Fixed in this review:** nothing. **Checked and fine:** - L1: `add` probes before it grows, so a batch of known words never grows the table. `check_known_at_boundary` fills it to exactly half and would fail without the lookup that comes first. - L2: `resize` asks for the table with `new (std::nothrow)` inside a `NewNothrow` scope (the same pattern as the staging block at :1174), and leaves the index as it was on a refusal. In the fallback, `[fresh, i)` holds only known words and repeats of fresh words, so erasing it before the sort and binary searches keeps every new word. The fresh words already added to the index are not in the sets yet, so they still come out fresh. `check_refused` covers a refusal in mid-batch and a refused first table, through an `operator new` that stops the run as the new_handler does. - L3: the forget frees the table. The next merge builds one sized to the sets (32 KB when they are empty), so a high-water table is never swept. `kMax` (1 MB, 65,536 words) means the merge just before a forget falls back to main's path instead of doubling to 2 MB. `check_clear`'s `biggest <= 1 MB` would catch the cap being removed. - The `n == sizes` invariant: nothing but `cpu_words_merge` and the forget changes the two sets (`cut_cpu_words` only reads them), so the steady state never rebuilds. Sets past 65,536 (a `cut_cpu_words` merge before the next `memory_cpu_owned` forgets) fail `build` at the size check before any allocation and take main's path. - `sorted_merge` from the back is correct, with ties, an empty `into` and an empty batch. Its source and destination are different vectors at both call sites. - `resize`'s swap-and-reinsert, `probe` with `cap == 0` guarded, and `kEmpty` can never be an 8-aligned word. - L4: `RUN_ALL_ARGS = ["--cxx", "{cxx}"]`, with `CXX` and then the PATH order when run on its own. - L5: the merge times are counted only when `RX_VK_LOG_WRITEBACK` is set, a `steady_clock` pair a merge. The switch row describes the new line. - L7 and L8: the Summary and Risks now say what BeanBot asked for. - No switch is right here: this changes a data structure, the sets come out the same, and a revert is the way back. Nothing is shipped turned off. **Suggestions** (the author may take or leave) - `vk_memory.cpp:7381`: `logf` runs inside the `cpu_words_mu` scope. `memory_cpu_owned` takes that lock on the guest-CPU side, so a slow log write stalls a report write. Build `m` (and copy `cap`) under the lock, and call `logf` after it. This only happens with diagnostics on. **Questions** - How will Measurements show the gain against main? The targeted number (merge time) is logged only on this branch, and ~1% of a replay-thread core is unlikely to show in p99 frame time beyond the run-to-run spread. Two ways: a replay-thread profile of both sides (where the 0.7 and 0.4 % came from), or the micro-benchmark from 92fa6e19 rerun with main's and this head's `cpu_words_merge`. Either would give the "number the change targets" column. **Testing:** the author ran the fixture and `--changed` checks on Windows (llvm-mingw clang), with the failures matched against main. CI is pending (blocked on approval). No in-game run yet. The farm request (comment 63660) is waiting for a BigBean. Still missing: the in-game A/B on Tier 1 discrete cards (Windows and Linux, NVIDIA and AMD), the merge-time line from a branch run, and the Linux build, full suite and lint (BeanBot's L6). These hold the merge, not this verdict. **Overlaps and merge order:** https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2029 adds `retired_held` right after `cut_cpu_words` (context only, no shared lines). The other PRs that touch `vk_memory.cpp` (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2052, https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2051, https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2028, https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2027, https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2002, https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/759) change other parts of the file. No duplicate. Any order works. The `switches.def` row will need the usual rebase.
@ -7291,2 +7378,4 @@
logf("vk: write-back a submission, by pool:%s", s.c_str());
by_pool.clear();
{ // (the report words' merges since the last line, by kind: what a frame-time outlier there cost)
std::lock_guard lk(cpu_words_mu);
Member

Suggestion: logf runs while cpu_words_mu is held, and memory_cpu_owned (the guest-CPU side) waits on that lock. Build the string (and copy cap) under the lock, then log after it. Diagnostics only.

Suggestion: logf runs while cpu_words_mu is held, and memory_cpu_owned (the guest-CPU side) waits on that lock. Build the string (and copy cap) under the lock, then log after it. Diagnostics only.
Member
Beanstalk test farm · an earlier run: commit ecd1b8a (the newer results are in a comment below)

Commit ecd1b8a · approved by dyst (👍 on siantm's request) (reviewed) · dashboard

⚠️ Note: The measurement is stationary after a short scripted walk; the farm cannot drive gameplay concurrently with a measure step, and two pictures cannot rule out intermittent flicker.
⚠️ Note: The 5% p99 tolerance is a fixed approximation: the plan cannot set its threshold from the observed run-to-run spread.
⚠️ Note: The Deck and integrated GPUs may not exercise the changed merge because VRAM mirrors are disabled.

Started at 10:07 UTC.

Estimate: done in about 2 h 30 min, from the queue and the testers online now; some jobs can't start yet.

Target Result Reports Frame time p99 (ms), main → PR VRAM peak (MB) Crashes
linux+nvidia 🔄 running 0 of 1 — — —
linux+amd+radv ❌ fail (an outlier) 2 1 2 25.7 → 29.3 (+14%) — none
windows+amd 🔄 running 0 of 1 — — —
windows+intel ⏳ queued 0 of 1 — — —
steamdeck ⏳ queued 0 of 1 — — —

Why it failed

  • linux+amd+radv: kokiri-forest screenshot.max_diff: 0.2 → 0.8; limit 0.0
  • linux+amd+radv: kokiri-forest screenshot.max_diff: 0.1 → 0.8; limit 0.0
  • linux+amd+radv: kokiri-forest forest.frametime_p99_ms.max_delta_pct: 32.9 → 40.2 (+22.3%); limit 5.0
What was tested

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

On five requested hardware targets, main and the PR each run twice in Kokiri Forest, with a one-minute warm-up and three-minute measurement per run. Pictures, crashes, FATAL logs and frame-time p99 are compared; a picture mismatch, crash, FATAL line or p99 regression over 5% fails. Each tester spends about 36 minutes on game runs; Windows Intel will wait for a matching tester. No tester online now matches windows+intel: that target waits for one.

  • Where: linux+nvidia (1-2 reports), linux+amd+radv (1-2 reports), windows+amd (1-2 reports), windows+intel (1-2 reports), steamdeck (1-2 reports).
  • kokiri-forest: from the repository's save kokiri-start, then teleport to Kokiri Forest, move the stick, take the picture forest-start to compare with main, measure forest for 3 min (after 60 s warm-up), take the picture forest-end to compare with main; 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 0%; or frame time (p99) is more than 5% above main; or forbidden log lines is above 0.
  • Time: about 36 min of game runs per tester (4 game starts), plus the two builds.
Measurements on `linux+amd+radv`, for the PR description

Verdict: fail on linux+amd+radv (2 reports): kokiri-forest screenshot.max_diff; kokiri-forest forest.frametime_p99_ms.max_delta_pct (+22.3%) failed.

Hardware: 1: linux+amd+radv+dgpu AMD Radeon RX 9070 (RADV GFX1201), 26.0.8 AMD Ryzen 7 5800X 8-Core Processor, 32 GB RAM; 2: linux+amd+radv+dgpu AMD Radeon RX 580 Series (RADV POLARIS10), 26.2.7 AMD Ryzen 5 5500F 6-Core Processor, 32 GB RAM
Scene: kokiri-forest, 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); kokiri-forest: 2 game starts a side, forest 180 s after 60 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 @ f1f2dc5 After: this PR @ ecd1b8a
kokiri-forest · forest · frame time (p99) (ms) 25.7 29.3 (+14%)
kokiri-forest · forbidden log lines 0.0 0.0

Flags and settings

None: the plan varied no setting, switch or build option.

As Markdown for the PR description:

## Measurements

**Verdict:** fail on linux+amd+radv (2 reports): `kokiri-forest screenshot.max_diff`; `kokiri-forest forest.frametime_p99_ms.max_delta_pct (+22.3%)` failed.

Hardware: 1: linux+amd+radv+dgpu `AMD Radeon RX 9070 (RADV GFX1201), 26.0.8` `AMD Ryzen 7 5800X 8-Core Processor, 32 GB RAM`; 2: linux+amd+radv+dgpu `AMD Radeon RX 580 Series (RADV POLARIS10), 26.2.7` `AMD Ryzen 5 5500F 6-Core Processor, 32 GB RAM`  
Scene: kokiri-forest, 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); kokiri-forest: 2 game starts a side, forest 180 s after 60 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 @ f1f2dc5 | After: this PR @ ecd1b8a |
|---|---|---|
| kokiri-forest · forest · frame time (p99) (ms) | 25.7 | 29.3 (+14%) |
| kokiri-forest · forbidden log lines | 0.0 | 0.0 |

**Flags and settings**

None: the plan varied no setting, switch or build option.
The testers' hardware
Target Report Ran on
linux+amd+radv 1 linux+amd+radv+dgpu AMD Radeon RX 9070 (RADV GFX1201), 26.0.8 AMD Ryzen 7 5800X 8-Core Processor, 32 GB RAM
linux+amd+radv 2 linux+amd+radv+dgpu AMD Radeon RX 580 Series (RADV POLARIS10), 26.2.7 AMD Ryzen 5 5500F 6-Core Processor, 32 GB RAM
<!-- beanstalk:previous --> <details><summary>Beanstalk test farm · an earlier run: commit <code>ecd1b8a</code> (the newer results are in a comment below)</summary> Commit `ecd1b8a` · approved by dyst (👍 on siantm's request) (reviewed) · [dashboard](https://beanstalk.magicbean.dev/prs/1993) ⚠️ **Note:** The measurement is stationary after a short scripted walk; the farm cannot drive gameplay concurrently with a measure step, and two pictures cannot rule out intermittent flicker. ⚠️ **Note:** The 5% p99 tolerance is a fixed approximation: the plan cannot set its threshold from the observed run-to-run spread. ⚠️ **Note:** The Deck and integrated GPUs may not exercise the changed merge because VRAM mirrors are disabled. Started at 10:07 UTC. **Estimate:** done in about 2 h 30 min, from the queue and the testers online now; some jobs can't start yet. | Target | Result | Reports | Frame time p99 (ms), main → PR | VRAM peak (MB) | Crashes | | --- | --- | --- | --- | --- | --- | | `linux+nvidia` | 🔄 running | 0 of 1 | — | — | — | | `linux+amd+radv` | ❌ fail (an outlier) | 2 [1](https://beanstalk.magicbean.dev/reports/rp_9a8e4a8936a2733b) [2](https://beanstalk.magicbean.dev/reports/rp_8fe1f5398fa836a9) | 25.7 → 29.3 (+14%) | — | none | | `windows+amd` | 🔄 running | 0 of 1 | — | — | — | | `windows+intel` | ⏳ queued | 0 of 1 | — | — | — | | `steamdeck` | ⏳ queued | 0 of 1 | — | — | — | **Why it failed** - `linux+amd+radv`: `kokiri-forest` `screenshot.max_diff`: `0.2 → 0.8; limit 0.0` - `linux+amd+radv`: `kokiri-forest` `screenshot.max_diff`: `0.1 → 0.8; limit 0.0` - `linux+amd+radv`: `kokiri-forest` `forest.frametime_p99_ms.max_delta_pct`: `32.9 → 40.2 (+22.3%); limit 5.0` <details><summary>What was tested</summary> **What will be tested** · AI plan (`gpt-6.1-terra`) On five requested hardware targets, main and the PR each run twice in Kokiri Forest, with a one-minute warm-up and three-minute measurement per run. Pictures, crashes, FATAL logs and frame-time p99 are compared; a picture mismatch, crash, FATAL line or p99 regression over 5% fails. Each tester spends about 36 minutes on game runs; Windows Intel will wait for a matching tester. No tester online now matches windows+intel: that target waits for one. - **Where:** linux+nvidia (1-2 reports), linux+amd+radv (1-2 reports), windows+amd (1-2 reports), windows+intel (1-2 reports), steamdeck (1-2 reports). - **kokiri-forest:** from the repository's save `kokiri-start`, then teleport to Kokiri Forest, move the stick, take the picture forest-start to compare with main, measure forest for 3 min (after 60 s warm-up), take the picture forest-end to compare with main; 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 0%; or frame time (p99) is more than 5% above main; or forbidden log lines is above 0. - **Time:** about 36 min of game runs per tester (4 game starts), plus the two builds. </details> <details><summary>Measurements on `linux+amd+radv`, for the PR description</summary> **Verdict:** fail on linux+amd+radv (2 reports): `kokiri-forest screenshot.max_diff`; `kokiri-forest forest.frametime_p99_ms.max_delta_pct (+22.3%)` failed. Hardware: 1: linux+amd+radv+dgpu `AMD Radeon RX 9070 (RADV GFX1201), 26.0.8` `AMD Ryzen 7 5800X 8-Core Processor, 32 GB RAM`; 2: linux+amd+radv+dgpu `AMD Radeon RX 580 Series (RADV POLARIS10), 26.2.7` `AMD Ryzen 5 5500F 6-Core Processor, 32 GB RAM` Scene: kokiri-forest, 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); kokiri-forest: 2 game starts a side, forest 180 s after 60 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 @ f1f2dc5 | After: this PR @ ecd1b8a | |---|---|---| | kokiri-forest · forest · frame time (p99) (ms) | 25.7 | 29.3 (+14%) | | kokiri-forest · forbidden log lines | 0.0 | 0.0 | **Flags and settings** None: the plan varied no setting, switch or build option. As Markdown for the PR description: ```markdown ## Measurements **Verdict:** fail on linux+amd+radv (2 reports): `kokiri-forest screenshot.max_diff`; `kokiri-forest forest.frametime_p99_ms.max_delta_pct (+22.3%)` failed. Hardware: 1: linux+amd+radv+dgpu `AMD Radeon RX 9070 (RADV GFX1201), 26.0.8` `AMD Ryzen 7 5800X 8-Core Processor, 32 GB RAM`; 2: linux+amd+radv+dgpu `AMD Radeon RX 580 Series (RADV POLARIS10), 26.2.7` `AMD Ryzen 5 5500F 6-Core Processor, 32 GB RAM` Scene: kokiri-forest, 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); kokiri-forest: 2 game starts a side, forest 180 s after 60 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 @ f1f2dc5 | After: this PR @ ecd1b8a | |---|---|---| | kokiri-forest · forest · frame time (p99) (ms) | 25.7 | 29.3 (+14%) | | kokiri-forest · forbidden log lines | 0.0 | 0.0 | **Flags and settings** None: the plan varied no setting, switch or build option. ``` </details> <details><summary>The testers' hardware</summary> | Target | Report | Ran on | | --- | --- | --- | | `linux+amd+radv` | [1](https://beanstalk.magicbean.dev/reports/rp_9a8e4a8936a2733b) | linux+amd+radv+dgpu `AMD Radeon RX 9070 (RADV GFX1201), 26.0.8` `AMD Ryzen 7 5800X 8-Core Processor, 32 GB RAM` | | `linux+amd+radv` | [2](https://beanstalk.magicbean.dev/reports/rp_8fe1f5398fa836a9) | linux+amd+radv+dgpu `AMD Radeon RX 580 Series (RADV POLARIS10), 26.2.7` `AMD Ryzen 5 5500F 6-Core Processor, 32 GB RAM` | </details> </details>
siantm force-pushed perf/vk-report-words from ecd1b8a499
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 5s
beanstalk/approval approved by dyst (reviewed)
beanstalk/linux+nvidia 0/1 pass, 1 running, 1 queued
beanstalk/linux+amd+radv 2/1 fail
beanstalk/windows+amd 0/1 pass, 2 running, 0 queued
beanstalk/windows+intel 0/1 pass, 0 running, 2 queued
beanstalk/steamdeck 0/1 pass, 0 running, 2 queued
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
to 4422e0fd49
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
PR description / Description follows the template (pull_request_target) Successful in 4s
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
2026-11-21 11:08:37 +00:00
Compare
Member

Beanstalk test farm

Commit 4422e0f · 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 `4422e0f` · approved by nobody yet · [dashboard](https://beanstalk.magicbean.dev/prs/1993) A member of `BigBeans` can review this commit and comment `@Beanstalk` to test it.
Author
Contributor

Thanks for the review (#1993 (comment)). The branch is rebased onto main @ 9dd41326 without a conflict (the three earlier commits unchanged, now 4c15eaeb, e3e4fca1, 11d9c417), with one commit on top, 4422e0fd.

  • vk_memory.cpp:7381, logf under cpu_words_mu (#1993 (comment)): taken. The merge line is now built and cap copied under the lock, and logf runs after the lock is let go (4422e0fd). The line's content is unchanged.
  • The question of how Measurements will show the gain against main: pending. The in-game run is pending too. The head moved from ecd1b8a4, which the farm run started on.

Checked at 4422e0fd on main 9dd41326 in light job fb-dy1993-1: tests/test_report_words.py and tests/test_mirror_bookkeeping.py pass, and vk_memory.cpp compiles (syntax) with the game build's own command. The --changed run was not repeated on this main. The description's Summary, Testing and Measurements are updated.

Thanks for the review (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1993#issuecomment-65744). The branch is rebased onto main @ 9dd41326 without a conflict (the three earlier commits unchanged, now 4c15eaeb, e3e4fca1, 11d9c417), with one commit on top, 4422e0fd. - **`vk_memory.cpp:7381`, `logf` under `cpu_words_mu`** (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1993#issuecomment-65743): taken. The merge line is now built and `cap` copied under the lock, and `logf` runs after the lock is let go (4422e0fd). The line's content is unchanged. - **The question of how Measurements will show the gain against main**: pending. The in-game run is pending too. The head moved from ecd1b8a4, which the farm run started on. Checked at 4422e0fd on main 9dd41326 in light job `fb-dy1993-1`: `tests/test_report_words.py` and `tests/test_mirror_bookkeeping.py` pass, and `vk_memory.cpp` compiles (syntax) with the game build's own command. The `--changed` run was not repeated on this main. The description's Summary, Testing and Measurements are updated.
Author
Contributor

@Beanstalk This changes how the Vulkan replay merges the report words the CPU owns at write-backs (gpu/vk): a hash index answers whether a word is kept already and the fresh words are merged in place, with no allocation; the words kept are the same as before. It acts where VRAM mirrors are on (discrete GPUs). No switch: a revert gives back main's code. Please play Kokiri Forest and Hyrule Field, two minutes each after a minute's warm-up, the PR against main on the same PC, with RX_VK_LOG_WRITEBACK=1 on both sides and a picture in each scene compared with main's, on Linux with NVIDIA, Linux with AMD (RADV), Windows with AMD and Windows with NVIDIA. The same picture as main (no stale or flickering values), no crash and no FATAL line; frame time p99 equal to main's, within the run-to-run spread; on the PR's side the "report words' merges" line every 600 write-back submissions.

@Beanstalk This changes how the Vulkan replay merges the report words the CPU owns at write-backs (gpu/vk): a hash index answers whether a word is kept already and the fresh words are merged in place, with no allocation; the words kept are the same as before. It acts where VRAM mirrors are on (discrete GPUs). No switch: a revert gives back main's code. Please play Kokiri Forest and Hyrule Field, two minutes each after a minute's warm-up, the PR against main on the same PC, with RX_VK_LOG_WRITEBACK=1 on both sides and a picture in each scene compared with main's, on Linux with NVIDIA, Linux with AMD (RADV), Windows with AMD and Windows with NVIDIA. The same picture as main (no stale or flickering values), no crash and no FATAL line; frame time p99 equal to main's, within the run-to-run spread; on the PR's side the "report words' merges" line every 600 write-back submissions.
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

Re the Test Farm's Linux RADV result on ecd1b8a4 (65805): both sides were built on this PR's base f1f2dc5b. The pictures show the same view; the difference is the forest's drifting mist, present in both main frames and absent in the PR's (the same RX 9070 tester shows it the other way round on #1996 with that PR's switch at 0, which is main's code), so it is the scene varying rather than this change. The p99 gap on the RX 580 is inside main's own spread on that tester (main's two runs 23.4 and 42.3 ms); one figure is not explained yet: its median, +0.7 ms in both PR runs (two runs a side). A differential check of this PR's word index against main's sets (4 seeds × 3,000,000 rounds, about 2.4 million cuts and 152 forgets) found the two identical every time. A repeat run on the RX 580 with the picture at an input-free point and main against itself, four runs a side, is asked to confirm or drop the median figure; until then it is pending.

Re the Test Farm's Linux RADV result on ecd1b8a4 ([65805](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1993#issuecomment-65805)): both sides were built on this PR's base f1f2dc5b. The pictures show the same view; the difference is the forest's drifting mist, present in both main frames and absent in the PR's (the same RX 9070 tester shows it the other way round on #1996 with that PR's switch at 0, which is main's code), so it is the scene varying rather than this change. The p99 gap on the RX 580 is inside main's own spread on that tester (main's two runs 23.4 and 42.3 ms); one figure is not explained yet: its median, +0.7 ms in both PR runs (two runs a side). A differential check of this PR's word index against main's sets (4 seeds × 3,000,000 rounds, about 2.4 million cuts and 152 forgets) found the two identical every time. A repeat run on the RX 580 with the picture at an input-free point and main against itself, four runs a side, is asked to confirm or drop the median figure; until then it is pending.
Author
Contributor

@Beanstalk This replaces my request 66243 on this head (please do not run that one) with one targeted run. It changes how the Vulkan replay merges the report words the CPU owns at write-backs (gpu/vk); no switch, a revert gives back main's code. An earlier run on an older head showed a picture difference and a p50 about 0.7 ms higher on Linux with AMD; this run is to confirm or drop that. Please run on the tester manasuazo (Linux, RADV, RX 580; tag tester-manasuazo) if it can be chosen, else on Linux with AMD (RADV): Kokiri Forest from its start save; take the picture at a fixed point with no input, right after the save settles, and one main-against-itself picture; then measure three minutes after a minute's warm-up, the PR against main on the same PC in ABBA order twice (four runs a side). Please report the picture difference beside main-against-itself, and p50 and p99 frame times beside main's own run-to-run spread. No crash and no FATAL line.

@Beanstalk This replaces my request 66243 on this head (please do not run that one) with one targeted run. It changes how the Vulkan replay merges the report words the CPU owns at write-backs (gpu/vk); no switch, a revert gives back main's code. An earlier run on an older head showed a picture difference and a p50 about 0.7 ms higher on Linux with AMD; this run is to confirm or drop that. Please run on the tester manasuazo (Linux, RADV, RX 580; tag tester-manasuazo) if it can be chosen, else on Linux with AMD (RADV): Kokiri Forest from its start save; take the picture at a fixed point with no input, right after the save settles, and one main-against-itself picture; then measure three minutes after a minute's warm-up, the PR against main on the same PC in ABBA order twice (four runs a side). Please report the picture difference beside main-against-itself, and p50 and p99 frame times beside main's own run-to-run spread. No crash and no FATAL line.
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.
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
PR description / Description follows the template (pull_request_target) Successful in 4s
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
This pull request is marked as a work in progress.
Some workflows are waiting to be reviewed.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'perf/vk-report-words:siantm-perf/vk-report-words'
git switch 'siantm-perf/vk-report-words'
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!1993
No description provided.