perf(vk): with the shader preparation off, kept programs are indexed at start and load at create: ~70 % fewer draws left out (dev builds) #2193

Merged
HumanBean merged 4 commits from Jer9/Longshot:perf/vk-saveload-warm-cache into main 2026-11-22 17:58:43 +00:00
Contributor

Summary

With the shader preparation off (RX_VK_PRECOMPILE=0: the default of development builds; release builds always prepare, and players have no setting that turns it off), loading a save leaves longshot_programs.bin unindexed and pcache uninitialized during pipeline_cache_play(). Every program the game creates is then read at its first draw, and its draws are left out meanwhile: 2,740–2,774 draws left out on a warm-cache save load (6,792 across a 3-zone tour) and 538–549 synchronous program loads on the 860M, about 187k draws left out a run on an RTX 3090.

Three issues caused it:

  1. pipeline_cache_play() ran before pcache_init(), leaving pcache as VK_NULL_HANDLE and bypassing play_cache_begin() (play-cache tracking off whenever precompile_run() had not initialized pcache first; census counters stayed 0/0/0).
  2. programs_index() only ran inside precompile_run(). With RX_VK_PRECOMPILE=0, kept program records in longshot_programs.bin were never indexed, so none was loaded ahead of its first draw.
  3. A longshot_load_start.txt left by an earlier run (with the preparation on) switched the start to loading programs before the title, which only the preparation does: with it off, nothing was loaded before the title and the index was skipped too.

This change:

  • Calls pcache_init() before play_cache_begin() in pipeline_cache_play().
  • Runs index-only programs_index() in pipeline_cache_play() when the preparation is off, RX_VK_NO_PROGRAM_CACHE is not set, and kept program records exist (~2.1 ms at start), guards programs_index() as one-shot via index_ready, and guards programs_frames_note() and load_wait_note() so RX_VK_PRECOMPILE=0 never writes load-start markers.
  • Leaves longshot_load_start.txt aside when the preparation is off (load_default::choose's prepared): loads at create, since start would load nothing.

Split out: the non-compiling cache probe in graphics_pipeline() (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT before a play pipeline's background build) was part of this PR until 9d2f7b54 and goes to a change of its own. With the preparation on it never ran in testing (no pipeline was made in play); with it off it found about 13 % of play's pipelines in the driver's cache on an RTX 3090, at an unmeasured driver call for each of the rest, on every Vulkan 1.3 GPU.

Who it helps: development builds, testers and dev.py runtimes, whose runs then look closer to players'. Players are unaffected: their preparation builds this index.

Read first: pipeline_cache_play in gpu/vk/vk_draw.cpp, programs_index, load_wait_note, programs_frames_note and programs_load_decide in gpu/vk/vk_programs.cpp, choose in gpu/vk/load_default.h, and tests/test_saveload_warm_cache.py.

Testing

Tested: Windows 11, AMD Radeon 860M (Adrenalin 26.10.1 LLPC), handheld_profile=1 (1600x1000, 67% render scale, sharpness=80, vsync=0, amd_anti-lag_2=1, threaded_rendering=0).

  • Standalone in-game save load (Kokiri Forest, warm cache, RX_VK_PRECOMPILE=0, 3 interleaved rounds + 12 s settle) plus 1 cold-cache run: verified 0 draws left out, 0 pipeline waits, 0 synchronous program loads, 0 VK_ERROR_DEVICE_LOST, and clean 3D transition in a side-by-side Dev FPS counter capture (starting 0.50 s before Load click; timer starts on Load click).

  • Standalone 3-zone traversal tour (Kokiri Forest, Hyrule Field, Market; 3 interleaved rounds): verified -95.0% dropped draws, +15.5% 1% low lift, flat steady VRAM, and 0 VK_ERROR_DEVICE_LOST.

  • Game-free regression test tests/test_saveload_warm_cache.py (including RX_VK_NO_PROGRAM_CACHE=1 skipping indexing and a behavioral C++ check calling programs_index() twice to verify the index_ready one-shot guard): fails on main @ a2dc5385 and passes on b6e5f76c (rebased cleanly onto main @ a2dc5385).

  • Targeted checks on b6e5f76c: test_saveload_warm_cache.py, test_pipeline_play_cache.py, test_quick_pipelines.py, test_same_draw.py, test_pipeline_share.py, test_draw_side_effects.py, test_jobs_wait_runs_queued.py, test_load_default.py, test_program_load_wait.py, test_note_refs_once.py, test_fallback_loaded.py, test_thinlto_tls.py, test_log_levels.py, test_vk_braces.py, test_utf8_paths.py, test_doc_anchors.py, test_program_stamp_knobs.py, test_cpp_preflight.py, and scripts/check_third_party.py (19/19) all pass. Pre-existing / host caveats: tests/test_switch_table.py fails identically on main (RX_VK_GRASS_DISTANCE ordering; this PR does not touch switches.def), and tests/test_job_queue.py is excluded on Windows shared consoles.

  • Linux, RTX 3090 (NVIDIA proprietary), by HumanBean on e4ad718b (with the probe), RX_VK_PRECOMPILE=0, loads at create, 2 interleaved runs a side: draws left out 200,436 / 174,720 -> 60,396 / 60,000 a run, worst save-load frame 1,744 / 1,737 -> 1,486 / 1,441 ms, 2,211 programs queued at create (0 on main). At the default settings, no difference past the spread and no pipeline made in play on either side. Details: #2193 (comment)

  • 9d2f7b54 (the probe split out, the marker rule): built for Linux (clang); not yet run in the game; its checks not yet run.

Still to test:

  • 9d2f7b54 in the game with RX_VK_PRECOMPILE=0, with and without a leftover longshot_load_start.txt: the index built and programs queued at create in both (by hand)
  • The Test Farm's Linux RADV picture failure on b6e5f76c (RX 9070, RX 6600, RX_VK_GPL=1, RX_VK_PRECOMPILE=0): pictures 0.82–1.0 apart from main's; whether main's pictures are the ones missing geometry (@Beanstalk linux-radv)
  • The checks at 9d2f7b54, test_saveload_warm_cache.py and test_load_default.py among them (by hand, or CI on the push)

Measurements

Verdict: (measured with the cache probe in, which this PR no longer has; the probe served 3 of the save load's pipelines here and about 13 % of play's on the RTX 3090, so most of the gain is the index's) Standalone on main @ 9e10f6f7, eliminates 100% of warm-cache save-load dropped draws (2,773 -> 0) and synchronous program loads (539 -> 0, 185.2 ms -> 0.0 ms), cuts 3-zone traversal dropped draws by 95.0% (6,792 -> 339), and lifts 3-zone traversal 1% lows by +15.5% (21.71 -> 25.07 FPS, p99 46.06 -> 39.89 ms) with no cold-cache regression.

Setup: Windows 11 (26200), AMD Ryzen AI 7 350, AMD Radeon 860M (RDNA 3.5, Adrenalin 26.10.1 LLPC); handheld_profile=1 (1600x1000, 67% render scale, sharpness=80, vsync=0, amd_anti-lag_2=1, threaded_rendering=0), RX_VK_PRECOMPILE=0; Kokiri Forest warm-cache save load (12 s settle) and 3-zone traversal (Kokiri Forest, Hyrule Field, Market), 3 interleaved unprofiled runs each, median [min, max].

Rebase note: Branch is rebased onto main @ a2dc5385 (#2174 simulated-turf floor + #1722 castle-gate save); measurements below remain from main @ 9e10f6f7 because #2174 did not affect our Kokiri Forest -> Hyrule Field -> Market tour (Hyrule Field max_ms on main @ 9e10f6f7 was 30.94 / 71.01 / 72.49 ms, gt_50ms 0 / 4 / 4, zero 250 ms turf stalls).

Before: main @ 9e10f6f7 After: this PR @ e4ad718b Delta
Draws left out (save load) 2,773 [2,740, 2,774] 0 [0, 0] -2,773 (-100.0%)
Draws waiting for pipeline (save load) 3 [3, 3] 0 [0, 0] -3 (-100.0%)
Pipeline wait time (save load) 0.4 ms [0.3, 0.4] 0.0 ms [0.0, 0.0] -0.4 ms (-100.0%)
Synchronous program loads (save load) 539 [538, 549] 0 [0, 0] -539 (-100.0%)
Program load time (save load) 185.2 ms [177.1, 186.6] 0.0 ms [0.0, 0.0] -185.2 ms (-100.0%)
Driver cache hits (from_driver, save load) 0 [0, 0] 3 [3, 3] +3
Startup index cost (load at create) — 2.1 ms +2.1 ms one-time
Max frame time (save load) 2,422.83 ms [2,384.08, 2,638.16] 2,442.65 ms [2,401.26, 2,490.77] +19.82 ms (+0.8%, ASTC-bound)
Steady VRAM (save load, 12 s settle) 3,062 MB [3,062, 3,271] 3,271 MB [3,174, 3,271] +209 MB (within spread)
Traversal mean FPS (3 zones) 54.79 [46.30, 56.64] 54.37 [53.86, 57.21] -0.42 FPS (-0.8%)
Traversal median frame time (3 zones) 16.98 ms [16.63, 19.46] 16.99 ms [16.42, 17.20] +0.01 ms (+0.1%)
Traversal p99 frame time / 1% low FPS 46.06 ms [37.78, 75.76] (21.71 [13.20, 26.47] FPS) 39.89 ms [35.49, 44.61] (25.07 [22.42, 28.17] FPS) -6.17 ms (+3.36 FPS / +15.5%)
Traversal draws left out (3 zones) 6,792 [5,982, 10,194] 339 [234, 1,259] -6,453 (-95.0%)
Traversal frames >= 50 ms (3 zones) 32 [20, 69] 26 [21, 28] -6 (-18.8%)
Traversal steady / peak VRAM 4,660 MB / 4,756 MB 4,628 MB / 4,770 MB -32 MB / +14 MB

Cold cache (1 run each, empty cache, RX_VK_PRECOMPILE=0):

  • Draws left out: 2,747 -> 2,172 (-20.9%)
  • Pipeline waits: 440 (2,779.0 ms) -> 429 (2,738.0 ms)
  • Driver / start cache hits (from_driver / from_start): 0 / 0 -> 469 / 246
  • Max frame time (save load): 2,709.9 ms -> 2,706.8 ms (-3.1 ms, no regression)
  • Steady VRAM: 2,998 MB -> 3,062 MB

Matched headless Dev FPS counter capture (HOS_HEADLESS=1, RX_VK_SHOT_MENU=1, RX_VK_SHOT_EVERY=3, 1 run each, timed from Load button click with 0.50 s pre-roll):

  • Before (main @ 9e10f6f7): 2,731 draws left out, 536 program loads (204.0 ms), 1st 3D: 13.59 s
  • After (this PR @ e4ad718b): 0 draws left out, 0 program loads (0.0 ms), 1st 3D: 12.74 s (-0.85 s)

Raw longshot_log.txt lines (Round 1 save load and Round 1 traversal):

# Before: main @ 9e10f6f7 (save load R1)
[hos host] vk: program census (close): ... in play: 549 program records loaded (186.6 ms), 639 new graphics pipelines, pipelines from the driver's cache 0, from the start's cache 0, compiled 0; 2774 draws and dispatches left out, 3 waits (0.4 ms)
[hos Presentation Thread] vk: VRAM: 3271 MB used of 12212 MB allowed (261 MB of it free in the blocks); textures 2551 MB (budget 4096 MB), 1224 textures
[hos Presentation Thread] vk: status: 600 frames, the slowest 2384.1 ms; VRAM 3.2 of 11.9 GB

# After: this PR @ e4ad718b (save load R1)
[hos host] vk: programs: load at create: 2284 notes of 1499 programs indexed, 4 type signatures, 3309 compute programs listed, in 2.1 ms (1645 kept program keys); 2 workers in play, 2 while the game loads; pipelines from: pipeline caches
[hos host] vk: program census (close): ... in play: 0 program records loaded (0.0 ms), 0 new graphics pipelines, pipelines from the driver's cache 3, from the start's cache 0, compiled 0; 0 draws and dispatches left out, 0 waits (0.0 ms)
[hos Presentation Thread] vk: VRAM: 3174 MB used of 12212 MB allowed (192 MB of it free in the blocks); textures 2488 MB (budget 4096 MB), 1264 textures
[hos Presentation Thread] vk: status: 600 frames, the slowest 2490.8 ms; VRAM 3.1 of 11.9 GB

# Before: main @ 9e10f6f7 (3-zone traversal R1)
[hos host] vk: program census (close): ... in play: 1479 program records loaded (765.3 ms), 2131 new graphics pipelines, pipelines from the driver's cache 0, from the start's cache 0, compiled 0; 10194 draws and dispatches left out, 63 waits (1186.8 ms)
[hos Presentation Thread] vk: VRAM: 4628 MB used of 12212 MB allowed (619 MB of it free in the blocks); textures 3748 MB (budget 4096 MB), 3354 textures

# After: this PR @ e4ad718b (3-zone traversal R1)
[hos host] vk: programs: load at create: 2284 notes of 1499 programs indexed, 4 type signatures, 3309 compute programs listed, in 1.9 ms (1645 kept program keys); 2 workers in play, 2 while the game loads; pipelines from: pipeline caches
[hos host] vk: program census (close): ... in play: 0 program records loaded (0.0 ms), 305 new graphics pipelines, pipelines from the driver's cache 15, from the start's cache 18, compiled 280; 1259 draws and dispatches left out, 173 waits (24613.7 ms)
[hos Presentation Thread] vk: VRAM: 4628 MB used of 12212 MB allowed (391 MB of it free in the blocks); textures 3854 MB (budget 4096 MB), 3303 textures

Risks

  • What could break: only runs with the shader preparation off: the index (~2.1 ms at start, one-shot, skipped under RX_VK_NO_PROGRAM_CACHE=1) and loads at create where a marker used to choose start. A PC where loads at create wait seconds (the RX 580 the marker was made for) now loads at create with the preparation off; before, it read every program at its first draw instead, which is no better. With the preparation on (every release build) nothing changes.
  • Turning it off: no new switch; RX_VK_LOAD=start or RX_VK_PRECOMPILE=1, or a revert.
  • After updating: players see no change. Development builds and testers with the preparation off see far fewer draws left out on save loads and first visits. No cache needs clearing.

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 (not yet at 9d2f7b54, whose two checks changed; earlier, on b6e5f76c: 18 targeted Vulkan/program/pipeline/preflight tests + test_saveload_warm_cache.py + check_third_party.py pass on Windows; test_switch_table.py fails identically on main @ 9e10f6f7, and test_job_queue.py is excluded on Windows shared consoles).
  • 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 fix: a game-free test that fails on main and passes here.
  • 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 With the shader preparation off (`RX_VK_PRECOMPILE=0`: the default of development builds; release builds always prepare, and players have no setting that turns it off), loading a save leaves `longshot_programs.bin` unindexed and `pcache` uninitialized during `pipeline_cache_play()`. Every program the game creates is then read at its first draw, and its draws are left out meanwhile: `2,740–2,774` draws left out on a warm-cache save load (`6,792` across a 3-zone tour) and `538–549` synchronous program loads on the 860M, about 187k draws left out a run on an RTX 3090. Three issues caused it: 1. `pipeline_cache_play()` ran before `pcache_init()`, leaving `pcache` as `VK_NULL_HANDLE` and bypassing `play_cache_begin()` (play-cache tracking off whenever `precompile_run()` had not initialized `pcache` first; census counters stayed `0/0/0`). 2. `programs_index()` only ran inside `precompile_run()`. With `RX_VK_PRECOMPILE=0`, kept program records in `longshot_programs.bin` were never indexed, so none was loaded ahead of its first draw. 3. A `longshot_load_start.txt` left by an earlier run (with the preparation on) switched the start to loading programs before the title, which only the preparation does: with it off, nothing was loaded before the title and the index was skipped too. This change: - Calls `pcache_init()` before `play_cache_begin()` in `pipeline_cache_play()`. - Runs index-only `programs_index()` in `pipeline_cache_play()` when the preparation is off, `RX_VK_NO_PROGRAM_CACHE` is not set, and kept program records exist (`~2.1 ms` at start), guards `programs_index()` as one-shot via `index_ready`, and guards `programs_frames_note()` and `load_wait_note()` so `RX_VK_PRECOMPILE=0` never writes load-start markers. - Leaves `longshot_load_start.txt` aside when the preparation is off (`load_default::choose`'s `prepared`): loads at create, since start would load nothing. **Split out:** the non-compiling cache probe in `graphics_pipeline()` (`VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT` before a play pipeline's background build) was part of this PR until 9d2f7b54 and goes to a change of its own. With the preparation on it never ran in testing (no pipeline was made in play); with it off it found about 13 % of play's pipelines in the driver's cache on an RTX 3090, at an unmeasured driver call for each of the rest, on every Vulkan 1.3 GPU. Who it helps: development builds, testers and `dev.py` runtimes, whose runs then look closer to players'. Players are unaffected: their preparation builds this index. Read first: `pipeline_cache_play` in `gpu/vk/vk_draw.cpp`, `programs_index`, `load_wait_note`, `programs_frames_note` and `programs_load_decide` in `gpu/vk/vk_programs.cpp`, `choose` in `gpu/vk/load_default.h`, and `tests/test_saveload_warm_cache.py`. ## Testing **Tested:** Windows 11, AMD Radeon 860M (Adrenalin 26.10.1 LLPC), `handheld_profile=1` (`1600x1000`, `67%` render scale, `sharpness=80`, `vsync=0`, `amd_anti-lag_2=1`, `threaded_rendering=0`). - Standalone in-game save load (Kokiri Forest, warm cache, `RX_VK_PRECOMPILE=0`, 3 interleaved rounds + 12 s settle) plus 1 cold-cache run: verified `0` draws left out, `0` pipeline waits, `0` synchronous program loads, `0` `VK_ERROR_DEVICE_LOST`, and clean 3D transition in a side-by-side Dev FPS counter capture (starting `0.50 s` before Load click; timer starts on Load click). - Standalone 3-zone traversal tour (Kokiri Forest, Hyrule Field, Market; 3 interleaved rounds): verified `-95.0%` dropped draws, `+15.5%` 1% low lift, flat steady VRAM, and `0` `VK_ERROR_DEVICE_LOST`. - Game-free regression test `tests/test_saveload_warm_cache.py` (including `RX_VK_NO_PROGRAM_CACHE=1` skipping indexing and a behavioral C++ check calling `programs_index()` twice to verify the `index_ready` one-shot guard): fails on `main @ a2dc5385` and passes on `b6e5f76c` (rebased cleanly onto `main @ a2dc5385`). - Targeted checks on `b6e5f76c`: `test_saveload_warm_cache.py`, `test_pipeline_play_cache.py`, `test_quick_pipelines.py`, `test_same_draw.py`, `test_pipeline_share.py`, `test_draw_side_effects.py`, `test_jobs_wait_runs_queued.py`, `test_load_default.py`, `test_program_load_wait.py`, `test_note_refs_once.py`, `test_fallback_loaded.py`, `test_thinlto_tls.py`, `test_log_levels.py`, `test_vk_braces.py`, `test_utf8_paths.py`, `test_doc_anchors.py`, `test_program_stamp_knobs.py`, `test_cpp_preflight.py`, and `scripts/check_third_party.py` (19/19) all pass. Pre-existing / host caveats: `tests/test_switch_table.py` fails identically on `main` (`RX_VK_GRASS_DISTANCE` ordering; this PR does not touch `switches.def`), and `tests/test_job_queue.py` is excluded on Windows shared consoles. - Linux, RTX 3090 (NVIDIA proprietary), by HumanBean on e4ad718b (with the probe), `RX_VK_PRECOMPILE=0`, loads at create, 2 interleaved runs a side: draws left out 200,436 / 174,720 -> 60,396 / 60,000 a run, worst save-load frame 1,744 / 1,737 -> 1,486 / 1,441 ms, 2,211 programs queued at create (0 on `main`). At the default settings, no difference past the spread and no pipeline made in play on either side. Details: https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2193#issuecomment-73392 - 9d2f7b54 (the probe split out, the marker rule): built for Linux (clang); not yet run in the game; its checks not yet run. **Still to test:** - 9d2f7b54 in the game with `RX_VK_PRECOMPILE=0`, with and without a leftover `longshot_load_start.txt`: the index built and programs queued at create in both (by hand) - The Test Farm's Linux RADV picture failure on b6e5f76c (RX 9070, RX 6600, `RX_VK_GPL=1`, `RX_VK_PRECOMPILE=0`): pictures 0.82–1.0 apart from `main`'s; whether `main`'s pictures are the ones missing geometry (@Beanstalk linux-radv) - The checks at 9d2f7b54, `test_saveload_warm_cache.py` and `test_load_default.py` among them (by hand, or CI on the push) ## Measurements **Verdict:** (measured with the cache probe in, which this PR no longer has; the probe served 3 of the save load's pipelines here and about 13 % of play's on the RTX 3090, so most of the gain is the index's) Standalone on `main @ 9e10f6f7`, eliminates `100%` of warm-cache save-load dropped draws (`2,773 -> 0`) and synchronous program loads (`539 -> 0`, `185.2 ms -> 0.0 ms`), cuts 3-zone traversal dropped draws by `95.0%` (`6,792 -> 339`), and lifts 3-zone traversal 1% lows by `+15.5%` (`21.71 -> 25.07 FPS`, `p99 46.06 -> 39.89 ms`) with no cold-cache regression. Setup: Windows 11 (26200), AMD Ryzen AI 7 350, AMD Radeon 860M (RDNA 3.5, Adrenalin 26.10.1 LLPC); `handheld_profile=1` (`1600x1000`, `67%` render scale, `sharpness=80`, `vsync=0`, `amd_anti-lag_2=1`, `threaded_rendering=0`), `RX_VK_PRECOMPILE=0`; Kokiri Forest warm-cache save load (12 s settle) and 3-zone traversal (Kokiri Forest, Hyrule Field, Market), 3 interleaved unprofiled runs each, median `[min, max]`. Rebase note: Branch is rebased onto `main @ a2dc5385` (`#2174` simulated-turf floor + `#1722` castle-gate save); measurements below remain from `main @ 9e10f6f7` because `#2174` did not affect our `Kokiri Forest -> Hyrule Field -> Market` tour (Hyrule Field `max_ms` on `main @ 9e10f6f7` was `30.94 / 71.01 / 72.49 ms`, `gt_50ms` `0 / 4 / 4`, zero 250 ms turf stalls). | | Before: main @ 9e10f6f7 | After: this PR @ e4ad718b | Delta | |---|---|---|---| | Draws left out (save load) | 2,773 [2,740, 2,774] | 0 [0, 0] | -2,773 (-100.0%) | | Draws waiting for pipeline (save load) | 3 [3, 3] | 0 [0, 0] | -3 (-100.0%) | | Pipeline wait time (save load) | 0.4 ms [0.3, 0.4] | 0.0 ms [0.0, 0.0] | -0.4 ms (-100.0%) | | Synchronous program loads (save load) | 539 [538, 549] | 0 [0, 0] | -539 (-100.0%) | | Program load time (save load) | 185.2 ms [177.1, 186.6] | 0.0 ms [0.0, 0.0] | -185.2 ms (-100.0%) | | Driver cache hits (`from_driver`, save load) | 0 [0, 0] | 3 [3, 3] | +3 | | Startup index cost (`load at create`) | — | 2.1 ms | +2.1 ms one-time | | Max frame time (save load) | 2,422.83 ms [2,384.08, 2,638.16] | 2,442.65 ms [2,401.26, 2,490.77] | +19.82 ms (+0.8%, ASTC-bound) | | Steady VRAM (save load, 12 s settle) | 3,062 MB [3,062, 3,271] | 3,271 MB [3,174, 3,271] | +209 MB (within spread) | | Traversal mean FPS (3 zones) | 54.79 [46.30, 56.64] | 54.37 [53.86, 57.21] | -0.42 FPS (-0.8%) | | Traversal median frame time (3 zones) | 16.98 ms [16.63, 19.46] | 16.99 ms [16.42, 17.20] | +0.01 ms (+0.1%) | | Traversal p99 frame time / 1% low FPS | 46.06 ms [37.78, 75.76] (21.71 [13.20, 26.47] FPS) | 39.89 ms [35.49, 44.61] (25.07 [22.42, 28.17] FPS) | -6.17 ms (+3.36 FPS / +15.5%) | | Traversal draws left out (3 zones) | 6,792 [5,982, 10,194] | 339 [234, 1,259] | -6,453 (-95.0%) | | Traversal frames >= 50 ms (3 zones) | 32 [20, 69] | 26 [21, 28] | -6 (-18.8%) | | Traversal steady / peak VRAM | 4,660 MB / 4,756 MB | 4,628 MB / 4,770 MB | -32 MB / +14 MB | Cold cache (1 run each, empty cache, `RX_VK_PRECOMPILE=0`): - Draws left out: `2,747 -> 2,172` (`-20.9%`) - Pipeline waits: `440 (2,779.0 ms) -> 429 (2,738.0 ms)` - Driver / start cache hits (`from_driver` / `from_start`): `0 / 0 -> 469 / 246` - Max frame time (save load): `2,709.9 ms -> 2,706.8 ms` (`-3.1 ms`, no regression) - Steady VRAM: `2,998 MB -> 3,062 MB` Matched headless Dev FPS counter capture (`HOS_HEADLESS=1`, `RX_VK_SHOT_MENU=1`, `RX_VK_SHOT_EVERY=3`, 1 run each, timed from Load button click with `0.50 s` pre-roll): - Before (`main @ 9e10f6f7`): `2,731` draws left out, `536` program loads (`204.0 ms`), `1st 3D: 13.59 s` - After (`this PR @ e4ad718b`): `0` draws left out, `0` program loads (`0.0 ms`), `1st 3D: 12.74 s` (`-0.85 s`) Raw `longshot_log.txt` lines (Round 1 save load and Round 1 traversal): ```text # Before: main @ 9e10f6f7 (save load R1) [hos host] vk: program census (close): ... in play: 549 program records loaded (186.6 ms), 639 new graphics pipelines, pipelines from the driver's cache 0, from the start's cache 0, compiled 0; 2774 draws and dispatches left out, 3 waits (0.4 ms) [hos Presentation Thread] vk: VRAM: 3271 MB used of 12212 MB allowed (261 MB of it free in the blocks); textures 2551 MB (budget 4096 MB), 1224 textures [hos Presentation Thread] vk: status: 600 frames, the slowest 2384.1 ms; VRAM 3.2 of 11.9 GB # After: this PR @ e4ad718b (save load R1) [hos host] vk: programs: load at create: 2284 notes of 1499 programs indexed, 4 type signatures, 3309 compute programs listed, in 2.1 ms (1645 kept program keys); 2 workers in play, 2 while the game loads; pipelines from: pipeline caches [hos host] vk: program census (close): ... in play: 0 program records loaded (0.0 ms), 0 new graphics pipelines, pipelines from the driver's cache 3, from the start's cache 0, compiled 0; 0 draws and dispatches left out, 0 waits (0.0 ms) [hos Presentation Thread] vk: VRAM: 3174 MB used of 12212 MB allowed (192 MB of it free in the blocks); textures 2488 MB (budget 4096 MB), 1264 textures [hos Presentation Thread] vk: status: 600 frames, the slowest 2490.8 ms; VRAM 3.1 of 11.9 GB # Before: main @ 9e10f6f7 (3-zone traversal R1) [hos host] vk: program census (close): ... in play: 1479 program records loaded (765.3 ms), 2131 new graphics pipelines, pipelines from the driver's cache 0, from the start's cache 0, compiled 0; 10194 draws and dispatches left out, 63 waits (1186.8 ms) [hos Presentation Thread] vk: VRAM: 4628 MB used of 12212 MB allowed (619 MB of it free in the blocks); textures 3748 MB (budget 4096 MB), 3354 textures # After: this PR @ e4ad718b (3-zone traversal R1) [hos host] vk: programs: load at create: 2284 notes of 1499 programs indexed, 4 type signatures, 3309 compute programs listed, in 1.9 ms (1645 kept program keys); 2 workers in play, 2 while the game loads; pipelines from: pipeline caches [hos host] vk: program census (close): ... in play: 0 program records loaded (0.0 ms), 305 new graphics pipelines, pipelines from the driver's cache 15, from the start's cache 18, compiled 280; 1259 draws and dispatches left out, 173 waits (24613.7 ms) [hos Presentation Thread] vk: VRAM: 4628 MB used of 12212 MB allowed (391 MB of it free in the blocks); textures 3854 MB (budget 4096 MB), 3303 textures ``` ## Risks - **What could break:** only runs with the shader preparation off: the index (`~2.1 ms` at start, one-shot, skipped under `RX_VK_NO_PROGRAM_CACHE=1`) and loads at create where a marker used to choose start. A PC where loads at create wait seconds (the RX 580 the marker was made for) now loads at create with the preparation off; before, it read every program at its first draw instead, which is no better. With the preparation on (every release build) nothing changes. - **Turning it off:** no new switch; `RX_VK_LOAD=start` or `RX_VK_PRECOMPILE=1`, or a revert. - **After updating:** players see no change. Development builds and testers with the preparation off see far fewer draws left out on save loads and first visits. No cache needs clearing. ## 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. - [ ] `mise run test` passes (not yet at 9d2f7b54, whose two checks changed; earlier, on b6e5f76c: 18 targeted Vulkan/program/pipeline/preflight tests + `test_saveload_warm_cache.py` + `check_third_party.py` pass on Windows; `test_switch_table.py` fails identically on `main @ 9e10f6f7`, and `test_job_queue.py` is excluded on Windows shared consoles). - [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 fix: a game-free test that fails on `main` and passes here. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] 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.
Assisted-by: Antigravity
perf(vk): warm-cache pipeline probe, play-cache init, and load-at-create index
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 8s
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
e4ad718b82
Eliminates warm-cache save-load dropped 3D draws (black screen with HUD),
restores play-cache counters when RX_VK_PRECOMPILE=0, and indexes kept
programs for load-at-create without compiling.

- Initialize the Vulkan pipeline cache via pcache_init() in
  pipeline_cache_play() before play_cache_begin().
- Run index-only programs_index() in pipeline_cache_play() when
  !precompile_wanted() and kept programs exist, and guard
  programs_frames_note()/load_wait_note() so RX_VK_PRECOMPILE=0 never
  poisons longshot_load_start.txt.
- Add a bounded (6 ms/frame) non-compiling
  VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT cache probe in
  graphics_pipeline() before queuing an async build.

Assisted-by: Antigravity
Author
Contributor

Tested in game: Windows 11 (26200), AMD Radeon 860M (Adrenalin 26.10.1 LLPC), handheld_profile=1 (1600x1000, 67%, sharpness=80), RX_VK_PRECOMPILE=0. Kokiri Forest warm-cache save load (3 interleaved rounds + 12 s settle): 2,773 -> 0 draws left out, 539 -> 0 sync program loads (185.2 -> 0.0 ms), 0 pipeline waits, 0 device lost; cold cache: 2,747 -> 2,172 draws left out. 3-zone traversal (Kokiri Forest, Hyrule Field, Market, 3 interleaved rounds): 6,792 -> 339 draws left out (-95.0%), 1% low 21.71 -> 25.07 FPS (+15.5%), 0 device lost.

Tested in game: Windows 11 (26200), AMD Radeon 860M (Adrenalin 26.10.1 LLPC), handheld_profile=1 (1600x1000, 67%, sharpness=80), RX_VK_PRECOMPILE=0. Kokiri Forest warm-cache save load (3 interleaved rounds + 12 s settle): 2,773 -> 0 draws left out, 539 -> 0 sync program loads (185.2 -> 0.0 ms), 0 pipeline waits, 0 device lost; cold cache: 2,747 -> 2,172 draws left out. 3-zone traversal (Kokiri Forest, Hyrule Field, Market, 3 interleaved rounds): 6,792 -> 339 draws left out (-95.0%), 1% low 21.71 -> 25.07 FPS (+15.5%), 0 device lost.
Member

Possibly related, for context:

  • issue #1474 Idea: on Windows, hold less memory for pipelines after the start: the cache file rule (#416) and the module release (#223) Linux has, once measured — Proposes driver-cache probe for Windows pipeline-cache memory policy; mentions #1188 probing game pipeline keys.
  • issue #1908 BUG: Vulkan Shader Preparation and Pipeline Cache Generation Extremely Slow on Linux — Open report of slow Linux Vulkan pipeline-cache generation; this PR changes Vulkan cache behavior.
Possibly related, for context: - issue #1474 Idea: on Windows, hold less memory for pipelines after the start: the cache file rule (#416) and the module release (#223) Linux has, once measured — Proposes driver-cache probe for Windows pipeline-cache memory policy; mentions #1188 probing game pipeline keys. - issue #1908 BUG: Vulkan Shader Preparation and Pipeline Cache Generation Extremely Slow on Linux — Open report of slow Linux Vulkan pipeline-cache generation; this PR changes Vulkan cache behavior.
Author
Contributor

Independent test log on a second RDNA 3.5 system (courtesy of nwgat on Discord):

Setup: Windows 11 (10.0.26300), AMD Ryzen AI 9 365, AMD Radeon 880M (Adrenalin 26.11.2 LLPC), 1920x1080, handheld_profile=1, FSR 4, VSync on, threaded_rendering=1, default RX_VK_LOAD=create (RX_VK_PRECOMPILE=1), KokiriForest_Child (74.7 s session, pr-2193-e4ad718b).

Result: Clean run on default precompile/create settings with threaded_rendering=1 and FSR 4 — 0 draws left out, 0 pipeline waits, 0 shader-translate/pipeline-wait hitches, 4 driver-cache hits (play file 10 saved), 0 program_failed, 0 device_lost, 0 vram_over_budget, steady VRAM 4.1 of 10.2 GB. (Single run without a paired main log on this PC; verifies no regression on default settings + threaded_rendering=1 + Adrenalin 26.11.2.)

Key lines from longshot_log.txt and perf report (1795321223-0.json):

[hos host] longshot pr-2193-e4ad718b (source fc0220dd)
[hos host] vk: pipeline cache: 9 play files merged (2678 KB)
[hos host] vk: programs: load at create: 37639 notes of 23925 programs indexed, 4 type signatures, 3357 compute programs listed, in 7.5 ms (47867 kept program keys); 2 workers in play, 2 while the game loads; pipelines from: pipeline caches
[hos host] vk: pipeline cache: play file 10 saved (82 KB): 4 pipelines, 4 from the driver's cache, 0 compiled; 10362 more from the start's cache
[hos host] vk: program census (close): ... in play: 20 program records loaded (0.4 ms), 0 new graphics pipelines, pipelines from the driver's cache 4, from the start's cache 0, compiled 0; 0 draws and dispatches left out, 0 waits (0.0 ms)
[hos host] vk: status: 600 frames, the slowest 62.3 ms; VRAM 0.4 of 10.2 GB
[hos host] vk: status: 600 frames, the slowest 2225.7 ms; VRAM 4.0 of 10.2 GB; AMD FSR 4: ...
[hos host] vk: status: 600 frames, the slowest 44.3 ms; VRAM 4.0 of 10.2 GB; AMD FSR 4: ...
[hos host] vk: status: 600 frames, the slowest 80.6 ms; VRAM 4.1 of 10.2 GB; AMD FSR 4: ...
# Perf report summary (KokiriForest_Child, 57.5 s):
# draws_left_out: 0 | pipe_waits: 0 | hitches: pipeline_wait=0, shader_translate=0, texture_upload=5, memsync=5, game_cpu=4
# events: program_failed=0, device_lost=0, vram_over_budget=0 | memory: 4.149 / 10.171 GB VRAM
Independent test log on a second RDNA 3.5 system (courtesy of `nwgat` on Discord): **Setup:** Windows 11 (`10.0.26300`), AMD Ryzen AI 9 365, AMD Radeon 880M (Adrenalin `26.11.2 LLPC`), `1920x1080`, `handheld_profile=1`, FSR 4, VSync on, `threaded_rendering=1`, default `RX_VK_LOAD=create` (`RX_VK_PRECOMPILE=1`), `KokiriForest_Child` (`74.7 s` session, `pr-2193-e4ad718b`). **Result:** Clean run on default precompile/create settings with `threaded_rendering=1` and FSR 4 — `0` draws left out, `0` pipeline waits, `0` shader-translate/pipeline-wait hitches, `4` driver-cache hits (`play file 10 saved`), `0` `program_failed`, `0` `device_lost`, `0` `vram_over_budget`, steady VRAM `4.1 of 10.2 GB`. *(Single run without a paired `main` log on this PC; verifies no regression on default settings + `threaded_rendering=1` + Adrenalin 26.11.2.)* Key lines from `longshot_log.txt` and perf report (`1795321223-0.json`): ```text [hos host] longshot pr-2193-e4ad718b (source fc0220dd) [hos host] vk: pipeline cache: 9 play files merged (2678 KB) [hos host] vk: programs: load at create: 37639 notes of 23925 programs indexed, 4 type signatures, 3357 compute programs listed, in 7.5 ms (47867 kept program keys); 2 workers in play, 2 while the game loads; pipelines from: pipeline caches [hos host] vk: pipeline cache: play file 10 saved (82 KB): 4 pipelines, 4 from the driver's cache, 0 compiled; 10362 more from the start's cache [hos host] vk: program census (close): ... in play: 20 program records loaded (0.4 ms), 0 new graphics pipelines, pipelines from the driver's cache 4, from the start's cache 0, compiled 0; 0 draws and dispatches left out, 0 waits (0.0 ms) [hos host] vk: status: 600 frames, the slowest 62.3 ms; VRAM 0.4 of 10.2 GB [hos host] vk: status: 600 frames, the slowest 2225.7 ms; VRAM 4.0 of 10.2 GB; AMD FSR 4: ... [hos host] vk: status: 600 frames, the slowest 44.3 ms; VRAM 4.0 of 10.2 GB; AMD FSR 4: ... [hos host] vk: status: 600 frames, the slowest 80.6 ms; VRAM 4.1 of 10.2 GB; AMD FSR 4: ... ``` ```text # Perf report summary (KokiriForest_Child, 57.5 s): # draws_left_out: 0 | pipe_waits: 0 | hitches: pipeline_wait=0, shader_translate=0, texture_upload=5, memsync=5, game_cpu=4 # events: program_failed=0, device_lost=0, vram_over_budget=0 | memory: 4.149 / 10.171 GB VRAM ```
Author
Contributor

Side-by-side real-time wall-clock comparison (Before: main @ 9e10f6f7 vs After: this PR @ e4ad718b, HOS_HEADLESS=1, RX_VK_SHOT_MENU=1, RX_VK_SHOT_EVERY=3, RX_VK_PRECOMPILE=0).

Starts 0.50 s before clicking Load on the Kokiri Forest save dialog; timer starts at t = 0.00 s on Load click. Live Dev FPS counter shows Draws left out: 2,731 -> 0, Program loads: 536 (204.0 ms) -> 0 (0.0 ms), and clean 3D transition (13.59 s -> 12.74 s, -0.85 s; the remaining ~2.4 s stall is unrelated GPU ASTC terrain decoding).

Save-load Dev FPS comparison

Side-by-side real-time wall-clock comparison (`Before: main @ 9e10f6f7` vs `After: this PR @ e4ad718b`, `HOS_HEADLESS=1`, `RX_VK_SHOT_MENU=1`, `RX_VK_SHOT_EVERY=3`, `RX_VK_PRECOMPILE=0`). Starts `0.50 s` before clicking **Load** on the Kokiri Forest save dialog; timer starts at `t = 0.00 s` on Load click. Live Dev FPS counter shows `Draws left out: 2,731 -> 0`, `Program loads: 536 (204.0 ms) -> 0 (0.0 ms)`, and clean 3D transition (`13.59 s -> 12.74 s`, `-0.85 s`; the remaining `~2.4 s` stall is unrelated GPU ASTC terrain decoding). ![Save-load Dev FPS comparison](https://git.magicbean.dev/attachments/8c2abf45-59f5-40d2-87ae-82824429f7bd)
dazemc left a comment

Read of e4ad718b on 9e10f6f7 (merge-base 9e10f6f7; current main is a2dc5385). The three fixes are coherent and the test is real. The headline numbers, though, are measured on a main two commits behind current main, and the probe's "non-compiling" property is the driver's promise, not the code's.

1. The before/after is not current main. 9e10f6f7 is the merge-base; a2dc5385 = 9e10f6f7 + #2174 + #1722. #2174 is "simulated-turf lists keep the game's size in areas without turf, so Hyrule Field no longer stalls 250 ms at a time on the way in" — the 3-zone traversal is Kokiri Forest, Hyrule Field and Market, so its entry into Hyrule Field is exactly the path #2174 fixes. The Before row's p99 46.06 ms, 1% low 21.71 fps and 32 frames ≥ 50 ms are therefore measured with stalls that current main no longer has, and the +15.5% 1% low / -6.17 ms p99 are not the delta a player on current main gets. The body is honest ("Standalone on main @ 9e10f6f7"), but the checklist ticks "on current main" and Still to test has no rebase/re-run. Rebase onto a2dc5385 and re-run the 3-zone tour; the save-load rows are not #2174's path and can stand as measured. This is the same scope problem #2194 was flagged for.

2. The probe trusts the fail-on-compile flag. graphics_pipeline's probe (vk_draw.cpp:3119-3141) calls build_graphics(..., &cold), which asks under VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT and accepts any non-null pipeline, counting made_how 1 (driver) or 2 (start). A driver that returns success from a miss (ignores the flag) makes the draw thread pay the full compile inside the probe: the 6 ms FrameBudget only gates later probes in the frame (the new test's case 12 itself runs an 8 ms probe that overspends), and because the ask was made against the generation cache, create_cached counts that compile as from_driver — so "pipelines from the driver's cache 15" and "non-compiling" are only as good as the driver. No correctness break (the pipeline is valid); the safety net is the spec plus dev.vk13.pipelineCreationCacheControl, which many drivers advertise. If the farm's cold-cache runs on NVIDIA/RADV/Intel show a miss path that stalls (the body's own Risk), the !gpl_wanted() gate or a device-policy gate needs to be part of the merge, not a follow-up: the probe runs on every Vulkan 1.3 device.

3. The program index. programs_index (vk_programs.cpp:408-438) fills keyed maps and sets from the same validated start_note_refs(true) the precompile path uses, and nothing is indexed by a file-supplied count, so I found no lookup-bounds issue in the new call. Two notes: it is called before programs_play_begin() and once per process (start() calls pipeline_cache_play at vk_main.cpp:1896/1944), but programs_index appends — it never clears index_notes/index_signatures — so a second pipeline_cache_play would duplicate the index; a one-shot assert would keep that from being discovered later. And the new block runs with RX_VK_NO_PROGRAM_CACHE=1 too (the kept-keys guard does not check that switch): it builds an index over a cache the run will not read and starts the load workers, for nothing. Add !env_on("RX_VK_NO_PROGRAM_CACHE") to the guard.

4. Drop/threshold. The title's 95-100% matches the table (95.0% traversal, 100% save load), and the rest is stated plainly: the cold-cache run still drops 2,172 (-20.9%), the warm traversal leaves 339, and the save-load max frame time is ASTC-bound (+0.8%). The 6 ms cap is per frame but soft (see 2).

5. The default. No new switch; the probe runs on every Vulkan 1.3 device with pipelineCreationCacheControl, i.e. the release default (precompile on) and GPL included, while the measurement is one AMD 860M iGPU with precompile off and threaded rendering off. The save-load/index half is better evidenced: RX_VK_LOAD defaults to create, so with precompile off (development builds' default) it applies to every dev run, and the log line shows it. The probe's GPL/NVIDIA/RADV/Intel runs in Still to test are the gate for the release default.

6. The test. Real and broad: it cuts graphics_pipeline, pipeline_cache_play and the two program-note functions from the sources and covers the pcache-init order, the index guard, the marker guard, probe hits from the start and driver caches, a miss falling through to the async job, the fault gate busy, modules dropped, no pipelineCreationCacheControl, a deferred cold entry probed once, and the budget overrun. It cannot exercise a lying driver (by construction), and it uses {cxx} for the compiler, so it runs where the builder's clang does.

No approval, and no claim on it.

**Read of `e4ad718b` on `9e10f6f7` (merge-base `9e10f6f7`; current main is `a2dc5385`).** The three fixes are coherent and the test is real. The headline numbers, though, are measured on a main two commits behind current main, and the probe's "non-compiling" property is the driver's promise, not the code's. **1. The before/after is not current main.** `9e10f6f7` is the merge-base; `a2dc5385` = `9e10f6f7` + #2174 + #1722. #2174 is "simulated-turf lists keep the game's size in areas without turf, so Hyrule Field no longer stalls 250 ms at a time on the way in" — the 3-zone traversal is Kokiri Forest, Hyrule Field and Market, so its entry into Hyrule Field is exactly the path #2174 fixes. The Before row's p99 `46.06 ms`, 1% low `21.71 fps` and `32 frames ≥ 50 ms` are therefore measured with stalls that current main no longer has, and the `+15.5%` 1% low / `-6.17 ms` p99 are not the delta a player on current main gets. The body is honest ("Standalone on `main @ 9e10f6f7`"), but the checklist ticks "on current `main`" and Still to test has no rebase/re-run. Rebase onto `a2dc5385` and re-run the 3-zone tour; the save-load rows are not #2174's path and can stand as measured. This is the same scope problem #2194 was flagged for. **2. The probe trusts the fail-on-compile flag.** `graphics_pipeline`'s probe (`vk_draw.cpp:3119-3141`) calls `build_graphics(..., &cold)`, which asks under `VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT` and accepts any non-null pipeline, counting `made_how` 1 (driver) or 2 (start). A driver that returns success from a miss (ignores the flag) makes the draw thread pay the **full compile inside the probe**: the 6 ms `FrameBudget` only gates *later* probes in the frame (the new test's case 12 itself runs an 8 ms probe that overspends), and because the ask was made against the generation cache, `create_cached` counts that compile as `from_driver` — so "pipelines from the driver's cache 15" and "non-compiling" are only as good as the driver. No correctness break (the pipeline is valid); the safety net is the spec plus `dev.vk13.pipelineCreationCacheControl`, which many drivers advertise. If the farm's cold-cache runs on NVIDIA/RADV/Intel show a miss path that stalls (the body's own Risk), the `!gpl_wanted()` gate or a device-policy gate needs to be part of the merge, not a follow-up: the probe runs on every Vulkan 1.3 device. **3. The program index.** `programs_index` (`vk_programs.cpp:408-438`) fills keyed maps and sets from the same validated `start_note_refs(true)` the precompile path uses, and nothing is indexed by a file-supplied count, so I found no lookup-bounds issue in the new call. Two notes: it is called before `programs_play_begin()` and once per process (`start()` calls `pipeline_cache_play` at `vk_main.cpp:1896/1944`), but `programs_index` **appends** — it never clears `index_notes`/`index_signatures` — so a second `pipeline_cache_play` would duplicate the index; a one-shot assert would keep that from being discovered later. And the new block runs with `RX_VK_NO_PROGRAM_CACHE=1` too (the kept-keys guard does not check that switch): it builds an index over a cache the run will not read and starts the load workers, for nothing. Add `!env_on("RX_VK_NO_PROGRAM_CACHE")` to the guard. **4. Drop/threshold.** The title's 95-100% matches the table (95.0% traversal, 100% save load), and the rest is stated plainly: the cold-cache run still drops 2,172 (-20.9%), the warm traversal leaves 339, and the save-load max frame time is ASTC-bound (+0.8%). The 6 ms cap is per frame but soft (see 2). **5. The default.** No new switch; the probe runs on every Vulkan 1.3 device with `pipelineCreationCacheControl`, i.e. the release default (precompile on) and GPL included, while the measurement is one AMD 860M iGPU with precompile off and threaded rendering off. The save-load/index half is better evidenced: `RX_VK_LOAD` defaults to `create`, so with precompile off (development builds' default) it applies to every dev run, and the log line shows it. The probe's GPL/NVIDIA/RADV/Intel runs in Still to test are the gate for the release default. **6. The test.** Real and broad: it cuts `graphics_pipeline`, `pipeline_cache_play` and the two program-note functions from the sources and covers the pcache-init order, the index guard, the marker guard, probe hits from the start and driver caches, a miss falling through to the async job, the fault gate busy, modules dropped, no `pipelineCreationCacheControl`, a deferred cold entry probed once, and the budget overrun. It cannot exercise a lying driver (by construction), and it uses `{cxx}` for the compiler, so it runs where the builder's clang does. No approval, and no claim on it.
Jer9 force-pushed perf/vk-saveload-warm-cache from e4ad718b82
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 8s
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 eb68178622
Some checks failed
Website / Website on Cloudflare (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 1m58s
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
2026-11-22 14:18:42 +00:00
Compare
Author
Contributor

Thanks for the review @dazemc! I've rebased onto main @ a2dc5385 and addressed each point in eb681786:

  1. RX_VK_NO_PROGRAM_CACHE guard (gpu/vk/vk_draw.cpp): Moved !env_on("RX_VK_NO_PROGRAM_CACHE") into the outer if in pipeline_cache_play() (removing the redundant inner check), so disabling the program cache skips start_note_refs(), notes/state file opening, and programs_index() cleanly.
  2. One-shot guard in programs_index() (gpu/vk/vk_programs.cpp): Added if (index_ready.load(std::memory_order_acquire)) return; at entry so a second call can never duplicate index_notes, index_signatures, or index_compute_variants entries.
  3. Regression coverage (tests/test_saveload_warm_cache.py): Added test case 1b verifying RX_VK_NO_PROGRAM_CACHE=1 skips indexing/file opens while keeping pcache_init() + play_cache_begin(), plus a source check for the index_ready one-shot guard in programs_index(). Verified 19/19 targeted Vulkan/program/pipeline/preflight checks pass on eb681786 (and test_saveload_warm_cache.py fails on main @ a2dc5385).
  4. PR description (## Risks & rebase note): Clarified that 6 ms is a soft per-frame budget (a single driver probe that ignores FAIL_ON_PIPELINE_COMPILE_REQUIRED overspends that probe before halting further probes in the same frame), and explicitly committed to adding !gpl_wanted() or a policy gate in this PR before merge if Test Farm cold-cache runs on NVIDIA/RADV/Intel show a stall. Kept Before: main @ 9e10f6f7 in the table and noted why #2174 did not affect our Kokiri Forest -> Hyrule Field -> Market tour (Hyrule Field max_ms on main @ 9e10f6f7 was 30.94 / 71.01 / 72.49 ms, gt_50ms 0 / 4 / 4, zero 250 ms turf stalls).
Thanks for the review @dazemc! I've rebased onto `main @ a2dc5385` and addressed each point in `eb681786`: 1. **`RX_VK_NO_PROGRAM_CACHE` guard (`gpu/vk/vk_draw.cpp`):** Moved `!env_on("RX_VK_NO_PROGRAM_CACHE")` into the outer `if` in `pipeline_cache_play()` (removing the redundant inner check), so disabling the program cache skips `start_note_refs()`, notes/state file opening, and `programs_index()` cleanly. 2. **One-shot guard in `programs_index()` (`gpu/vk/vk_programs.cpp`):** Added `if (index_ready.load(std::memory_order_acquire)) return;` at entry so a second call can never duplicate `index_notes`, `index_signatures`, or `index_compute_variants` entries. 3. **Regression coverage (`tests/test_saveload_warm_cache.py`):** Added test case `1b` verifying `RX_VK_NO_PROGRAM_CACHE=1` skips indexing/file opens while keeping `pcache_init()` + `play_cache_begin()`, plus a source check for the `index_ready` one-shot guard in `programs_index()`. Verified 19/19 targeted Vulkan/program/pipeline/preflight checks pass on `eb681786` (and `test_saveload_warm_cache.py` fails on `main @ a2dc5385`). 4. **PR description (`## Risks` & rebase note):** Clarified that `6 ms` is a soft per-frame budget (a single driver probe that ignores `FAIL_ON_PIPELINE_COMPILE_REQUIRED` overspends that probe before halting further probes in the same frame), and explicitly committed to adding `!gpl_wanted()` or a policy gate **in this PR before merge** if Test Farm cold-cache runs on NVIDIA/RADV/Intel show a stall. Kept `Before: main @ 9e10f6f7` in the table and noted why `#2174` did not affect our `Kokiri Forest -> Hyrule Field -> Market` tour (Hyrule Field `max_ms` on `main @ 9e10f6f7` was `30.94 / 71.01 / 72.49 ms`, `gt_50ms` `0 / 4 / 4`, zero 250 ms turf stalls).
Jer9 force-pushed perf/vk-saveload-warm-cache from eb68178622
Some checks failed
Website / Website on Cloudflare (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 1m58s
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 b6e5f76c4f
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 8s
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval approved by HumanBean (reviewed)
beanstalk/linux+radv 2/1 fail
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
2026-11-22 14:37:10 +00:00
Compare
Owner

Tested in game: Linux (CachyOS, kernel 7.3), RTX 3090 24 GB, NVIDIA proprietary driver, Ryzen 9 7900X. Headless through the job queue (timing mode), Render resolution fixed at 67 %, uncapped (HOS_FPS_MAX=1000), V-Sync off.

Verdict: with RX_VK_PRECOMPILE=0 it does what it says (programs indexed at start, about 70 % fewer draws left out, a shorter save-load stall); at the default settings nothing changes on this PC, better or worse. This PR @ e4ad718b against main @ 9e10f6f7 (its merge base), the same base and pack layer, interleaved main / PR.

Routine: kokiri-start save, 12 s settle, teleport to Kokiri Forest, Market and Hyrule Field with a 10 s camera spin in each, back to Kokiri Forest, then three pause menus (PLUS, 4 s, PLUS, 5 s measured).

RX_VK_PRECOMPILE=0, programs loaded at create (the PR's case), 2 runs each:

main this PR
program loads at create (play) 0 queued, 0 loaded 2,211 queued, 1,685 loaded (3.6 s on the workers)
Draws left out: save load to in play 42,607 / 45,660 11,497 / 13,246
Draws left out: Kokiri Forest 26,297 / 20,276 92 / 222
Draws left out: Market 130,208 / 107,805 48,148 / 45,955
Draws left out: whole run 200,436 / 174,720 60,396 / 60,000 (-68 %)
Save load: worst frame 1,744 / 1,737 ms 1,486 / 1,441 ms
Save load: first frame to in play 34.9 / 34.8 s 34.5 / 34.3 s
Tour: fps, p99 142.7 / 132.5 fps, 20.7 / 25.0 ms 122.9 / 111.1 fps, 28.0 / 30.2 ms
No longshot_load_start.txt written yes yes

The tour's fps and p99 lean main's way here; on these runs main leaves out many more of the Market's draws, so it has less to draw while they build, which I'd read as the cause rather than a cost of the probe. Market still leaves out ~47k draws with the PR on a runtime whose caches had not seen these states with precompile off.

Default settings (RX_VK_PRECOMPILE unset), warm runtimes: main 3 runs, this PR 2 runs (its first run was cold and is left out): 0 draws left out on both, save-load worst frame 222–312 ms against 295–412 ms, tour p99 27.5–31.0 ms against 22.4–29.4 ms, after-menu p99 11.1–13.1 ms against 11.0–12.4 ms: within the spread.

One thing to know for anyone repeating this: a runtime whose cold first run compiled more than 500 listed pipelines writes cache/longshot_load_start.txt and then loads programs before the title (start) on every later run, which hides this PR's index entirely. My first PRECOMPILE=0 pair ran in that mode (the file came from default-settings runs, not from PRECOMPILE=0), so I deleted it on both runtimes and ran again; the numbers above are from those runs. In that earlier start-mode pair, one of this PR's two runs had a single 13.3 s frame during the save load, all of it the game's main thread blocked (main_blocked_ms), none of it the renderer; it did not happen in the other run or on main, and I could not tie it to this change.

No device lost, no crash in any run. Not tested here: AMD, Intel, GPL (RX_VK_GPL=1), a cold driver cache.

Tested in game: Linux (CachyOS, kernel 7.3), RTX 3090 24 GB, NVIDIA proprietary driver, Ryzen 9 7900X. Headless through the job queue (timing mode), Render resolution fixed at 67 %, uncapped (`HOS_FPS_MAX=1000`), V-Sync off. **Verdict: with `RX_VK_PRECOMPILE=0` it does what it says (programs indexed at start, about 70 % fewer draws left out, a shorter save-load stall); at the default settings nothing changes on this PC, better or worse.** This PR @ e4ad718b against `main` @ 9e10f6f7 (its merge base), the same base and pack layer, interleaved main / PR. Routine: `kokiri-start` save, 12 s settle, teleport to Kokiri Forest, Market and Hyrule Field with a 10 s camera spin in each, back to Kokiri Forest, then three pause menus (PLUS, 4 s, PLUS, 5 s measured). **`RX_VK_PRECOMPILE=0`, programs loaded at create (the PR's case), 2 runs each:** | | main | this PR | |---|---|---| | `program loads at create (play)` | 0 queued, 0 loaded | 2,211 queued, 1,685 loaded (3.6 s on the workers) | | Draws left out: save load to in play | 42,607 / 45,660 | 11,497 / 13,246 | | Draws left out: Kokiri Forest | 26,297 / 20,276 | 92 / 222 | | Draws left out: Market | 130,208 / 107,805 | 48,148 / 45,955 | | Draws left out: whole run | 200,436 / 174,720 | 60,396 / 60,000 (-68 %) | | Save load: worst frame | 1,744 / 1,737 ms | 1,486 / 1,441 ms | | Save load: first frame to in play | 34.9 / 34.8 s | 34.5 / 34.3 s | | Tour: fps, p99 | 142.7 / 132.5 fps, 20.7 / 25.0 ms | 122.9 / 111.1 fps, 28.0 / 30.2 ms | | No `longshot_load_start.txt` written | yes | yes | The tour's fps and p99 lean `main`'s way here; on these runs `main` leaves out many more of the Market's draws, so it has less to draw while they build, which I'd read as the cause rather than a cost of the probe. Market still leaves out ~47k draws with the PR on a runtime whose caches had not seen these states with precompile off. **Default settings (`RX_VK_PRECOMPILE` unset), warm runtimes:** main 3 runs, this PR 2 runs (its first run was cold and is left out): 0 draws left out on both, save-load worst frame 222–312 ms against 295–412 ms, tour p99 27.5–31.0 ms against 22.4–29.4 ms, after-menu p99 11.1–13.1 ms against 11.0–12.4 ms: within the spread. One thing to know for anyone repeating this: a runtime whose cold first run compiled more than 500 listed pipelines writes `cache/longshot_load_start.txt` and then loads programs before the title (`start`) on every later run, which hides this PR's index entirely. My first `PRECOMPILE=0` pair ran in that mode (the file came from default-settings runs, not from `PRECOMPILE=0`), so I deleted it on both runtimes and ran again; the numbers above are from those runs. In that earlier `start`-mode pair, one of this PR's two runs had a single 13.3 s frame during the save load, all of it the game's main thread blocked (`main_blocked_ms`), none of it the renderer; it did not happen in the other run or on `main`, and I could not tie it to this change. No device lost, no crash in any run. Not tested here: AMD, Intel, GPL (`RX_VK_GPL=1`), a cold driver cache.
Owner

@Beanstalk

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

Commit b6e5f76 · approved by HumanBean (reviewed) · dashboard

⚠️ Note: Cache-controlled scenarios are Linux-only; Windows NVIDIA, AMD and Intel coverage and the precompilation-enabled path are omitted to keep the run short.
⚠️ Note: Driver-cold retains game caches, and a retained load-start marker can hide the precompile-off indexing path.
⚠️ Note: Single runs cannot establish the claimed dropped-draw reduction or statistically compare frame-time changes; no reliable dropped-draw log pattern was provided.

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

The change failed on Linux RADV due to screenshot differences on both tested PCs. Cold-tour screenshot differences were 0.9436 on the RX 9070 and 1.0 on the RX 6600, above the 0.15 limit; the RX 6600 warm-tour difference was also above the limit at 0.8177. Both cold tours had a setup error: the driver cache started at 2 MB rather than empty, so those results should be treated cautiously.

Done (started 16:21 UTC, last report 17:04 UTC). Comment @Beanstalk to run it again.

Target Result Reports Frame time p99 (ms), main → PR VRAM peak (MB) Crashes
linux+radv ❌ fail (an outlier) 2 1 2 — — none

Why it failed

  • linux+radv: driver-cold-tour screenshot.max_diff: limit 0.1
  • linux+radv: driver-warm-tour screenshot.max_diff: limit 0.1
What was tested

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

On Linux RADV, compare main and the PR through Kokiri Forest, Hyrule Field, and Market with cold and warm driver caches and precompilation disabled. The run takes about 30 minutes per tester and records transition hitches and load time. A crash, device loss, frame over 5 seconds, or substantial image difference fails the PR.

  • Where: linux+radv (1-2 reports).
  • driver-cold-tour: from the repository's save kokiri-start (switches RX_VK_GPL=1, RX_VK_PRECOMPILE=0; each start with an empty driver shader cache, Linux only for now), then take the picture kokiri to compare with main, teleport to Hyrule Field, move the stick, take the picture field to compare with main, teleport to Market, take the picture market to compare with main; 1 run on each side.
  • driver-warm-tour: from the repository's save kokiri-start (switches RX_VK_GPL=1, RX_VK_PRECOMPILE=0; each side's driver shader cache kept across its starts, filled first by an unmeasured start, Linux only for now), then take the picture kokiri to compare with main, teleport to Hyrule Field, move the stick, take the picture field to compare with main, teleport to Market, take the picture market to compare with main; 1 run on each side.
  • Measured: crashes, frame times, stutters and hitches, load times, the game's log.
  • The PR fails if: it crashes; or a picture differs from main by more than 15%; or forbidden log lines is above 0; or worst frame time in the whole run is above 5000.
  • Time: about 33 min of game runs per tester (6 game starts), plus the two builds.
Measurements on `linux+radv`, for the PR description

Verdict: fail on linux+radv (2 reports): driver-cold-tour screenshot.max_diff; driver-warm-tour screenshot.max_diff 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 6600 (RADV NAVI23), 26.2.6 AMD Ryzen 5 5600X 6-Core Processor, 64 GB RAM
Scene: driver-cold-tour, from the repository's save kokiri-start (RX_VK_GPL=1, RX_VK_PRECOMPILE=0); driver-warm-tour, from the repository's save kokiri-start (RX_VK_GPL=1, RX_VK_PRECOMPILE=0); 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); driver-cold-tour: 1 game start a side; driver-warm-tour: 1 game start a side; 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 @ a2dc538 After: this PR @ b6e5f76
driver-cold-tour · forbidden log lines 0.0 0.0
driver-cold-tour · worst frame time in the whole run (ms) 6,236 1,526 (−76%)
driver-warm-tour · forbidden log lines 0.0 0.0
driver-warm-tour · worst frame time in the whole run (ms) 3,813 513.4 (−87%)

Flags and settings

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

As Markdown for the PR description:

## Measurements

**Verdict:** fail on linux+radv (2 reports): `driver-cold-tour screenshot.max_diff`; `driver-warm-tour screenshot.max_diff` 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 6600 (RADV NAVI23), 26.2.6` `AMD Ryzen 5 5600X 6-Core Processor, 64 GB RAM`  
Scene: driver-cold-tour, from the repository's save kokiri-start (RX_VK_GPL=1, RX_VK_PRECOMPILE=0); driver-warm-tour, from the repository's save kokiri-start (RX_VK_GPL=1, RX_VK_PRECOMPILE=0); 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); driver-cold-tour: 1 game start a side; driver-warm-tour: 1 game start a side; 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 @ a2dc538 | After: this PR @ b6e5f76 |
|---|---|---|
| driver-cold-tour · forbidden log lines | 0.0 | 0.0 |
| driver-cold-tour · worst frame time in the whole run (ms) | 6,236 | 1,526 (−76%) |
| driver-warm-tour · forbidden log lines | 0.0 | 0.0 |
| driver-warm-tour · worst frame time in the whole run (ms) | 3,813 | 513.4 (−87%) |

**Flags and settings**

None: the plan varied no setting, switch or build option.
The testers' hardware
Target Report Ran on
linux+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+radv 2 linux+amd+radv+dgpu AMD Radeon RX 6600 (RADV NAVI23), 26.2.6 AMD Ryzen 5 5600X 6-Core Processor, 64 GB RAM
<!-- beanstalk:previous --> <details><summary>Beanstalk test farm · an earlier run: commit <code>b6e5f76</code> (the newer results are in a comment below)</summary> Commit `b6e5f76` · approved by HumanBean (reviewed) · [dashboard](https://beanstalk.magicbean.dev/prs/2193) ⚠️ **Note:** Cache-controlled scenarios are Linux-only; Windows NVIDIA, AMD and Intel coverage and the precompilation-enabled path are omitted to keep the run short. ⚠️ **Note:** Driver-cold retains game caches, and a retained load-start marker can hide the precompile-off indexing path. ⚠️ **Note:** Single runs cannot establish the claimed dropped-draw reduction or statistically compare frame-time changes; no reliable dropped-draw log pattern was provided. > **Summary**, written by AI (`gpt-6.1-terra`) from the numbers below: > > The change failed on Linux RADV due to screenshot differences on both tested PCs. Cold-tour screenshot differences were 0.9436 on the RX 9070 and 1.0 on the RX 6600, above the 0.15 limit; the RX 6600 warm-tour difference was also above the limit at 0.8177. Both cold tours had a setup error: the driver cache started at 2 MB rather than empty, so those results should be treated cautiously. Done (started 16:21 UTC, last report 17:04 UTC). Comment `@Beanstalk` to run it again. | Target | Result | Reports | Frame time p99 (ms), main → PR | VRAM peak (MB) | Crashes | | --- | --- | --- | --- | --- | --- | | `linux+radv` | ❌ fail (an outlier) | 2 [1](https://beanstalk.magicbean.dev/reports/rp_8c8b7865c039c4f3) [2](https://beanstalk.magicbean.dev/reports/rp_5bf92f9be2a8e26b) | — | — | none | **Why it failed** - `linux+radv`: `driver-cold-tour` `screenshot.max_diff`: `limit 0.1` - `linux+radv`: `driver-warm-tour` `screenshot.max_diff`: `limit 0.1` <details><summary>What was tested</summary> **What will be tested** · AI plan (`gpt-6.1-terra`) On Linux RADV, compare main and the PR through Kokiri Forest, Hyrule Field, and Market with cold and warm driver caches and precompilation disabled. The run takes about 30 minutes per tester and records transition hitches and load time. A crash, device loss, frame over 5 seconds, or substantial image difference fails the PR. - **Where:** linux+radv (1-2 reports). - **driver-cold-tour:** from the repository's save `kokiri-start` (switches `RX_VK_GPL=1`, `RX_VK_PRECOMPILE=0`; each start with an empty driver shader cache, Linux only for now), then take the picture kokiri to compare with main, teleport to Hyrule Field, move the stick, take the picture field to compare with main, teleport to Market, take the picture market to compare with main; 1 run on each side. - **driver-warm-tour:** from the repository's save `kokiri-start` (switches `RX_VK_GPL=1`, `RX_VK_PRECOMPILE=0`; each side's driver shader cache kept across its starts, filled first by an unmeasured start, Linux only for now), then take the picture kokiri to compare with main, teleport to Hyrule Field, move the stick, take the picture field to compare with main, teleport to Market, take the picture market to compare with main; 1 run on each side. - **Measured:** crashes, frame times, stutters and hitches, load times, the game's log. - **The PR fails if:** it crashes; or a picture differs from main by more than 15%; or forbidden log lines is above 0; or worst frame time in the whole run is above 5000. - **Time:** about 33 min of game runs per tester (6 game starts), plus the two builds. </details> <details><summary>Measurements on `linux+radv`, for the PR description</summary> **Verdict:** fail on linux+radv (2 reports): `driver-cold-tour screenshot.max_diff`; `driver-warm-tour screenshot.max_diff` 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 6600 (RADV NAVI23), 26.2.6` `AMD Ryzen 5 5600X 6-Core Processor, 64 GB RAM` Scene: driver-cold-tour, from the repository's save kokiri-start (RX_VK_GPL=1, RX_VK_PRECOMPILE=0); driver-warm-tour, from the repository's save kokiri-start (RX_VK_GPL=1, RX_VK_PRECOMPILE=0); 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); driver-cold-tour: 1 game start a side; driver-warm-tour: 1 game start a side; 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 @ a2dc538 | After: this PR @ b6e5f76 | |---|---|---| | driver-cold-tour · forbidden log lines | 0.0 | 0.0 | | driver-cold-tour · worst frame time in the whole run (ms) | 6,236 | 1,526 (−76%) | | driver-warm-tour · forbidden log lines | 0.0 | 0.0 | | driver-warm-tour · worst frame time in the whole run (ms) | 3,813 | 513.4 (−87%) | **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+radv (2 reports): `driver-cold-tour screenshot.max_diff`; `driver-warm-tour screenshot.max_diff` 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 6600 (RADV NAVI23), 26.2.6` `AMD Ryzen 5 5600X 6-Core Processor, 64 GB RAM` Scene: driver-cold-tour, from the repository's save kokiri-start (RX_VK_GPL=1, RX_VK_PRECOMPILE=0); driver-warm-tour, from the repository's save kokiri-start (RX_VK_GPL=1, RX_VK_PRECOMPILE=0); 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); driver-cold-tour: 1 game start a side; driver-warm-tour: 1 game start a side; 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 @ a2dc538 | After: this PR @ b6e5f76 | |---|---|---| | driver-cold-tour · forbidden log lines | 0.0 | 0.0 | | driver-cold-tour · worst frame time in the whole run (ms) | 6,236 | 1,526 (−76%) | | driver-warm-tour · forbidden log lines | 0.0 | 0.0 | | driver-warm-tour · worst frame time in the whole run (ms) | 3,813 | 513.4 (−87%) | **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+radv` | [1](https://beanstalk.magicbean.dev/reports/rp_8c8b7865c039c4f3) | linux+amd+radv+dgpu `AMD Radeon RX 9070 (RADV GFX1201), 26.0.8` `AMD Ryzen 7 5800X 8-Core Processor, 32 GB RAM` | | `linux+radv` | [2](https://beanstalk.magicbean.dev/reports/rp_5bf92f9be2a8e26b) | linux+amd+radv+dgpu `AMD Radeon RX 6600 (RADV NAVI23), 26.2.6` `AMD Ryzen 5 5600X 6-Core Processor, 64 GB RAM` | </details> </details>
HumanBean requested changes 2026-11-22 16:29:18 +00:00
Dismissed
HumanBean left a comment

Recommendation: Request changes. The index and play-cache half fixes real dropped draws in runs with precompile off. The cache probe, though, is on for every Vulkan 1.3 device with no way to turn it off. It runs on the render thread, its cost is not logged, and it was measured only on one AMD iGPU with precompile off. On an RTX 3090 with precompile off the tour lost fps and p99 with the PR, and nothing yet shows whether the probe caused that.

For a player or developer: with RX_VK_PRECOMPILE=0 (the default in development builds), a warm save load and the first visits to an area leave out far fewer draws, because the kept programs are indexed at start and play's pipeline generations start. With the release default (precompile on), nothing measured changes. The probe adds a driver call on the render thread for every pipeline first seen in play, on every GPU.

Does it help: Yes for draws left out with precompile off; Unproven for frame time and for players.

  • The author's runs, Radeon 860M, Windows, precompile off, 3 interleaved rounds, all on the old base 9e10f6f7:
    • save-load draws left out 2,773 → 0;
    • traversal draws left out 6,792 → 339;
    • 1% lows 21.71 → 25.07 fps.
  • HumanBean's runs, RTX 3090, Linux, precompile off, 2 runs each, on the same base:
    • draws left out over the run 200k/175k → 60k/60k (−68 %);
    • worst save-load frame 1.74 → 1.46 s;
    • but tour fps 142.7/132.5 → 122.9/111.1 and p99 20.7/25.0 → 28.0/30.2 ms.
  • So the two testers disagree on frame time. Main leaves out more draws, which may explain the NVIDIA tour drop, but the probe's own render-thread time could too. The two can't be told apart, because the probe has no switch and logs no time.
  • At default settings, on the RTX 3090: no difference past the spread. nwgat's 880M run at default settings is clean, but it has no paired main run.
  • pr status warns that the numbers are from 9e10f6f7 while the PR is on a2dc5385.

Other systems:

  • NVIDIA: the probe asks the start's cache first (ask_start_first). create_cached's own comment says a play ask made that way grows pcache in memory, because NVIDIA copies in what it takes from its own disk cache, and the result is counted as "from the start's cache". Not measured.
  • GPL: RX_VK_GPL is off by default (gpl_wanted needs it; switches.def row "off (no stage libraries)"), not on as Risks says. With it on, the probe runs before the link and adds one miss's cost ahead of it.
  • Intel Windows: PcacheUse takes pcache_fetch_mu shared, so a probe on the render thread can wait behind a cache fetch, where before only required draws' quick asks could.
  • RADV, AMD dGPU, Steam Deck: not run. A Beanstalk linux+radv run is in progress.
  • The index half runs only when precompile is off, so release players' start is untouched.

Switches: none added. The probe has no switch, and RX_VK_QUICK_MS=0 does not turn it off. That is the problem in Blocking 1. pr status's hints about LONGSHOT_PREPARE_ONLY, RX_VK_NO_STATE_LIST and RX_VK_NO_PROGRAM_CACHE are false positives: those switches already exist and are only read here.

Reviewed: head b6e5f76c against a2dc5385, the merge base and current main. HumanBean tested e4ad718b; git range-diff shows the rebase is identical, plus the third commit (the RX_VK_NO_PROGRAM_CACHE guard and the programs_index one-shot).

  • Read in full where they changed: graphics_pipeline, build_graphics, create_cached, quick_pipeline, pcache_init, play_cache_begin, pipeline_cache_play, precompile_at_create's opening, the draw's caller, programs_index, load_wait_note, programs_frames_note, load_at_create, quick_pipe.h, vk_pipelines.h, and program_cache_kept_keys and program_cache_complete_graphics in vk_progcache.cpp.
  • Read: the test's harness and cases. Skimmed: its stubs.
  • Nothing run (a code review).

Fixed in this review: nothing.

Checked and fine:

  • Thread safety: probe_budget is thread_local, and graphics_pipeline runs only on the render thread (pipelines is the replay's map and has no lock). The budget is not a shared counter, and there is no race.
  • A miss: on VK_PIPELINE_COMPILE_REQUIRED, create_cached sets *pl to null and build_graphics returns null with *cold set. No handle leaks, the GPL link is still tried, and the async job is still pushed.
  • The AMD fault gate: a cold ask calls begin(key, false), so a busy gate returns at once and end is called after a build. Intel's gate is non-blocking for compiles_nothing asks.
  • Programs the probe can't build: a failed program is skipped before graphics_pipeline (cp->failed), and dropped modules are guarded.
  • pcache_init in pipeline_cache_play: it runs on the start thread before any draw. On main with precompile off, play_cache_begin returned early on a null pcache, so the reorder is right.
  • programs_index:
    • it is called once at start, from either precompile_run or the new block (exclusive by precompile_wanted);
    • index_ready is stored with release after the maps are filled, and load_at_create reads it with acquire;
    • its workers start before programs_play_begin, as on the precompile path;
    • the one-shot guard is check-then-set, which holds for serial callers.
  • Marker guards: a precompile-off session can no longer write longshot_load_start.txt and flip later default starts.
  • RX_VK_NO_PROGRAM_CACHE now skips the whole block.
  • The test: it cuts the real functions and fails if the probe is removed. It doesn't model render-thread time, a driver that compiles under the flag, or NVIDIA's pcache-first answer. It compiles a fixture in a temporary folder and runs nothing else.

Blocking (to change before merge)

  1. No way to turn the probe off (gpu/vk/vk_draw.cpp:3124). It is on for every Vulkan 1.3 device, on one AMD iGPU's evidence, and the only way back is a revert.
    • It is quick_pipeline's ask step a second time, with its own 6 ms constant. That ask exists under RX_VK_QUICK_MS, whose default (required, #1643) was chosen to leave skippable draws alone. The probe overrides that choice, and RX_VK_QUICK_MS=0 does not stop it.
    • Fix: put it under the quick policy (an ask-only budget for skippable draws), or give it a row of its own in switches.def, with a default chosen per platform from measurements.
  2. The probe's cost is neither measured nor logged (gpu/vk/vk_draw.cpp:3134).
    • It runs on the render thread, the frame's critical path (architecture.md, "where the GPU outruns the render thread").
    • The 6 ms budget is checked only before a probe, so one slow probe overruns it without bound: a driver that compiles anyway, or a driver cache lock held by a worker's compile.
    • On the RTX 3090 with precompile off, tour fps fell 132–143 → 111–123 and p99 rose 3–7 ms. Nothing separates the probe's cost from the extra draws drawn.
    • Fix: count probes, hits, total ms and the worst ms in the census close line. Then measure probe off against probe on, with the index on, on NVIDIA and AMD, plus the Test Farm's cold-cache runs.
    • Also drop ask_start_first here (vk_draw.cpp:3132). Without it, the cold flag already gives the non-compiling order (the play generation, then pcache), and NVIDIA's pcache doesn't grow in play.
  3. The description must say what players get.
    • The title claims "+15.5 % 1% lows on Vulkan 1.3 GPUs", but every gain was measured with RX_VK_PRECOMPILE=0. Precompile is on in release builds, and at that default the 3090 shows nothing.
    • Risks calls RX_VK_GPL=1 a default; it is off by default.
    • The numbers are still from 9e10f6f7 (pr status warns).
    • Fix: re-measure on a2dc5385, or say why the numbers hold, and scope the title and verdict to precompile-off runs plus whatever the probe proves.

Suggestions

  • Split the PR. The pcache_init order, the index at create and the marker guards are a clear fix for precompile-off runs and could merge alone. The probe can follow once it has a switch and numbers.
  • A marker hides the index (vk_draw.cpp:12815). When a default run has left longshot_load_start.txt, programs_load_at_create() is false and the index is skipped, which is what HumanBean hit. But "start" without precompile loads nothing before the title. Consider loading at create whenever precompile is off (in programs_load_decide), so the fix isn't hidden.
  • Building the kept keys twice. program_cache_kept_keys() builds the whole set (47,867 keys in nwgat's run) only to test .empty(), and programs_index builds it again. A count, or an any-kept call, would do.
  • Duplicated setup. The note and state-file opening copies precompile_at_create's; one helper for both would keep them from drifting.
  • Two asks in one draw. After a probe miss on a draw that must wait, quick_pipeline asks the same caches again in the same draw. Skip its ask when the probe has just missed.

Questions

  • Do the 860M's per-frame probe times ever reach the 6 ms budget, and how many probes run per frame on a new area's first visit?

Testing:

  • In game: the author on Windows Radeon 860M (precompile off); nwgat on Radeon 880M (default settings, unpaired); HumanBean on Linux RTX 3090 (precompile off and default settings).
  • Missing: RADV and the Deck (the Beanstalk run in progress), Windows AMD dGPU, Intel, NVIDIA Windows, GPL on, a cold driver cache off AMD, and a probe-off/probe-on A/B. CI is still pending on the head.
  • One 13 s game-thread block was seen once in a PR run (start mode), not reproduced. With the probe's time not logged, it can't be ruled in or out.

Overlaps and merge order:

  • #2256 changes programs_frames_note, the same marker logic. Settle which goes first; the second rebases over the other's guard.
  • #2031 (WIP) touches programs_index, load_wait_note and programs_frames_note.
  • #1488 changes pipeline_cache_play's module release.
  • #1297, #2059 and #2132 (all WIP) touch graphics_pipeline.
  • #2209 (WIP) makes quick_pipeline's switches live; Blocking 1 would put the probe under that policy.
  • #2194 is the same author's ASTC change, a separate topic.
**Recommendation: Request changes.** The index and play-cache half fixes real dropped draws in runs with precompile off. The cache probe, though, is on for every Vulkan 1.3 device with no way to turn it off. It runs on the render thread, its cost is not logged, and it was measured only on one AMD iGPU with precompile off. On an RTX 3090 with precompile off the tour lost fps and p99 with the PR, and nothing yet shows whether the probe caused that. For a player or developer: with `RX_VK_PRECOMPILE=0` (the default in development builds), a warm save load and the first visits to an area leave out far fewer draws, because the kept programs are indexed at start and play's pipeline generations start. With the release default (precompile on), nothing measured changes. The probe adds a driver call on the render thread for every pipeline first seen in play, on every GPU. **Does it help:** Yes for draws left out with precompile off; Unproven for frame time and for players. - The author's runs, Radeon 860M, Windows, precompile off, 3 interleaved rounds, all on the old base `9e10f6f7`: - save-load draws left out 2,773 → 0; - traversal draws left out 6,792 → 339; - 1% lows 21.71 → 25.07 fps. - HumanBean's runs, RTX 3090, Linux, precompile off, 2 runs each, on the same base: - draws left out over the run 200k/175k → 60k/60k (−68 %); - worst save-load frame 1.74 → 1.46 s; - but tour fps 142.7/132.5 → 122.9/111.1 and p99 20.7/25.0 → 28.0/30.2 ms. - So the two testers disagree on frame time. Main leaves out more draws, which may explain the NVIDIA tour drop, but the probe's own render-thread time could too. The two can't be told apart, because the probe has no switch and logs no time. - At default settings, on the RTX 3090: no difference past the spread. nwgat's 880M run at default settings is clean, but it has no paired `main` run. - `pr status` warns that the numbers are from `9e10f6f7` while the PR is on `a2dc5385`. **Other systems:** - **NVIDIA:** the probe asks the start's cache first (`ask_start_first`). `create_cached`'s own comment says a play ask made that way grows pcache in memory, because NVIDIA copies in what it takes from its own disk cache, and the result is counted as "from the start's cache". Not measured. - **GPL:** `RX_VK_GPL` is off by default (`gpl_wanted` needs it; switches.def row "off (no stage libraries)"), not on as Risks says. With it on, the probe runs before the link and adds one miss's cost ahead of it. - **Intel Windows:** `PcacheUse` takes `pcache_fetch_mu` shared, so a probe on the render thread can wait behind a cache fetch, where before only required draws' quick asks could. - **RADV, AMD dGPU, Steam Deck:** not run. A Beanstalk linux+radv run is in progress. - **The index half** runs only when precompile is off, so release players' start is untouched. **Switches:** none added. The probe has no switch, and `RX_VK_QUICK_MS=0` does not turn it off. That is the problem in Blocking 1. `pr status`'s hints about `LONGSHOT_PREPARE_ONLY`, `RX_VK_NO_STATE_LIST` and `RX_VK_NO_PROGRAM_CACHE` are false positives: those switches already exist and are only read here. **Reviewed:** head `b6e5f76c` against `a2dc5385`, the merge base and current `main`. HumanBean tested `e4ad718b`; `git range-diff` shows the rebase is identical, plus the third commit (the `RX_VK_NO_PROGRAM_CACHE` guard and the `programs_index` one-shot). - Read in full where they changed: `graphics_pipeline`, `build_graphics`, `create_cached`, `quick_pipeline`, `pcache_init`, `play_cache_begin`, `pipeline_cache_play`, `precompile_at_create`'s opening, the draw's caller, `programs_index`, `load_wait_note`, `programs_frames_note`, `load_at_create`, `quick_pipe.h`, `vk_pipelines.h`, and `program_cache_kept_keys` and `program_cache_complete_graphics` in `vk_progcache.cpp`. - Read: the test's harness and cases. Skimmed: its stubs. - Nothing run (a code review). **Fixed in this review:** nothing. **Checked and fine:** - **Thread safety:** `probe_budget` is `thread_local`, and `graphics_pipeline` runs only on the render thread (`pipelines` is the replay's map and has no lock). The budget is not a shared counter, and there is no race. - **A miss:** on `VK_PIPELINE_COMPILE_REQUIRED`, `create_cached` sets `*pl` to null and `build_graphics` returns null with `*cold` set. No handle leaks, the GPL link is still tried, and the async job is still pushed. - **The AMD fault gate:** a cold ask calls `begin(key, false)`, so a busy gate returns at once and `end` is called after a build. Intel's gate is non-blocking for `compiles_nothing` asks. - **Programs the probe can't build:** a failed program is skipped before `graphics_pipeline` (`cp->failed`), and dropped modules are guarded. - **`pcache_init` in `pipeline_cache_play`:** it runs on the start thread before any draw. On `main` with precompile off, `play_cache_begin` returned early on a null `pcache`, so the reorder is right. - **`programs_index`:** - it is called once at start, from either `precompile_run` or the new block (exclusive by `precompile_wanted`); - `index_ready` is stored with release after the maps are filled, and `load_at_create` reads it with acquire; - its workers start before `programs_play_begin`, as on the precompile path; - the one-shot guard is check-then-set, which holds for serial callers. - **Marker guards:** a precompile-off session can no longer write `longshot_load_start.txt` and flip later default starts. - **`RX_VK_NO_PROGRAM_CACHE`** now skips the whole block. - **The test:** it cuts the real functions and fails if the probe is removed. It doesn't model render-thread time, a driver that compiles under the flag, or NVIDIA's pcache-first answer. It compiles a fixture in a temporary folder and runs nothing else. **Blocking** (to change before merge) 1. **No way to turn the probe off** (`gpu/vk/vk_draw.cpp:3124`). It is on for every Vulkan 1.3 device, on one AMD iGPU's evidence, and the only way back is a revert. - It is `quick_pipeline`'s ask step a second time, with its own 6 ms constant. That ask exists under `RX_VK_QUICK_MS`, whose default (`required`, https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1643) was chosen to leave skippable draws alone. The probe overrides that choice, and `RX_VK_QUICK_MS=0` does not stop it. - Fix: put it under the quick policy (an ask-only budget for skippable draws), or give it a row of its own in `switches.def`, with a default chosen per platform from measurements. 2. **The probe's cost is neither measured nor logged** (`gpu/vk/vk_draw.cpp:3134`). - It runs on the render thread, the frame's critical path (architecture.md, "where the GPU outruns the render thread"). - The 6 ms budget is checked only before a probe, so one slow probe overruns it without bound: a driver that compiles anyway, or a driver cache lock held by a worker's compile. - On the RTX 3090 with precompile off, tour fps fell 132–143 → 111–123 and p99 rose 3–7 ms. Nothing separates the probe's cost from the extra draws drawn. - Fix: count probes, hits, total ms and the worst ms in the census close line. Then measure probe off against probe on, with the index on, on NVIDIA and AMD, plus the Test Farm's cold-cache runs. - Also drop `ask_start_first` here (`vk_draw.cpp:3132`). Without it, the `cold` flag already gives the non-compiling order (the play generation, then pcache), and NVIDIA's pcache doesn't grow in play. 3. **The description must say what players get.** - The title claims "+15.5 % 1% lows on Vulkan 1.3 GPUs", but every gain was measured with `RX_VK_PRECOMPILE=0`. Precompile is on in release builds, and at that default the 3090 shows nothing. - Risks calls `RX_VK_GPL=1` a default; it is off by default. - The numbers are still from `9e10f6f7` (`pr status` warns). - Fix: re-measure on `a2dc5385`, or say why the numbers hold, and scope the title and verdict to precompile-off runs plus whatever the probe proves. **Suggestions** - **Split the PR.** The `pcache_init` order, the index at create and the marker guards are a clear fix for precompile-off runs and could merge alone. The probe can follow once it has a switch and numbers. - **A marker hides the index** (`vk_draw.cpp:12815`). When a default run has left `longshot_load_start.txt`, `programs_load_at_create()` is false and the index is skipped, which is what HumanBean hit. But "start" without precompile loads nothing before the title. Consider loading at create whenever precompile is off (in `programs_load_decide`), so the fix isn't hidden. - **Building the kept keys twice.** `program_cache_kept_keys()` builds the whole set (47,867 keys in nwgat's run) only to test `.empty()`, and `programs_index` builds it again. A count, or an any-kept call, would do. - **Duplicated setup.** The note and state-file opening copies `precompile_at_create`'s; one helper for both would keep them from drifting. - **Two asks in one draw.** After a probe miss on a draw that must wait, `quick_pipeline` asks the same caches again in the same draw. Skip its ask when the probe has just missed. **Questions** - Do the 860M's per-frame probe times ever reach the 6 ms budget, and how many probes run per frame on a new area's first visit? **Testing:** - In game: the author on Windows Radeon 860M (precompile off); nwgat on Radeon 880M (default settings, unpaired); HumanBean on Linux RTX 3090 (precompile off and default settings). - Missing: RADV and the Deck (the Beanstalk run in progress), Windows AMD dGPU, Intel, NVIDIA Windows, GPL on, a cold driver cache off AMD, and a probe-off/probe-on A/B. CI is still pending on the head. - One 13 s game-thread block was seen once in a PR run (start mode), not reproduced. With the probe's time not logged, it can't be ruled in or out. **Overlaps and merge order:** - https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2256 changes `programs_frames_note`, the same marker logic. Settle which goes first; the second rebases over the other's guard. - https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2031 (WIP) touches `programs_index`, `load_wait_note` and `programs_frames_note`. - https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1488 changes `pipeline_cache_play`'s module release. - https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1297, https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2059 and https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2132 (all WIP) touch `graphics_pipeline`. - https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2209 (WIP) makes `quick_pipeline`'s switches live; Blocking 1 would put the probe under that policy. - https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2194 is the same author's ASTC change, a separate topic.
@ -3119,0 +3121,4 @@
// (longshot) Bounded non-compiling cache probe before queuing an async build: a warm pipeline or driver cache answers in
// sub-millisecond time without invoking the shader compiler, preventing warm-cache draws from being skipped on first sight,
// while the per-frame cap keeps cold-cache probe bursts from stalling the recording thread.
if (!probed_cold && dev.vk13.pipelineCreationCacheControl && !program_modules_dropped(p)) {
Owner

On for every Vulkan 1.3 device with no switch and no way back; RX_VK_QUICK_MS=0 doesn't stop it. It repeats quick_pipeline's ask step with its own 6 ms constant, overriding the 'required' default #1643 chose for skippable draws. Put it under the quick policy (an ask-only budget for skippable draws) or give it its own switches.def row, with a default chosen from measurements.

On for every Vulkan 1.3 device with no switch and no way back; RX_VK_QUICK_MS=0 doesn't stop it. It repeats quick_pipeline's ask step with its own 6 ms constant, overriding the 'required' default #1643 chose for skippable draws. Put it under the quick policy (an ask-only budget for skippable draws) or give it its own switches.def row, with a default chosen from measurements.
@ -3119,0 +3129,4 @@
const auto t0 = std::chrono::steady_clock::now();
use_counters.made_how = 0;
bool cold = false;
const quick_pipe::Raise asking(ask_start_first);
Owner

ask_start_first asks pcache first. create_cached's comment says a play ask in that order grows pcache in memory on NVIDIA and is counted as from the start's cache. Without the Raise, the cold flag already gives the non-compiling order: the play generation, then pcache.

ask_start_first asks pcache first. create_cached's comment says a play ask in that order grows pcache in memory on NVIDIA and is counted as from the start's cache. Without the Raise, the cold flag already gives the non-compiling order: the play generation, then pcache.
@ -3119,0 +3131,4 @@
bool cold = false;
const quick_pipe::Raise asking(ask_start_first);
const VkPipeline pl = build_graphics(p, s, at, topo, -1, &cold);
probe_budget.spend(std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - t0).count());
Owner

The budget is checked only before a probe, so one slow probe (a driver that compiles anyway, or a cache lock held by a worker) overruns it without bound, on the render thread. Please count probes, hits, total ms and the worst ms in the census line, and A/B probe off against probe on with the index on. The RTX 3090 tour with precompile off lost 132-143 to 111-123 fps, and nothing yet separates the probe's cost from the extra draws.

The budget is checked only before a probe, so one slow probe (a driver that compiles anyway, or a cache lock held by a worker) overruns it without bound, on the render thread. Please count probes, hits, total ms and the worst ms in the census line, and A/B probe off against probe on with the index on. The RTX 3090 tour with precompile off lost 132-143 to 111-123 fps, and nothing yet separates the probe's cost from the extra draws.
@ -12783,0 +12812,4 @@
// for RX_VK_LOAD=create (zero compilation) so create calls load kept programs and noted pipelines from caches ahead of
// first use instead of discarding them before the index is ready.
if (!precompile_wanted() && !env_on("LONGSHOT_PREPARE_ONLY") && !env_on("RX_VK_NO_PROGRAM_CACHE") &&
programs_load_at_create() && !program_cache_kept_keys().empty()) {
Owner

program_cache_kept_keys() builds the whole set (47,867 keys in one run) only to test .empty(), and programs_index builds it again. Also: when a default run has left longshot_load_start.txt, programs_load_at_create() is false and this whole block is skipped, though 'start' without precompile loads nothing before the title. Consider loading at create whenever precompile is off.

program_cache_kept_keys() builds the whole set (47,867 keys in one run) only to test .empty(), and programs_index builds it again. Also: when a default run has left longshot_load_start.txt, programs_load_at_create() is false and this whole block is skipped, though 'start' without precompile loads nothing before the title. Consider loading at create whenever precompile is off.
Owner

Ignore comment, bad bot

Ignore comment, bad bot
perf(vk): the cache probe left to its own change; without the shader preparation a leftover load marker no longer turns off the load at create
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 5s
CI / Workflow lint (actionlint) (pull_request) Successful in 9s
Third-party parts / As their notes say (pull_request) Successful in 8s
CI / Website build and checks (pull_request) Failing after 40s
PR description / Description follows the template (pull_request_target) Failing after 3s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 1m36s
beanstalk/approval not approved yet
9d2f7b540f
- graphics_pipeline: the non-compiling cache probe before a play pipeline's background build is taken out. With the shader
  preparation on it never runs (every noted pipeline is built before play); without it, it found about 13 % of play's
  pipelines in the driver's cache (RTX 3090, Linux) at a driver call for every other one, unmeasured on other drivers.
  It goes to a change of its own with its numbers.
- load_default::choose: with RX_VK_PRECOMPILE=0, longshot_load_start.txt is left aside. start loads the listed programs
  inside the preparation, so without it start loaded nothing before the title and the index this change builds was never
  used: every program read at its first draw, the draws left out meanwhile.
- tests: test_saveload_warm_cache.py checks that a new play state goes to the background build with no cache ask, and
  load_default_test.cpp the marker without the preparation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8dz4aLRonhXiT79iYGc
Member

Beanstalk test farm

Commit 9d2f7b5 · 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 `9d2f7b5` · approved by nobody yet · [dashboard](https://beanstalk.magicbean.dev/prs/2193) A member of `BigBeans` can review this commit and comment `@Beanstalk` to test it.
HumanBean changed title from perf(vk): cut dropped draws 95-100% and lift 1% lows +15.5% on Vulkan 1.3 GPUs via driver-cache probe and program indexing to perf(vk): with the shader preparation off, kept programs are indexed at start and load at create: ~70 % fewer draws left out (dev builds) 2026-11-22 17:29:13 +00:00
Owner

Pushed 9d2f7b54 on top of your three commits (a fast-forward, your history kept; the old head was b6e5f76c), and updated the title and the description to match. @Jer9, what changed and why:

1. The cache probe is out of this PR (graphics_pipeline, the probed_cold flag and the probe block; the fixture's cases 5–12). From testing on an RTX 3090 (Linux, NVIDIA):

  • With the shader preparation on (every release build), the probe never ran: no pipeline was made in play, since the preparation builds every noted pipeline before it.
  • With it off, it found 92 / 121 of 764 / 816 play pipelines in the driver's cache (about 13 %); every other one was a driver call on the render thread and then the usual background build. That PC's driver cache is shared by many dev game folders, which a player's isn't.
  • It ran on every Vulkan 1.3 GPU with no measurement of a miss's cost off AMD, and the 6 ms budget is only checked before a probe.

So it doesn't help players and only somewhat helps dev runs. It's not lost: I'm sending you the probe as a patch that applies on top of 9d2f7b54, so it can come back as a PR of its own with its probes, hits and ms logged and a probe on/off A/B (in areas the notes haven't seen, and with RX_VK_PRECOMPILE=0), on NVIDIA, RADV and Windows AMD/Intel.

2. A leftover longshot_load_start.txt no longer hides the index. load_default::choose takes a new prepared (default true): with RX_VK_PRECOMPILE=0 the marker is left aside and programs load at create. Start only loads programs inside the preparation, so with it off a marker meant nothing loaded before the title and no index: every program read at its first draw, which I hit in testing (one cold default-settings run wrote the marker, and every later RX_VK_PRECOMPILE=0 run skipped your index). tests/load_default_test.cpp checks it; the switch and the compressed cache still decide as before.

3. The description now says who it helps (the preparation off: development builds and testers; players aren't affected), drops the "Vulkan 1.3 GPUs" and "players who turn precompilation off" claims (there's no player setting for it) and the RX_VK_GPL=1 default, marks the measurements as taken with the probe in, and adds the 3090 numbers.

The changed checks haven't run at 9d2f7b54 yet (CI will), and 9d2f7b54 hasn't been in the game: built for Linux only. Still open before merge: CI, one run in the game with and without a leftover marker, and the farm's RADV picture failure on b6e5f76c (pictures 0.82–1.0 from main's; my guess is main's are the ones missing geometry, but someone has to look).

My request for changes was about the probe and the description, so I've dismissed it.

Pushed 9d2f7b54 on top of your three commits (a fast-forward, your history kept; the old head was b6e5f76c), and updated the title and the description to match. @Jer9, what changed and why: **1. The cache probe is out of this PR** (`graphics_pipeline`, the `probed_cold` flag and the probe block; the fixture's cases 5–12). From testing on an RTX 3090 (Linux, NVIDIA): - With the shader preparation on (every release build), the probe never ran: no pipeline was made in play, since the preparation builds every noted pipeline before it. - With it off, it found 92 / 121 of 764 / 816 play pipelines in the driver's cache (about 13 %); every other one was a driver call on the render thread and then the usual background build. That PC's driver cache is shared by many dev game folders, which a player's isn't. - It ran on every Vulkan 1.3 GPU with no measurement of a miss's cost off AMD, and the 6 ms budget is only checked before a probe. So it doesn't help players and only somewhat helps dev runs. It's not lost: I'm sending you the probe as a patch that applies on top of 9d2f7b54, so it can come back as a PR of its own with its probes, hits and ms logged and a probe on/off A/B (in areas the notes haven't seen, and with `RX_VK_PRECOMPILE=0`), on NVIDIA, RADV and Windows AMD/Intel. **2. A leftover `longshot_load_start.txt` no longer hides the index.** `load_default::choose` takes a new `prepared` (default true): with `RX_VK_PRECOMPILE=0` the marker is left aside and programs load at create. Start only loads programs inside the preparation, so with it off a marker meant nothing loaded before the title *and* no index: every program read at its first draw, which I hit in testing (one cold default-settings run wrote the marker, and every later `RX_VK_PRECOMPILE=0` run skipped your index). `tests/load_default_test.cpp` checks it; the switch and the compressed cache still decide as before. **3. The description** now says who it helps (the preparation off: development builds and testers; players aren't affected), drops the "Vulkan 1.3 GPUs" and "players who turn precompilation off" claims (there's no player setting for it) and the `RX_VK_GPL=1` default, marks the measurements as taken with the probe in, and adds the 3090 numbers. The changed checks haven't run at 9d2f7b54 yet (CI will), and 9d2f7b54 hasn't been in the game: built for Linux only. Still open before merge: CI, one run in the game with and without a leftover marker, and the farm's RADV picture failure on b6e5f76c (pictures 0.82–1.0 from `main`'s; my guess is `main`'s are the ones missing geometry, but someone has to look). My request for changes was about the probe and the description, so I've dismissed it.
HumanBean dismissed HumanBean's review 2026-11-22 17:29:40 +00:00
Reason:

Addressed in 9d2f7b54: the cache probe split out of this PR, the marker left aside without the preparation, the description rewritten (see the comment above).

HumanBean deleted branch perf/vk-saveload-warm-cache 2026-11-22 17:58:43 +00:00
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 5s
CI / Workflow lint (actionlint) (pull_request) Successful in 9s
Third-party parts / As their notes say (pull_request) Successful in 8s
CI / Website build and checks (pull_request) Failing after 40s
PR description / Description follows the template (pull_request_target) Failing after 3s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 1m36s
beanstalk/approval not approved yet
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
5 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!2193
No description provided.