fix(vk): a game started by itself keeps the program cache prepared in another shader store #2768

Merged
HumanBean merged 35 commits from klimovich008/Longshot:perf/shader-store-self-start into main 2026-11-29 05:20:52 +00:00
Member

Summary

Why: a game folder whose shaders the builder prepared loses every prepared program the first time its game is started without LONGSHOT_SHADER_STORE. Since #2629 / #2632 the builder prepares into <builder cache>/shader-store and passes that folder to the game it starts; the game started by itself opens the older default store (%LOCALAPPDATA%\Longshot\shaders, ~/.cache/longshot/shaders), sees that the program cache names another store, and starts the cache over ("its programs are in another shader store ...: prepared again"). On our day's build that cost a 41.8 s frame on the first Market visit.

Who meets it: a player's version folder does not, because its game hands over to the builder when started by itself (hos_main.c hand_over), and the launcher and longshot-builder play pass the variable. It is the folders with no builder above them: a developer's dev build --out, scripts/dev_packs.py runtimes, longshot_bridge sessions, the Test Farm's runs, a game folder copied somewhere else. So this is hardening for players plus a live bug fix for those folders, and it also makes such runs' measurements valid again (ours lost the cache in every fresh runtime and had cold arms in A/Bs).

How to see it on main: prepare a folder with the builder (LONGSHOT_CACHE set, so it prepares into the builder cache's shader-store), then start the game executable directly with no LONGSHOT_SHADER_STORE. The log says "its programs are in another shader store (ae068cab, this one f8a742eb): prepared again", cache/longshot_programs.bin is cut to an empty cache, and every program is translated again at its first draw.

What changes (gpu/vk/vk_progcache.cpp, disk_init and two helpers):

  • A start that opens the primary program cache with a store writes cache/longshot_shader_store_ref.txt: one line, the store's id and its absolute folder, through a temporary file and a rename, only when it changes.
  • A start without LONGSHOT_SHADER_STORE reads that record before it picks a store:
    • No record (every folder made before this PR), a record of another store, or a malformed one: exactly main's behaviour. The default store opens; a cache naming another store starts over against it once, the record is written, and the next start is warm.
    • The record names the default store and that store was deleted (the launcher's Free up space, or by hand): as main. The store is made again, the cache starts over once, then it is warm. On Windows the default's name is compared without case (CompareStringOrdinal), so a LOCALAPPDATA spelled in another case is still the default.
    • The record names a custom store with the cache's id: that folder is checked (pack and index heads whole, of this version, agreeing). If it is there, it is opened and every key is kept: the bug's fix. If another store is there now, it is gone and the cache starts over, as main. When it cannot be reached within the startup deadline: the primary cache is kept byte for byte and its lock released. The run uses a separate fallback cache that stays writable across launches.
  • LONGSHOT_SHADER_STORE set to a folder, or =0, behaves as before and wins over the record. No new switch: it is a fix.
  • Docs: docs/dev/reference/architecture.md (the store paragraph), switches.md (the LONGSHOT_SHADER_STORE row); contract comments in vk_progcache.cpp and spirv_pack.h (comment only).
  • Test: tests/test_program_cache_store_record.py with tests/program_cache_store_record_test.cpp builds the real disk_init, cut from the source, with the real spirv_pack.h, one process per start; tests/test_spirv_pack.py's anchor follows the keep line's text.

Shader caches: neither vk_progcache.cpp nor spirv_pack.h is in the shader-cache stamp (builder/crates/build-compile/src/generated/shader_stamp.rs: eden, sirit, compat, vk_shader.cpp, vk_bank.cpp, vk_state.h, checked on current main), and kProgramCacheFormat stays 3. An update keeps every translated program; in the game this PR's DLL kept all 47,867 of the base's program keys. The builder's preparation step runs again after the update, as for every renderer change.

Entry paths: the launcher and longshot-builder play pass the variable (game_env / configure_store): main's behaviour, plus the record written. A version folder's game started by itself hands over to the builder: the same. A direct start with no builder above: the record. --update and Linux update-game are gone on main since #2762 (the launcher owns updates); an update in place keeps cache/ and with it the record.

Read first: disk_init in gpu/vk/vk_progcache.cpp, then store_record, open_recorded, same_recorded_name and write_store_record.

#737 proposed cache/longshot_shader_store.txt for a different format. This PR uses cache/longshot_shader_store_ref.txt. #2410 tracks the cold start after deleting the default store.

The follow-up bounds implicit recorded-store lookup to 750 ms. If that custom store is missing, unreadable, or too slow, startup releases the original cache's lock and opens a separate writable fallback cache. The fallback uses the default store when available and inline SPIR-V otherwise. A returning store can still reopen the original cache. An implicit lookup checks the generation under the store lock before opening it, so it cannot recreate a custom store that was cleared during the lookup. Warm/seed cache transfers carry the record and the fallback artifacts.

The Windows regression fixture uses the game's UTF-8 manifest and changes the case of only a test-owned directory component. The record name ends in _ref.txt to distinguish it from the format proposed in #737.

Testing

Tested: Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2, in the game (Market, child, 16:9, uncapped, through our harness's fresh runtimes of a player-like build of main 22d0d2009 with this PR's longshot_vk.dll over it):

  • a builder-prepared folder started with no variable and the game's record there: all 47,867 keys kept, 0 programs translated in play, no "another shader store" line;
  • an old folder with no record, started by itself twice: main's line and behaviour at the first start (cache started over against the default store, the record written), warm at the second;
  • the record naming the cache's store at a folder that is not there: longshot_programs.bin, longshot_programs.idx and the record byte-identical after the run;
  • the default store's files deleted (on a copy, LOCALAPPDATA pointed at a job folder): made again, the cache started over, warm at the next start.

The numbers are under Measurements. Game-free:

  • python -I tests/test_program_cache_store_record.py --cxx <clang++>: on Windows (llvm-mingw clang++ 20261104) PASS, 22 broken variants fail as they must, 9 not run (Linux-only cases); on Linux (WSL Ubuntu, clang++ and g++, as a non-root user) PASS, 29 broken variants fail with each compiler, 2 not run (Windows-only). Each variant is credited only by the case it targets.
  • The same test on main's vk_progcache.cpp (--source): fails (19 checks), as it must. Its deleted-default cases pass there, as they must (main's behaviour).
  • After merging main @ 8cc807971: the new test (Windows), test_spirv_pack, test_program_cache_{index,format,reader,cleanup,one_variant}, test_descriptor_array_census, test_load_default, test_dev_packs, test_run_all_declarations pass (test_utf8_paths skipped here: no cargo); linux_syntax.sh gpu/vk/vk_progcache.cpp ok; mise run lint passes.
  • tests/run_all.py --jobs 4 on the merged head e7e905695: 682 passed, 24 failed, 186 skipped. All 24 fail on main on this Windows PC too: the 20 that failed on main 22d0d2009 in the checker's run (among them test_switch_table: LONGSHOT_LAUNCHER_STARTUP has no switches.def row), and test_log_batch, test_log_levels, test_dev_update, test_windows_on_linux, which fail the same way on main @ 8cc807971 here. None reads vk_progcache.cpp.
  • A second-opinion review (gpt-6.2-sol) ran on every round, 26 in all; its last points are under Risks, "Not covered".

Follow-up at b1717e29: the Linux game-free regression passes with a bounded lookup on a locked store, a warm fallback on repeat launch, and the original program cache restored when the custom store becomes available. The developer cache transfer and shader-store tests passed; the full Linux renderer built against the shared base. The headless game smoke on Linux (RTX 3090, NVIDIA driver 620.70.06) confirmed custom store selection, missing-store fallback, return to the original cache after restoration, and default store recreation after a clear. The seeded program cache did not match this renderer’s translator, so the positive warm-key count was verified in the synthetic regression fixture. The builder eviction fixture also verified the live fallback lock. Windows runtime verification of the revised paths is still outstanding.

Still to test:

  • Linux (Steam Deck or desktop, any GPU): prepare a folder with the builder (longshot-builder dev build ... --cache <dir>, or LONGSHOT_CACHE set, so the store is <cache>/shader-store), start it once through the builder, then start the game executable directly with no LONGSHOT_SHADER_STORE, expecting "the one the cache's longshot_shader_store_ref.txt names" in the log, the program keys kept and no "another shader store" line (by hand, on the Steam Deck or a Linux PC: the Test Farm's plan steps can't set up the folders, environment and files this needs, its comment says)
  • Linux: with a record naming the default store (~/.cache/longshot/shaders), delete that folder and start the game directly twice, expecting at the first start "prepared again" with the store made again and the record naming the new store, and at the second the keys of the first start kept (by hand, on the Steam Deck or a Linux PC: the Test Farm's plan steps can't set up the folders, environment and files this needs, its comment says)
  • NVIDIA and Intel on Windows: the first case above, expecting the same (start-up file logic only, no GPU path) (by hand)
  • Linux and the Steam Deck: a Market start of this PR and of main, expecting no crash at start-up and the store's log lines (@Beanstalk test it anyway: the farm's own alternative plan)

Measurements

Verdict: the bug's case goes from a cache emptied at the first start (582 programs translated in the first Market visit, a 41.8 s frame) to every prepared program kept (0 translated). No per-frame cost: the Market A/B is within noise, diagnostic with 3 pairs. The change runs once at start-up.

Setup: Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2; a player-like build of main 22d0d2009 (longshot.exe 992fc0fd, longshot_vk.dll a1af7a34) prepared by the builder; this PR as its longshot_vk.dll alone over that build. Market, child, 16:9, uncapped (HOS_FPS_MAX=240), render thread on, 20 s window after the arrival; fps, CPU ms a frame and p99 are the window's; "translated in play" counts programs translated after the load started. Each table names the head it ran on. The last two rounds (dd9bfd0bf) changed only the Windows case comparison of the default store's name and the docs, and were not run in the game. The branch now has main @ 8cc807971 merged in; main's commits since 22d0d2009 change neither vk_progcache.cpp nor spirv_pack.h (the builder, the host's log folder, other renderer passes), so the start-up numbers still hold; the A/B was not run again.

The bug's case and the record

A builder-prepared folder (keys at preparation: 47,867) started with no LONGSHOT_SHADER_STORE Before: main @ 22d0d2009 After: this PR @ 10d00286d
first start: keys kept 0 ("another shader store (ae068cab, this one f8a742eb): prepared again") 47,867 (the record's store)
first start: programs translated in play 751 (Hyrule warm-up), a 9.2 s frame 0 in Market: admitted, 113.39 fps, 39.23 CPU ms, p99 17.13 ms, worst 30.6 ms, 0/0/0 frames over 50/100/250 ms
next start, first Market visit: programs translated 582, 1,455 waits for shaders or pipelines (64.7 s), one 41.8 s frame (as above: 0)

Old folders, deleted stores, a store out of reach (cold-then-warm runs; each start a fresh run through the harness, with no variable)

Case Before: main @ 22d0d2009 After: this PR @ 10d00286d (first three) / 17c1c6f86 (last three)
old folder, no record: first start the line "prepared again" (the analyst's runs above) the same line and behaviour: 0 keys, 1,257 translated (11.2 s), the record written; admitted, 109.94 fps, worst 223.8 ms, 5/2/0 over 50/100/250 ms
old folder: the next start not run 1,257 keys kept, 4 translated (41 ms); admitted, 114.09 fps, 38.75 CPU ms, p99 16.81 ms, worst 20.3 ms, 0/0/0
the record names the cache's store at a folder that is not there not run (main has no record; it would start the cache over) no store, run without the cache (1,206 translated, rejected as a cold run); programs.bin (149,266,003 B), programs.idx and the record byte-identical after
the same, a custom store's name not run the same: all three files byte-identical
the default store's files deleted (a copy through LOCALAPPDATA), the record naming it: first start not run main's line: the store made again, 0 keys, 1,201 translated (10.2 s), the record names the new store; admitted, 110.59 fps, worst 226.7 ms, 1/1/0
the same: the next start not run 1,201 keys kept, 53 translated (1.3 s); admitted, 111.89 fps, 39.70 CPU ms, p99 17.30 ms, worst 26.9 ms, 0/0/0

The deleted-default runs redirected the AMD driver's own caches with LOCALAPPDATA too, so their numbers show behaviour, not speed.

The standard A/B (Market, child, 3 alternating pairs, both arms warm through the variable: 47,867 keys, 0 translated in every run, all 6 runs admitted)

Median of 3 Before: main @ 22d0d2009 After: this PR @ 84e9cb9f3
fps 112.44 111.39
CPU ms a frame 40.25 40.74
p99 frame ms 17.77 17.52
worst frame ms (max of 3) 27.5 24.2
frames over 50/100/250 ms 0/0/0 0/0/0
game clock 1.000 1.000
GPU ms a frame 3.2 3.05

-0.9 % fps and +1.2 % CPU ms: within Market's run-to-run spread on this PC (about 3 % fps and 5 % CPU ms with 3 pairs), so diagnostic, and no cost is seen. The code runs once in disk_init (one small read, two 16-byte head reads, a write when the record changes) and nothing per frame. The A/B ran at the first round's head; the later rounds changed only start-up branches.

Risks

  • What a player notices after updating: nothing in a version folder (the builder names the store). A folder started by itself keeps its cache from the second start on, instead of losing it.
  • The behaviour change: a folder with no record is unchanged. A folder whose record names a custom store that can't be reached now runs without the program cache, at every such start, until the store is back or a start names a store (the launcher, the builder, or LONGSHOT_SHADER_STORE). Main dropped the cache once and was warm from the next start. A start without the cache translates every program again at its first draw (about 1,200 in a first Market visit here, 9-19 s of translation, multi-second frames). The log line names the store the cache wants. Who meets it: a folder prepared against a store on a drive that is not mounted, or a custom store deleted while the cache stays.
  • What could break: start-up only. A wrong choice keeps a cache unused or starts it over, as main does for other reasons; nothing is lost that main would keep. LONGSHOT_SHADER_STORE set by hand restores main's choice for a run; a revert is enough.
  • The shader caches: not invalidated (see Summary).

Not covered (each from the reviews or the checks, left because no player's or harness path reaches it):

  • Windows: a concurrent repair of a crash-damaged custom store by another game folder can have its pack rename refused while this start reads the store's 16-byte heads (sol r13). The same window exists for any Longshot reading that store.
  • Linux: a custom store on a hard-mounted NFS share that is offline can block the probe at start-up; main never looks there (sol r15).
  • Linux: the default folder reached through a bind mount under another name, named by hand as LONGSHOT_SHADER_STORE at the preparation, then deleted: kept as a custom store out of reach every start, where main makes the default again (sol r16). No builder or launcher path names it so.
  • Linux: XDG_CACHE_HOME spelled through a .. over a folder later removed, under a link: the same class as the bind mount (sol check-r3).
  • Windows file systems whose case tables differ from CompareStringOrdinal's: NTFS volumes with XP-era or Vista-era $UpCase tables, exFAT's final sigma. Two names it calls one, or one it calls two, when a folder is missing (sol r20, r22).
  • Windows before 1903 (no UTF-8 code page): non-ASCII names compared as the game's other strings are.
  • The test on a machine whose TEMP is inside a folder made case-sensitive: default-case swaps the case of all of LOCALAPPDATA and fails on a correct tree (sol r23).
  • A Linux cache folder that is not writable (0555) with a writable cache file in it: the keys are kept, but no record can be written (sol r23).
  • The Windows test fixture has no UTF-8 manifest, so a TEMP outside the ANSI code page breaks its arguments; the shipped game is unaffected (sol check-r2, point 7).
  • Accepted after the review rounds: a recorded store's own lock held by another process (the store's normal wait); a recorded folder holding other files or unusual permissions (a read-only lock is out of reach: kept); damage a store's heads don't show (Store::open remakes it, as for a named store); special files or links inside a store folder; an unmount between the probe and Store::open; a cache replaced by another tool between the two head reads; a link retargeted since the record; a lock file that cannot be opened (two starts at once, fail-open as main) giving a record of another store, then taken as none; restored-store snapshots and seed-index pairing; the 4 KB record limit and the head-reread race untested; the test fixtures' 2^-32 id collisions; the guard that skips writing after a failed second read while out of reach is in the code but has no case of its own.
  • Inherited from main, listed as follow-ups: the cache lock is fail-open; on Linux a start that loses flock() leaks its descriptor until exit; a start that holds the lock but cannot open the cache for append keeps the lock with the cache off.
  • Not run: Linux and the Steam Deck in the game (WSL game-free only), NVIDIA and Intel GPUs, a real unmounted drive (a missing folder stood in), a real deleted default store (a copy through LOCALAPPDATA stood in), the Windows case-spelling fix in the game (game-free only; the final head's other code paths ran in the game at earlier heads, see Measurements).

Checklist

Ready for review

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

When it applies

  • A 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.
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary **Why:** a game folder whose shaders the builder prepared loses every prepared program the first time its game is started without `LONGSHOT_SHADER_STORE`. Since #2629 / #2632 the builder prepares into `<builder cache>/shader-store` and passes that folder to the game it starts; the game started by itself opens the older default store (`%LOCALAPPDATA%\Longshot\shaders`, `~/.cache/longshot/shaders`), sees that the program cache names another store, and starts the cache over ("its programs are in another shader store ...: prepared again"). On our day's build that cost a 41.8 s frame on the first Market visit. **Who meets it:** a player's version folder does not, because its game hands over to the builder when started by itself (`hos_main.c` `hand_over`), and the launcher and `longshot-builder play` pass the variable. It is the folders with no builder above them: a developer's `dev build --out`, `scripts/dev_packs.py` runtimes, `longshot_bridge` sessions, the Test Farm's runs, a game folder copied somewhere else. So this is **hardening for players plus a live bug fix for those folders**, and it also makes such runs' measurements valid again (ours lost the cache in every fresh runtime and had cold arms in A/Bs). **How to see it on main:** prepare a folder with the builder (`LONGSHOT_CACHE` set, so it prepares into the builder cache's `shader-store`), then start the game executable directly with no `LONGSHOT_SHADER_STORE`. The log says "its programs are in another shader store (ae068cab, this one f8a742eb): prepared again", `cache/longshot_programs.bin` is cut to an empty cache, and every program is translated again at its first draw. **What changes** (`gpu/vk/vk_progcache.cpp`, `disk_init` and two helpers): - A start that opens the primary program cache with a store writes `cache/longshot_shader_store_ref.txt`: one line, the store's id and its absolute folder, through a temporary file and a rename, only when it changes. - A start **without** `LONGSHOT_SHADER_STORE` reads that record before it picks a store: - **No record** (every folder made before this PR), a record of another store, or a malformed one: **exactly main's behaviour**. The default store opens; a cache naming another store starts over against it once, the record is written, and the next start is warm. - **The record names the default store** and that store was deleted (the launcher's Free up space, or by hand): **as main**. The store is made again, the cache starts over once, then it is warm. On Windows the default's name is compared without case (`CompareStringOrdinal`), so a `LOCALAPPDATA` spelled in another case is still the default. - **The record names a custom store** with the cache's id: that folder is checked (pack and index heads whole, of this version, agreeing). If it is there, it is opened and every key is kept: the bug's fix. If another store is there now, it is gone and the cache starts over, as main. **When it cannot be reached within the startup deadline:** the primary cache is **kept byte for byte** and its lock released. The run uses a separate fallback cache that stays writable across launches. - `LONGSHOT_SHADER_STORE` set to a folder, or `=0`, behaves as before and wins over the record. No new switch: it is a fix. - Docs: `docs/dev/reference/architecture.md` (the store paragraph), `switches.md` (the `LONGSHOT_SHADER_STORE` row); contract comments in `vk_progcache.cpp` and `spirv_pack.h` (comment only). - Test: `tests/test_program_cache_store_record.py` with `tests/program_cache_store_record_test.cpp` builds the real `disk_init`, cut from the source, with the real `spirv_pack.h`, one process per start; `tests/test_spirv_pack.py`'s anchor follows the keep line's text. **Shader caches:** neither `vk_progcache.cpp` nor `spirv_pack.h` is in the shader-cache stamp (`builder/crates/build-compile/src/generated/shader_stamp.rs`: eden, sirit, compat, `vk_shader.cpp`, `vk_bank.cpp`, `vk_state.h`, checked on current main), and `kProgramCacheFormat` stays 3. An update keeps every translated program; in the game this PR's DLL kept all 47,867 of the base's program keys. The builder's preparation step runs again after the update, as for every renderer change. **Entry paths:** the launcher and `longshot-builder play` pass the variable (`game_env` / `configure_store`): main's behaviour, plus the record written. A version folder's game started by itself hands over to the builder: the same. A direct start with no builder above: the record. `--update` and Linux `update-game` are gone on main since #2762 (the launcher owns updates); an update in place keeps `cache/` and with it the record. Read first: `disk_init` in `gpu/vk/vk_progcache.cpp`, then `store_record`, `open_recorded`, `same_recorded_name` and `write_store_record`. #737 proposed `cache/longshot_shader_store.txt` for a different format. This PR uses `cache/longshot_shader_store_ref.txt`. #2410 tracks the cold start after deleting the default store. The follow-up bounds implicit recorded-store lookup to 750 ms. If that custom store is missing, unreadable, or too slow, startup releases the original cache's lock and opens a separate writable fallback cache. The fallback uses the default store when available and inline SPIR-V otherwise. A returning store can still reopen the original cache. An implicit lookup checks the generation under the store lock before opening it, so it cannot recreate a custom store that was cleared during the lookup. Warm/seed cache transfers carry the record and the fallback artifacts. The Windows regression fixture uses the game's UTF-8 manifest and changes the case of only a test-owned directory component. The record name ends in `_ref.txt` to distinguish it from the format proposed in #737. ## Testing **Tested:** Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2, in the game (Market, child, 16:9, uncapped, through our harness's fresh runtimes of a player-like build of main 22d0d2009 with this PR's `longshot_vk.dll` over it): - a builder-prepared folder started with no variable and the game's record there: all 47,867 keys kept, 0 programs translated in play, no "another shader store" line; - an old folder with no record, started by itself twice: main's line and behaviour at the first start (cache started over against the default store, the record written), warm at the second; - the record naming the cache's store at a folder that is not there: `longshot_programs.bin`, `longshot_programs.idx` and the record byte-identical after the run; - the default store's files deleted (on a copy, `LOCALAPPDATA` pointed at a job folder): made again, the cache started over, warm at the next start. The numbers are under Measurements. Game-free: - `python -I tests/test_program_cache_store_record.py --cxx <clang++>`: on Windows (llvm-mingw clang++ 20261104) PASS, 22 broken variants fail as they must, 9 not run (Linux-only cases); on Linux (WSL Ubuntu, clang++ and g++, as a non-root user) PASS, 29 broken variants fail with each compiler, 2 not run (Windows-only). Each variant is credited only by the case it targets. - The same test on main's `vk_progcache.cpp` (`--source`): fails (19 checks), as it must. Its deleted-default cases pass there, as they must (main's behaviour). - After merging main @ 8cc807971: the new test (Windows), `test_spirv_pack`, `test_program_cache_{index,format,reader,cleanup,one_variant}`, `test_descriptor_array_census`, `test_load_default`, `test_dev_packs`, `test_run_all_declarations` pass (`test_utf8_paths` skipped here: no cargo); `linux_syntax.sh gpu/vk/vk_progcache.cpp` ok; `mise run lint` passes. - `tests/run_all.py --jobs 4` on the merged head e7e905695: 682 passed, 24 failed, 186 skipped. All 24 fail on main on this Windows PC too: the 20 that failed on main 22d0d2009 in the checker's run (among them `test_switch_table`: `LONGSHOT_LAUNCHER_STARTUP` has no `switches.def` row), and `test_log_batch`, `test_log_levels`, `test_dev_update`, `test_windows_on_linux`, which fail the same way on main @ 8cc807971 here. None reads `vk_progcache.cpp`. - A second-opinion review (gpt-6.2-sol) ran on every round, 26 in all; its last points are under Risks, "Not covered". Follow-up at `b1717e29`: the Linux game-free regression passes with a bounded lookup on a locked store, a warm fallback on repeat launch, and the original program cache restored when the custom store becomes available. The developer cache transfer and shader-store tests passed; the full Linux renderer built against the shared base. The headless game smoke on Linux (RTX 3090, NVIDIA driver 620.70.06) confirmed custom store selection, missing-store fallback, return to the original cache after restoration, and default store recreation after a clear. The seeded program cache did not match this renderer’s translator, so the positive warm-key count was verified in the synthetic regression fixture. The builder eviction fixture also verified the live fallback lock. Windows runtime verification of the revised paths is still outstanding. **Still to test:** - Linux (Steam Deck or desktop, any GPU): prepare a folder with the builder (`longshot-builder dev build ... --cache <dir>`, or `LONGSHOT_CACHE` set, so the store is `<cache>/shader-store`), start it once through the builder, then start the game executable directly with no `LONGSHOT_SHADER_STORE`, expecting "the one the cache's longshot_shader_store_ref.txt names" in the log, the program keys kept and no "another shader store" line (by hand, on the Steam Deck or a Linux PC: the Test Farm's plan steps can't set up the folders, environment and files this needs, its comment says) - Linux: with a record naming the default store (`~/.cache/longshot/shaders`), delete that folder and start the game directly twice, expecting at the first start "prepared again" with the store made again and the record naming the new store, and at the second the keys of the first start kept (by hand, on the Steam Deck or a Linux PC: the Test Farm's plan steps can't set up the folders, environment and files this needs, its comment says) - NVIDIA and Intel on Windows: the first case above, expecting the same (start-up file logic only, no GPU path) (by hand) - Linux and the Steam Deck: a Market start of this PR and of main, expecting no crash at start-up and the store's log lines (@Beanstalk test it anyway: the farm's own alternative plan) ## Measurements **Verdict:** the bug's case goes from a cache emptied at the first start (582 programs translated in the first Market visit, a 41.8 s frame) to every prepared program kept (0 translated). No per-frame cost: the Market A/B is within noise, diagnostic with 3 pairs. The change runs once at start-up. Setup: Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2; a player-like build of main 22d0d2009 (`longshot.exe` 992fc0fd, `longshot_vk.dll` a1af7a34) prepared by the builder; this PR as its `longshot_vk.dll` alone over that build. Market, child, 16:9, uncapped (`HOS_FPS_MAX=240`), render thread on, 20 s window after the arrival; fps, CPU ms a frame and p99 are the window's; "translated in play" counts programs translated after the load started. Each table names the head it ran on. The last two rounds (dd9bfd0bf) changed only the Windows case comparison of the default store's name and the docs, and were not run in the game. The branch now has main @ 8cc807971 merged in; main's commits since 22d0d2009 change neither `vk_progcache.cpp` nor `spirv_pack.h` (the builder, the host's log folder, other renderer passes), so the start-up numbers still hold; the A/B was not run again. **The bug's case and the record** | A builder-prepared folder (keys at preparation: 47,867) started with no `LONGSHOT_SHADER_STORE` | Before: main @ 22d0d2009 | After: this PR @ 10d00286d | |---|---|---| | first start: keys kept | 0 ("another shader store (ae068cab, this one f8a742eb): prepared again") | 47,867 (the record's store) | | first start: programs translated in play | 751 (Hyrule warm-up), a 9.2 s frame | 0 in Market: admitted, 113.39 fps, 39.23 CPU ms, p99 17.13 ms, worst 30.6 ms, 0/0/0 frames over 50/100/250 ms | | next start, first Market visit: programs translated | 582, 1,455 waits for shaders or pipelines (64.7 s), one 41.8 s frame | (as above: 0) | **Old folders, deleted stores, a store out of reach** (cold-then-warm runs; each start a fresh run through the harness, with no variable) | Case | Before: main @ 22d0d2009 | After: this PR @ 10d00286d (first three) / 17c1c6f86 (last three) | |---|---|---| | old folder, no record: first start | the line "prepared again" (the analyst's runs above) | the same line and behaviour: 0 keys, 1,257 translated (11.2 s), the record written; admitted, 109.94 fps, worst 223.8 ms, 5/2/0 over 50/100/250 ms | | old folder: the next start | not run | 1,257 keys kept, 4 translated (41 ms); admitted, 114.09 fps, 38.75 CPU ms, p99 16.81 ms, worst 20.3 ms, 0/0/0 | | the record names the cache's store at a folder that is not there | not run (main has no record; it would start the cache over) | no store, run without the cache (1,206 translated, rejected as a cold run); programs.bin (149,266,003 B), programs.idx and the record byte-identical after | | the same, a custom store's name | not run | the same: all three files byte-identical | | the default store's files deleted (a copy through `LOCALAPPDATA`), the record naming it: first start | not run | main's line: the store made again, 0 keys, 1,201 translated (10.2 s), the record names the new store; admitted, 110.59 fps, worst 226.7 ms, 1/1/0 | | the same: the next start | not run | 1,201 keys kept, 53 translated (1.3 s); admitted, 111.89 fps, 39.70 CPU ms, p99 17.30 ms, worst 26.9 ms, 0/0/0 | The deleted-default runs redirected the AMD driver's own caches with `LOCALAPPDATA` too, so their numbers show behaviour, not speed. **The standard A/B** (Market, child, 3 alternating pairs, both arms warm through the variable: 47,867 keys, 0 translated in every run, all 6 runs admitted) | Median of 3 | Before: main @ 22d0d2009 | After: this PR @ 84e9cb9f3 | |---|---|---| | fps | 112.44 | 111.39 | | CPU ms a frame | 40.25 | 40.74 | | p99 frame ms | 17.77 | 17.52 | | worst frame ms (max of 3) | 27.5 | 24.2 | | frames over 50/100/250 ms | 0/0/0 | 0/0/0 | | game clock | 1.000 | 1.000 | | GPU ms a frame | 3.2 | 3.05 | -0.9 % fps and +1.2 % CPU ms: within Market's run-to-run spread on this PC (about 3 % fps and 5 % CPU ms with 3 pairs), so diagnostic, and no cost is seen. The code runs once in `disk_init` (one small read, two 16-byte head reads, a write when the record changes) and nothing per frame. The A/B ran at the first round's head; the later rounds changed only start-up branches. ## Risks - **What a player notices after updating:** nothing in a version folder (the builder names the store). A folder started by itself keeps its cache from the second start on, instead of losing it. - **The behaviour change:** a folder with no record is unchanged. A folder whose record names a custom store that can't be reached now runs **without the program cache, at every such start**, until the store is back or a start names a store (the launcher, the builder, or `LONGSHOT_SHADER_STORE`). Main dropped the cache once and was warm from the next start. A start without the cache translates every program again at its first draw (about 1,200 in a first Market visit here, 9-19 s of translation, multi-second frames). The log line names the store the cache wants. Who meets it: a folder prepared against a store on a drive that is not mounted, or a custom store deleted while the cache stays. - **What could break:** start-up only. A wrong choice keeps a cache unused or starts it over, as main does for other reasons; nothing is lost that main would keep. `LONGSHOT_SHADER_STORE` set by hand restores main's choice for a run; a revert is enough. - **The shader caches:** not invalidated (see Summary). **Not covered** (each from the reviews or the checks, left because no player's or harness path reaches it): - Windows: a concurrent repair of a crash-damaged custom store by another game folder can have its pack rename refused while this start reads the store's 16-byte heads (sol r13). The same window exists for any Longshot reading that store. - Linux: a custom store on a hard-mounted NFS share that is offline can block the probe at start-up; main never looks there (sol r15). - Linux: the default folder reached through a bind mount under another name, named by hand as `LONGSHOT_SHADER_STORE` at the preparation, then deleted: kept as a custom store out of reach every start, where main makes the default again (sol r16). No builder or launcher path names it so. - Linux: `XDG_CACHE_HOME` spelled through a `..` over a folder later removed, under a link: the same class as the bind mount (sol check-r3). - Windows file systems whose case tables differ from `CompareStringOrdinal`'s: NTFS volumes with XP-era or Vista-era `$UpCase` tables, exFAT's final sigma. Two names it calls one, or one it calls two, when a folder is missing (sol r20, r22). - Windows before 1903 (no UTF-8 code page): non-ASCII names compared as the game's other strings are. - The test on a machine whose `TEMP` is inside a folder made case-sensitive: `default-case` swaps the case of all of `LOCALAPPDATA` and fails on a correct tree (sol r23). - A Linux cache folder that is not writable (0555) with a writable cache file in it: the keys are kept, but no record can be written (sol r23). - The Windows test fixture has no UTF-8 manifest, so a `TEMP` outside the ANSI code page breaks its arguments; the shipped game is unaffected (sol check-r2, point 7). - Accepted after the review rounds: a recorded store's own lock held by another process (the store's normal wait); a recorded folder holding other files or unusual permissions (a read-only lock is out of reach: kept); damage a store's heads don't show (`Store::open` remakes it, as for a named store); special files or links inside a store folder; an unmount between the probe and `Store::open`; a cache replaced by another tool between the two head reads; a link retargeted since the record; a lock file that cannot be opened (two starts at once, fail-open as main) giving a record of another store, then taken as none; restored-store snapshots and seed-index pairing; the 4 KB record limit and the head-reread race untested; the test fixtures' 2^-32 id collisions; the guard that skips writing after a failed second read while out of reach is in the code but has no case of its own. - Inherited from main, listed as follow-ups: the cache lock is fail-open; on Linux a start that loses `flock()` leaks its descriptor until exit; a start that holds the lock but cannot open the cache for append keeps the lock with the cache off. - Not run: Linux and the Steam Deck in the game (WSL game-free only), NVIDIA and Intel GPUs, a real unmounted drive (a missing folder stood in), a real deleted default store (a copy through `LOCALAPPDATA` stood in), the Windows case-spelling fix in the game (game-free only; the final head's other code paths ran in the game at earlier heads, see Measurements). ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A 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] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Since #2629 / #2632 the builder prepares the shaders in a store of its own and names it to the
games it starts (LONGSHOT_SHADER_STORE). A game started without the variable opened the player's
default store, found the cache "in another shader store" and started it over: every prepared
program of the build was gone, and translated again at its first draw in play.

Every start that opens a store now writes its folder beside the cache
(longshot_shader_store.txt). A start with no variable opens that folder first when the store there
is the one the cache's head names. A cache whose store the start finds nowhere, with no record of
where it is, is left as it is and the start runs without it, as for a store that did not open.
A recorded store that is gone or was made again still starts the file over, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Answers the first review of the change (sol, r1):
- longshot_shader_store.txt now holds the store's id beside its folder, and a record of another
  store than the cache's head names (a write of it that failed) is taken as none: the file is
  kept, not started over against the default store.
- A recorded store is called gone only when its folder, or the folder above it, is there without
  it, or when another store is there now; a lookup that fails (no access, a drive not ready) is
  not known, and the file is kept.
- The folder is recorded absolute, and a drive's root keeps its separator.
- A start that goes without the cache gives the cache's lock back (also the older case of a store
  that did not open), so a builder's start meanwhile may take it.
- A file just copied from the store's copy of a store made again since starts over, as before.
- Path conversions that throw are caught (no record taken or written).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Answers the second review (sol, r2):
- A recorded folder that is not there at all (a drive or share not mounted, the mount point
  left) is not known: the cache is kept. Gone means the folder is there without spirv.pack, or
  another store is there now.
- A drive-relative folder that absolute() leaves relative is not recorded; on Linux a backslash
  at the end of a folder's name stays part of it.
- The decision to keep takes the record against the head as read then, not as read before the
  store was chosen.
- The lock is unlocked before its handle is closed (Windows), and LOCK_UN before close (Linux),
  so a start right after finds it free.
- The test: the store that does not open (the older keep path) gives the lock back too; a lookup
  that fails (Linux, not root) is not known; the stale record does not open its store.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Answers the third review (sol, r3):
- The recorded store is looked at also when it is the default one: a default folder not there
  at all (its drive not mounted, the mount point left) is not made again under it; the start goes
  without a store and keeps the file, as for a store that did not open.
- A record whose folder is not absolute (not one the game writes) is taken as none.
- On Linux a store folder whose name ends in a backslash is not recorded: Store::open takes that
  backslash for its separator.
- The test's variant for the decision says what it checks (the record's id); the head read again
  between the store's choice and the decision is argued in the code, not covered by a case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Answers the fourth review (sol, r4):
- A recorded folder that is there but has nothing of a store in it (neither its lock nor its
  index: a mount point whose volume is not mounted) is not known, and the cache is kept.
- Two spellings of one folder that is not there now compare equal (lexically normal).
- A record with a control character (a NUL) is taken as none.
- An extended Windows path (\?\...) is recorded as it is, with its separator.
- The test reads and writes the record in the system's code page on Windows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Answers the fifth review (sol, r5), its test point: on Windows the fixture wrote that record in
UTF-8, which another code page could refuse for its own reason, so the variant without the
control-character check could pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Round 2 of the job (the checker and the orchestrator): a folder whose cache names a store this
start cannot find, with no longshot_shader_store.txt at all (every folder prepared before the
record), ran without its program cache at every start: worse than main, which loses it once and
is warm from the next start. Such a folder now behaves as main: the cache starts over against the
store this start opened, and the record is written, so the next start is warm. The cache is kept
untouched, and the start runs without it, only when the record names the cache's very store and
that store is out of reach this run without being known to be gone (its folder not there, empty,
or not readable). A record of another store, a relative one or one with a control character is
taken as none, as is no record.

Also (sol, check round 1): the writer refuses every control character the reader refuses, so a
Linux store folder with a tab in its name gets no record rather than one the next start rejects.
The test's ids derived from a random store id can no longer be 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Answers sol round 6:
- A record is taken only when the folder has a cache of this translator whose head names the
  record's store. With no such cache (a translator update, or no cache) there is nothing to keep
  and the store is chosen as main does, so the default store's copy of a prepared cache is not
  passed over. The guard against keeping a file just copied from the store's copy is unreachable
  now (no record is taken then) and goes.
- The default store, when it is the recorded one, is looked at by its own name, not the record's
  spelling of it (which may not resolve).
- The record is read only from a plain file: a pipe there would block the start.
- The test checks that a start without the cache leaves no store open, keeps the no-record case's
  two random stores apart, and covers the translator update, the default's other spelling and
  the pipe (the last two on Linux).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Answers sol round 7: same_folder fell back to comparing names when the two folders were both
there and different, so a recorded store reached through a link and .. was taken for the default
(lexically the same name) and the cache started over against the default. The names are compared
only when the system cannot say. The test's translator-update variant now restores round 6's rule
alone, and a Linux case covers the link.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Answers sol round 8, by making the choice simpler rather than adding cases:
- The recorded store is looked at by the record's own spelling and never compared with the
  default. When it is out of reach this run (not known to be gone), no store is opened at all,
  not even the default (which would be made again under a mount point left empty), and the file is
  kept by the older "store that did not open" branch. The keep branch of round 2 and same_folder
  go. So no spelling of the default (a link, .., ., a folder removed later) can redirect a start.
- On Linux the record holds the folder canonical (links followed, . and .. gone), so a spelling
  through a folder removed later still resolves; a folder whose name ends in a backslash is
  recorded with a slash after it (Store::open takes it then) instead of not at all.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Answers sol round 9:
- A recorded store whose pack is not there is not known, whatever else is in its folder (an
  older store's lock under a mount point, the store's files deleted): the cache is kept. Gone means
  another store is there now (made again), as before.
- The keep holds also when there is no default store folder at all (no HOME / LOCALAPPDATA).
- A Linux store folder whose name ends in a backslash is not recorded again (Store::open reads
  that backslash as its separator, with or without a slash after it); such a folder starts as
  before the record existed.
- The test: no-HOME keep, the backslash folders with and without a slash, the link case started
  twice, and the no-record variant limited to starts without the variable.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The line now keeps the file also when the record's store is out of reach and there is no default
store folder (c8648c609); the source check looks for its new text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Answers sol round 10:
- A recorded store whose spirv.idx is not there is not known (kept): Store::open would make the
  store again over its pack, where main, not looking in that folder, leaves it as it is.
- The writer writes no record longer than the reader reads (4 KB), which the next start would
  take as none.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Answers sol round 11:
- The recorded store's pack and index heads are read before Store::open: a head not whole, of
  another version, or an index of another id than its pack is a store Store::open would make
  again over its pack (main, not looking there, leaves it), so it is not opened and the cache is
  kept; another store's pack there means the cache's store was made again (gone, as before).
- The cache's lock is given back only when the start goes without the cache because the record's
  store is out of reach. A start with no record whose store does not open keeps it to the end, as
  main does, so a second start beside it does not start the file over.
- The test: an index cut to nothing; the lock held in the no-record case; variants that change
  several places together.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Answers sol round 12: a recorded store whose head ids are zeroed (Store::open's "no store") was
taken for another store and the cache started over; it is not known now, and the cache is kept.
On Windows the probe reads the heads through open_shared, so a Longshot replacing the store's
files meanwhile is not refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Round 3 (the orchestrator, from sol check-r2 point 1): the record of the default store itself no
longer goes through the out-of-reach probe. The default is opened as main opens it, so its files
deleted (the launcher's Free up space, or by hand) mean the store is made again and the cache
starts over, warm again from the next start, instead of a start without the cache every time.
The out-of-reach rule stays for a store outside the default folder.

Also from check-r2: while the recorded store is out of reach the cache file is never made again
when its second read fails (point 2); a record with a blank line after it is no record (4); a DEL
is refused by the reader and the writer as other control characters (5); a Linux link whose name
ends in a backslash is not recorded by its target (3, the check runs before links are followed).
The test: the default store's files and folder deleted (cold, then warm), the three record
cases, the stale-record fixture's ids distinct by construction (6), and each broken variant
credited only when the case it names fails (8).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Answers sol round 14:
- A store folder that is not there now is put in the record's form by name (its . and .. taken
  out), so the default named through XDG_CACHE_HOME=<cache>/. and since deleted still matches its
  record, and starts over as main instead of being kept.
- A Linux record ending in a backslash is taken as none (Store::open would read that backslash as
  its separator and open a store beside the folder); the writer never writes one.
- The test: every store a case makes has an id of its own; a Linux store folder with a DEL gets no
  record (the writer's check); the /. default and the backslash record cases; the store-creation
  variant credited only by its own case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Answers sol round 15: the record's folder is put in the record's form too before it is compared
with the default's, and that form is weakly canonical on Linux (the links of the part that is
there followed, the rest by name), so a default whose last folder was deleted, recorded through a
spelling with /. or through a linked parent, still matches its record and starts over as main.
Tests: both cases, with a broken variant each.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Round 3b (from sol check-r3): on Windows the default store's folder and its record are compared
as the file system compares names, without case (CompareStringOrdinal), so a LOCALAPPDATA spelled
in another case after the whole shaders folder was deleted is still the default: made again, the
cache starts over, as main. The docs now say that a cache whose head already names the default
store keeps its keys and gains a record, and only a cache naming another store starts over.
Test: the case-folded LOCALAPPDATA case, with a broken variant.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Answers the 3b review (sol r17): the game's char strings are UTF-8 (its manifest), so the
comparison converts them with CP_UTF8, as tests/test_utf8_paths.py requires (CP_ACP failed it).
The docs say that a custom store recorded for a cache of this translator is opened when it is
there whole, and that a cache of another translator starts over as before. The test's case swap
touches ASCII letters only, and a store made again with the deleted one's id by chance passes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Answers sol r18: the case-free comparison converts with MB_ERR_INVALID_CHARS, and a name that is
not UTF-8 (a store path of another code page) is compared byte for byte, so two such names no
longer both turn into U+FFFD and match. The docs say that a store that does not open at all (its
lock file not writable, a file in its place) keeps the cache for a later run, as before. The
Windows case checks the record after its first start and the reset after its second.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Answers sol r19: the docs say a store that does not open keeps a cache of this translator (one of
another translator starts over). The Windows case runs only with an ASCII temp folder (the fixture
has no UTF-8 manifest, so a name of another code page is compared byte for byte there, as the game
compares a name that is not UTF-8), and it checks that the rewritten cache's head names the new
store.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A case-sensitive folder on Windows (fsutil's per-directory flag, a Samba share) can hold another store under that name;
when one is there the file system decides. Test: a case-sensitive folder with the recorded store and the default beside
it under the name in another case; a broken variant without the guard fails it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merge main into perf/shader-store-self-start
Some checks failed
CI / What the change needs (pull_request) Successful in 14s
CI / Third-party parts and guide screenshots (pull_request) Failing after 18s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 19s
PR description / Title and description (pull_request_target) Successful in 7s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 2m29s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 4m11s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 5m44s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 5m32s
CI / Website build and checks (pull_request) Failing after 38s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 30m36s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 43m13s
beanstalk/approval approved by klimovich008 (reviewed)
beanstalk/any 1/1 fail
e7e905695b
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Member

Tested in game: Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2, Market (child): a builder-prepared folder started with no LONGSHOT_SHADER_STORE kept all 47,867 program keys and translated 0 programs in play (main: the cache started over, 582 translated in the first Market visit, a 41.8 s frame); an old folder with no record behaved as main (one cold start, then warm); a record naming an unreachable store left the cache files byte-identical; a deleted default store was made again, then warm. The Market A/B (3 pairs) is within noise. Runs at heads 84e9cb9f3, 10d00286d and 17c1c6f86; the last rounds changed the Windows case comparison and docs only.

Tested in game: Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2, Market (child): a builder-prepared folder started with no LONGSHOT_SHADER_STORE kept all 47,867 program keys and translated 0 programs in play (main: the cache started over, 582 translated in the first Market visit, a 41.8 s frame); an old folder with no record behaved as main (one cold start, then warm); a record naming an unreachable store left the cache files byte-identical; a deleted default store was made again, then warm. The Market A/B (3 pairs) is within noise. Runs at heads 84e9cb9f3, 10d00286d and 17c1c6f86; the last rounds changed the Windows case comparison and docs only.
Author
Member

@Beanstalk linux, any GPU (the Steam Deck if free), this PR's head. Two start-up cases this PC can't run (Windows here; Linux was only tested game-free). Uncapped and windowed if a run is timed: frame_rate_cap = 6, vsync = 2, frame_generation = 0. No A/B is needed: the change runs once at start-up.

  1. A direct start after a builder prepare. Build and prepare a game folder with the builder so the shaders go into the builder cache's store (LONGSHOT_CACHE set: <cache>/shader-store). Start it once through longshot-builder play (it passes LONGSHOT_SHADER_STORE), then quit. Then start the game executable directly, with no LONGSHOT_SHADER_STORE in its environment, and walk into Market. Expected:
    • cache/longshot_shader_store.txt exists after the first start: one line, an 8-hex id and the absolute store folder;
    • the direct start's log says shader store: the one the cache's longshot_shader_store.txt names and has no another shader store line;
    • the program cache keeps the prepared keys, and few or no programs are translated in play (on main the same start says "prepared again" and translates hundreds).
  2. A deleted default store, then two starts. In a game folder whose record names the default store (~/.cache/longshot/shaders; a folder started directly once with no variable and no builder cache writes that), quit, delete ~/.cache/longshot/shaders, then start the game directly twice with no variable. Expected:
    • first start: its programs are in another shader store (...): prepared again, the store made again under ~/.cache/longshot/shaders, and the record naming the new store's id;
    • second start: no another shader store line, the program keys of the first start kept.

Please attach both starts' longshot_log.txt (or diagnostics/logs/) and the record file's contents.

@Beanstalk linux, any GPU (the Steam Deck if free), this PR's head. Two start-up cases this PC can't run (Windows here; Linux was only tested game-free). Uncapped and windowed if a run is timed: `frame_rate_cap = 6`, `vsync = 2`, `frame_generation = 0`. No A/B is needed: the change runs once at start-up. 1. **A direct start after a builder prepare.** Build and prepare a game folder with the builder so the shaders go into the builder cache's store (`LONGSHOT_CACHE` set: `<cache>/shader-store`). Start it once through `longshot-builder play` (it passes `LONGSHOT_SHADER_STORE`), then quit. Then start the game executable directly, with **no** `LONGSHOT_SHADER_STORE` in its environment, and walk into Market. Expected: - `cache/longshot_shader_store.txt` exists after the first start: one line, an 8-hex id and the absolute store folder; - the direct start's log says `shader store: the one the cache's longshot_shader_store.txt names` and has no `another shader store` line; - the program cache keeps the prepared keys, and few or no programs are translated in play (on main the same start says "prepared again" and translates hundreds). 2. **A deleted default store, then two starts.** In a game folder whose record names the default store (`~/.cache/longshot/shaders`; a folder started directly once with no variable and no builder cache writes that), quit, delete `~/.cache/longshot/shaders`, then start the game directly twice with no variable. Expected: - first start: `its programs are in another shader store (...): prepared again`, the store made again under `~/.cache/longshot/shaders`, and the record naming the new store's id; - second start: no `another shader store` line, the program keys of the first start kept. Please attach both starts' `longshot_log.txt` (or `diagnostics/logs/`) and the record file's contents.
Member
Beanstalk test farm · an earlier run: commit e7e9056, run 2 (the newer results are in a comment below)

Commit e7e9056 · approved by klimovich008 (reviewed) · dashboard

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

The change failed on the any target, based on the GTX 980 report. In Hyrule Field, frame time p99 worsened from 39.78 to 48.36 ms (+21.6%), exceeding the 15% limit. The Intel UHD 630 report was inconclusive: both baseline and candidate crashed on every Hyrule Field start, suggesting a PC-specific issue rather than a change-specific failure.

Done (started 2026-11-28 22:40 UTC, last report 02:54 UTC). Run 2: re-planned by klimovich008. Comment @Beanstalk to run it again.

Target Result Reports Frame time p99 (ms), main → PR VRAM peak (MB) Crashes
any ❌ fail (an outlier) 2 1 2 21.5 → 20.2 (−6%) 738 → 752 (+2%) 2 PR runs

Why it failed

  • any: hyrule-field field.frametime_p99_ms.max_delta_pct: 39.8 → 48.4 (+21.6%); limit 15.0

Couldn't be judged: the tester's PC could not finish the test. The farm tries another PC, or the same one after a fix; it says nothing about the PR on its own.

  • any, report 2: Insufficient frame-time evidence for 2 required comparison(s). See rule results.
What was tested

What will be tested · default plan (AI failed: the summary says 'manual': the farm is unattended, so it must describe only what the plan's steps do (no one looks at, checks or does anything by hand); write it again)

The AI plan failed: the summary says 'manual': the farm is unattended, so it must describe only what the plan's steps do (no one looks at, checks or does anything by hand); write it again; using the default plan.

  • Where: any (any PC, 1-2 reports).
  • title: from the title screen, then measure title for 20 s (after 5 s warm-up); 2 runs on each side.
  • hyrule-field: from the repository's save kokiri-start, then teleport to Hyrule Field, measure field for 60 s (after 10 s warm-up); 2 runs on each side.
  • Measured: crashes, boot time, frame times, stutters and hitches, VRAM use, the game's log.
  • The PR fails if: it crashes; or peak VRAM is more than 10% above main; or frame time (p99) is more than 15% above main.
  • Time: about 47 min of game runs per tester (8 game starts), plus the two builds.
Measurements on `any`, for the PR description

Verdict: fail on any (2 reports): hyrule-field field.frametime_p99_ms.max_delta_pct (+21.6%) failed.

Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu+xess NVIDIA GeForce GTX 980, 582.78.0 Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz, 32 GB RAM; 2: windows+intel+intel-proprietary+igpu Intel(R) UHD Graphics 630, 0.404.2115 Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz, 8 GB RAM
Scene: title, from the title screen; hyrule-field, from the repository's save kokiri-start; each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); title: 2 game starts a side, title 20 s after 5 s warm-up; hyrule-field: 2 game starts a side, field 60 s after 10 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (@Beanstalk on this PR runs it again)

Before: main @ 8cc8079 After: this PR @ e7e9056
title · title · peak VRAM (MB) 737.5 752.5 (+2%)
title · title · frame time (p99) (ms) 21.5 20.2 (−6%)
hyrule-field · field · peak VRAM (MB) 2,579 2,485 (−4%)
hyrule-field · field · frame time (p99) (ms) 39.8 48.4 (+22%)

Flags and settings

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

As Markdown for the PR description:

## Measurements

**Verdict:** fail on any (2 reports): `hyrule-field field.frametime_p99_ms.max_delta_pct (+21.6%)` failed.

Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu+xess `NVIDIA GeForce GTX 980, 582.78.0` `Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz, 32 GB RAM`; 2: windows+intel+intel-proprietary+igpu `Intel(R) UHD Graphics 630, 0.404.2115` `Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz, 8 GB RAM`  
Scene: title, from the title screen; hyrule-field, from the repository's save kokiri-start; each cell's settings and switches as the table names them  
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); title: 2 game starts a side, title 20 s after 5 s warm-up; hyrule-field: 2 game starts a side, field 60 s after 10 s warm-up; each number the median of the runs, then of 2 reports  
How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again)

| | Before: main @ 8cc8079 | After: this PR @ e7e9056 |
|---|---|---|
| title · title · peak VRAM (MB) | 737.5 | 752.5 (+2%) |
| title · title · frame time (p99) (ms) | 21.5 | 20.2 (−6%) |
| hyrule-field · field · peak VRAM (MB) | 2,579 | 2,485 (−4%) |
| hyrule-field · field · frame time (p99) (ms) | 39.8 | 48.4 (+22%) |

**Flags and settings**

None: the plan varied no setting, switch or build option.
The testers' hardware
Target Report Ran on
any 1 windows+nvidia+nvidia-proprietary+dgpu+xess NVIDIA GeForce GTX 980, 582.78.0 Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz, 32 GB RAM
any 2 windows+intel+intel-proprietary+igpu Intel(R) UHD Graphics 630, 0.404.2115 Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz, 8 GB RAM
<!-- beanstalk:previous --> <details><summary>Beanstalk test farm · an earlier run: commit <code>e7e9056</code>, run 2 (the newer results are in a comment below)</summary> Commit `e7e9056` · approved by klimovich008 (reviewed) · [dashboard](https://beanstalk.magicbean.dev/prs/2768) > **Summary**, written by AI (`gpt-6.1-terra`) from the numbers below: > > The change failed on the any target, based on the GTX 980 report. In Hyrule Field, frame time p99 worsened from 39.78 to 48.36 ms (+21.6%), exceeding the 15% limit. The Intel UHD 630 report was inconclusive: both baseline and candidate crashed on every Hyrule Field start, suggesting a PC-specific issue rather than a change-specific failure. Done (started 2026-11-28 22:40 UTC, last report 02:54 UTC). Run 2: re-planned by klimovich008. Comment `@Beanstalk` to run it again. | Target | Result | Reports | Frame time p99 (ms), main → PR | VRAM peak (MB) | Crashes | | --- | --- | --- | --- | --- | --- | | `any` | ❌ fail (an outlier) | 2 [1](https://beanstalk.magicbean.dev/reports/rp_2ed9136f6235983d) [2](https://beanstalk.magicbean.dev/reports/rp_df977acdf1687637) | 21.5 → 20.2 (−6%) | 738 → 752 (+2%) | 2 PR runs | **Why it failed** - `any`: `hyrule-field` `field.frametime_p99_ms.max_delta_pct`: `39.8 → 48.4 (+21.6%); limit 15.0` **Couldn't be judged**: the tester's PC could not finish the test. The farm tries another PC, or the same one after a fix; it says nothing about the PR on its own. - `any`, [report 2](https://beanstalk.magicbean.dev/reports/rp_df977acdf1687637): `Insufficient frame-time evidence for 2 required comparison(s). See rule results.` <details><summary>What was tested</summary> **What will be tested** · default plan (AI failed: the summary says 'manual': the farm is unattended, so it must describe only what the plan's steps do (no one looks at, checks or does anything by hand); write it again) The AI plan failed: the summary says 'manual': the farm is unattended, so it must describe only what the plan's steps do (no one looks at, checks or does anything by hand); write it again; using the default plan. - **Where:** any (any PC, 1-2 reports). - **title:** from the title screen, then measure title for 20 s (after 5 s warm-up); 2 runs on each side. - **hyrule-field:** from the repository's save `kokiri-start`, then teleport to Hyrule Field, measure field for 60 s (after 10 s warm-up); 2 runs on each side. - **Measured:** crashes, boot time, frame times, stutters and hitches, VRAM use, the game's log. - **The PR fails if:** it crashes; or peak VRAM is more than 10% above main; or frame time (p99) is more than 15% above main. - **Time:** about 47 min of game runs per tester (8 game starts), plus the two builds. </details> <details><summary>Measurements on `any`, for the PR description</summary> **Verdict:** fail on any (2 reports): `hyrule-field field.frametime_p99_ms.max_delta_pct (+21.6%)` failed. Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu+xess `NVIDIA GeForce GTX 980, 582.78.0` `Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz, 32 GB RAM`; 2: windows+intel+intel-proprietary+igpu `Intel(R) UHD Graphics 630, 0.404.2115` `Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz, 8 GB RAM` Scene: title, from the title screen; hyrule-field, from the repository's save kokiri-start; each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); title: 2 game starts a side, title 20 s after 5 s warm-up; hyrule-field: 2 game starts a side, field 60 s after 10 s warm-up; each number the median of the runs, then of 2 reports How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) | | Before: main @ 8cc8079 | After: this PR @ e7e9056 | |---|---|---| | title · title · peak VRAM (MB) | 737.5 | 752.5 (+2%) | | title · title · frame time (p99) (ms) | 21.5 | 20.2 (−6%) | | hyrule-field · field · peak VRAM (MB) | 2,579 | 2,485 (−4%) | | hyrule-field · field · frame time (p99) (ms) | 39.8 | 48.4 (+22%) | **Flags and settings** None: the plan varied no setting, switch or build option. As Markdown for the PR description: ```markdown ## Measurements **Verdict:** fail on any (2 reports): `hyrule-field field.frametime_p99_ms.max_delta_pct (+21.6%)` failed. Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu+xess `NVIDIA GeForce GTX 980, 582.78.0` `Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz, 32 GB RAM`; 2: windows+intel+intel-proprietary+igpu `Intel(R) UHD Graphics 630, 0.404.2115` `Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz, 8 GB RAM` Scene: title, from the title screen; hyrule-field, from the repository's save kokiri-start; each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); title: 2 game starts a side, title 20 s after 5 s warm-up; hyrule-field: 2 game starts a side, field 60 s after 10 s warm-up; each number the median of the runs, then of 2 reports How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) | | Before: main @ 8cc8079 | After: this PR @ e7e9056 | |---|---|---| | title · title · peak VRAM (MB) | 737.5 | 752.5 (+2%) | | title · title · frame time (p99) (ms) | 21.5 | 20.2 (−6%) | | hyrule-field · field · peak VRAM (MB) | 2,579 | 2,485 (−4%) | | hyrule-field · field · frame time (p99) (ms) | 39.8 | 48.4 (+22%) | **Flags and settings** None: the plan varied no setting, switch or build option. ``` </details> <details><summary>The testers' hardware</summary> | Target | Report | Ran on | | --- | --- | --- | | `any` | [1](https://beanstalk.magicbean.dev/reports/rp_2ed9136f6235983d) | windows+nvidia+nvidia-proprietary+dgpu+xess `NVIDIA GeForce GTX 980, 582.78.0` `Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz, 32 GB RAM` | | `any` | [2](https://beanstalk.magicbean.dev/reports/rp_df977acdf1687637) | windows+intel+intel-proprietary+igpu `Intel(R) UHD Graphics 630, 0.404.2115` `Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz, 8 GB RAM` | </details> </details>
Author
Member

@Beanstalk test it anyway: the alternative plan (a Market start of this PR and of main on Linux and the Steam Deck, failing on a crash, noting the store's start-up lines) is useful as a Linux start-up check. The two sequences move to Still to test as by-hand runs.

@Beanstalk test it anyway: the alternative plan (a Market start of this PR and of main on Linux and the Steam Deck, failing on a crash, noting the store's start-up lines) is useful as a Linux start-up check. The two sequences move to Still to test as by-hand runs.
Author
Member
@review
BeanBot requested changes 2026-11-28 23:29:30 +00:00
Dismissed
BeanBot left a comment

Recommendation: Request changes. The fix preserves prepared programs in the reported Windows case, but an unreachable recorded store can block Linux startup or cause shader compilation on every direct start. The Linux game paths also still need validation.

A direct start can reuse the builder's shader store and prepared program cache. The added record and probing logic preserve that cache when its store is unavailable, but can leave affected runs cold indefinitely or block on an offline filesystem.

Blocking (2): must change before merging.

  1. L1 gpu/vk/vk_progcache.cpp:399: The synchronous probe can hang startup indefinitely on an unavailable hard-mounted network store. (more on the line) Do: Avoid putting an unbounded remote-filesystem probe on the startup path; arrange a bounded or asynchronous lookup with a usable fallback.
  2. L2 gpu/vk/vk_progcache.cpp:533: Deleting a recorded custom store leaves every subsequent direct start without a disk cache, with no automatic recovery. (more on the line) Do: Keep the original cache for a potentially returning store, but use a separate writable fallback cache and default store when it is unavailable, so later starts can be warm.

Should fix (2): not blocking, but worth doing before merging.

  • L3 tests/program_cache_store_record_test.cpp:58: The Windows fixture does not use the game's UTF-8 process configuration, so the new check fails for some valid temporary paths. (more on the line) Do: Give the fixture the same UTF-8 manifest as the game, or accept wide arguments and convert paths consistently to UTF-8.
  • L4 tests/test_program_cache_store_record.py:401: The Windows case-fold test changes the case of the entire temporary path, including potentially case-sensitive ancestors. (more on the line) Do: Change the case only of a test-owned component known to be case-insensitive, or skip this case when its ancestors are case-sensitive.

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L5 gpu/vk/vk_progcache.cpp:526: The Linux game paths for selecting the recorded store and recovering a deleted default store have not yet been exercised. (more on the line) Do: Run the two documented direct-start sequences in game on Linux or Steam Deck and report the cache and log results.

@fix can do L1, L2, L3 and L4.

Questions (1) (not confirmed from the code; they don't hold the recommendation)

  • How will the shared record filename be reconciled if the related #737 is merged?

Checks: Failing on this head, which is behind its base, where they pass: CI / Third-party parts and guide screenshots (pull_request), CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request), CI / Website build and checks (pull_request), CI / Game-free checks (run_all.py, part 1/2) (pull_request). @rebase (or @fix) brings it up to date and runs them again; not held against it. Still running: CI / Game-free checks (run_all.py, part 2/2) (pull_request).

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

Does it help: Yes: the author's Windows game run kept 47,867 prepared keys and translated none in Market; main discarded the cache and translated 582 programs on the next Market visit, including a 41.8-second frame. The three-pair warm A/B was within the reported noise. Linux game validation remains outstanding.

Other systems: The selection runs at cache initialization on Windows and Linux, independently of GPU vendor. Windows AMD was tested in game; Linux and Steam Deck were tested only through game-free checks, and Windows NVIDIA and Intel remain untested. An offline hard-mounted Linux filesystem can block the new probe.

Switches: No switch added or removed. LONGSHOT_SHADER_STORE remains authoritative when set; when unset, its default selection now first consults the cache's record.

Reviewed: e7e905695b against 8cc8079713: Read AGENTS.md, CONTRIBUTING.md, the PR template, standards, the renderer diff and surrounding cache/store code, the new C++ fixture and test harness, documentation and test diffs, and commit history. The checkout has no docs/review-checklist.md or adjacent Tooling AGENTS.md. Skimmed the long test's individual variants and the unchanged remainder of the renderer and store files; no generated files or recorded runs were added.; nothing run (a code review).

Checked and fine:

  • The record is used only when its ID matches a cache of the current translator.
  • An explicit LONGSHOT_SHADER_STORE overrides the record, and compressed program caches bypass it.
  • Changed commits record AI assistance; no game-derived output or generated shader files appear in the diff.
  • The reported game-free test includes a main-source failure and checks that prepared keys survive.

Testing: Read-only review; no builds, tests or project scripts were run. The PR reports Windows game runs and Linux and Windows game-free checks; one head CI check is still running.

Overlaps and merge order: #737 proposes the same record filename with different contents; coordinate the filename before both merge.


Automated code review by BeanBot (gpt-6.1-terra), asked for by klimovich008. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The fix preserves prepared programs in the reported Windows case, but an unreachable recorded store can block Linux startup or cause shader compilation on every direct start. The Linux game paths also still need validation. A direct start can reuse the builder's shader store and prepared program cache. The added record and probing logic preserve that cache when its store is unavailable, but can leave affected runs cold indefinitely or block on an offline filesystem. **Blocking (2)**: must change before merging. 1. **L1** `gpu/vk/vk_progcache.cpp:399`: The synchronous probe can hang startup indefinitely on an unavailable hard-mounted network store. (more on the line) **Do:** Avoid putting an unbounded remote-filesystem probe on the startup path; arrange a bounded or asynchronous lookup with a usable fallback. 2. **L2** `gpu/vk/vk_progcache.cpp:533`: Deleting a recorded custom store leaves every subsequent direct start without a disk cache, with no automatic recovery. (more on the line) **Do:** Keep the original cache for a potentially returning store, but use a separate writable fallback cache and default store when it is unavailable, so later starts can be warm. **Should fix (2)**: not blocking, but worth doing before merging. - **L3** `tests/program_cache_store_record_test.cpp:58`: The Windows fixture does not use the game's UTF-8 process configuration, so the new check fails for some valid temporary paths. (more on the line) **Do:** Give the fixture the same UTF-8 manifest as the game, or accept wide arguments and convert paths consistently to UTF-8. - **L4** `tests/test_program_cache_store_record.py:401`: The Windows case-fold test changes the case of the entire temporary path, including potentially case-sensitive ancestors. (more on the line) **Do:** Change the case only of a test-owned component known to be case-insensitive, or skip this case when its ancestors are case-sensitive. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L5** `gpu/vk/vk_progcache.cpp:526`: The Linux game paths for selecting the recorded store and recovering a deleted default store have not yet been exercised. (more on the line) **Do:** Run the two documented direct-start sequences in game on Linux or Steam Deck and report the cache and log results. `@fix` can do L1, L2, L3 and L4. **Questions (1)** (not confirmed from the code; they don't hold the recommendation) - How will the shared record filename be reconciled if the related #737 is merged? **Checks:** Failing on this head, which is behind its base, where they pass: `CI / Third-party parts and guide screenshots (pull_request)`, `CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request)`, `CI / Website build and checks (pull_request)`, `CI / Game-free checks (run_all.py, part 1/2) (pull_request)`. `@rebase` (or `@fix`) brings it up to date and runs them again; not held against it. Still running: `CI / Game-free checks (run_all.py, part 2/2) (pull_request)`. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes: the author's Windows game run kept 47,867 prepared keys and translated none in Market; main discarded the cache and translated 582 programs on the next Market visit, including a 41.8-second frame. The three-pair warm A/B was within the reported noise. Linux game validation remains outstanding. **Other systems:** The selection runs at cache initialization on Windows and Linux, independently of GPU vendor. Windows AMD was tested in game; Linux and Steam Deck were tested only through game-free checks, and Windows NVIDIA and Intel remain untested. An offline hard-mounted Linux filesystem can block the new probe. **Switches:** No switch added or removed. LONGSHOT_SHADER_STORE remains authoritative when set; when unset, its default selection now first consults the cache's record. **Reviewed:** e7e905695bb4 against 8cc8079713e3: Read AGENTS.md, CONTRIBUTING.md, the PR template, standards, the renderer diff and surrounding cache/store code, the new C++ fixture and test harness, documentation and test diffs, and commit history. The checkout has no docs/review-checklist.md or adjacent Tooling AGENTS.md. Skimmed the long test's individual variants and the unchanged remainder of the renderer and store files; no generated files or recorded runs were added.; nothing run (a code review). **Checked and fine:** - The record is used only when its ID matches a cache of the current translator. - An explicit LONGSHOT_SHADER_STORE overrides the record, and compressed program caches bypass it. - Changed commits record AI assistance; no game-derived output or generated shader files appear in the diff. - The reported game-free test includes a main-source failure and checks that prepared keys survive. **Testing:** Read-only review; no builds, tests or project scripts were run. The PR reports Windows game runs and Linux and Windows game-free checks; one head CI check is still running. **Overlaps and merge order:** #737 proposes the same record filename with different contents; coordinate the filename before both merge. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by klimovich008. Nothing was run; a maintainer decides.</sub>
@ -236,0 +396,4 @@
return ec ? -1 : st.type() == want ? 1 : 0;
};
const int pack = at(dir / "spirv.pack", fs::file_type::regular);
if (pack < 0) return RecordedStore::unknown;
Member

L1 (blocking): The synchronous probe can hang startup indefinitely on an unavailable hard-mounted network store.

When: A direct-start folder has a valid record pointing to a Linux hard-mounted NFS store whose server is offline. The filesystem status or head read waits for the server before disk_init can fall back; main never accessed that custom path.

Do: Avoid putting an unbounded remote-filesystem probe on the startup path; arrange a bounded or asynchronous lookup with a usable fallback.

**L1** (blocking): The synchronous probe can hang startup indefinitely on an unavailable hard-mounted network store. *When:* A direct-start folder has a valid record pointing to a Linux hard-mounted NFS store whose server is offline. The filesystem status or head read waits for the server before disk_init can fall back; main never accessed that custom path. **Do:** Avoid putting an unbounded remote-filesystem probe on the startup path; arrange a bounded or asynchronous lookup with a usable fallback.
@ -277,0 +523,4 @@
!ec));
} catch (const std::exception&) {
}
}
Member

L5 (should fix): The Linux game paths for selecting the recorded store and recovering a deleted default store have not yet been exercised.

When: A Linux or Steam Deck direct start may encounter filesystem behavior that the synthetic WSL fixture does not reproduce; the submitted game evidence covers Windows only.

Do: Run the two documented direct-start sequences in game on Linux or Steam Deck and report the cache and log results.

**L5** (should fix): The Linux game paths for selecting the recorded store and recovering a deleted default store have not yet been exercised. *When:* A Linux or Steam Deck direct start may encounter filesystem behavior that the synthetic WSL fixture does not reproduce; the submitted game evidence covers Windows only. **Do:** Run the two documented direct-start sequences in game on Linux or Steam Deck and report the cache and log results.
@ -277,0 +530,4 @@
record_unknown = at == RecordedStore::unknown;
}
// (a recorded store outside the default folder out of reach this run, not known to be gone: no store at all, not even
// the default. The file is then kept below, as for a store that did not open, for the start that reaches the store
Member

L2 (blocking): Deleting a recorded custom store leaves every subsequent direct start without a disk cache, with no automatic recovery.

When: A copied game folder's recorded builder cache is permanently deleted. Each start classifies the missing pack as unknown and returns without writing a cache, so every session recompiles shaders; the reported run translates about 1,200 programs with multi-second frames, whereas main becomes warm after one cold start.

Do: Keep the original cache for a potentially returning store, but use a separate writable fallback cache and default store when it is unavailable, so later starts can be warm.

**L2** (blocking): Deleting a recorded custom store leaves every subsequent direct start without a disk cache, with no automatic recovery. *When:* A copied game folder's recorded builder cache is permanently deleted. Each start classifies the missing pack as unknown and returns without writing a cache, so every session recompiles shaders; the reported run translates about 1,200 programs with multi-second frames, whereas main becomes warm after one cold start. **Do:** Keep the original cache for a potentially returning store, but use a separate writable fallback cache and default store when it is unavailable, so later starts can be warm.
@ -0,0 +55,4 @@
spirv_pack::Store s;
if (!s.open(argv[2])) return std::puts("FAIL: the store did not open"), 1;
const uint32_t w[4] = {0x07230203, 0x00010000, 1, 2};
if (s.put(w, 4) < 0) return std::puts("FAIL: no blob put"), 1;
Member

L3 (should fix): The Windows fixture does not use the game's UTF-8 process configuration, so the new check fails for some valid temporary paths.

When: When TEMP contains characters outside the active Windows ANSI code page, Python passes the Unicode path to the fixture, but its narrow argv and file APIs cannot represent it; store creation or startup fails before the behavior under test is checked.

Do: Give the fixture the same UTF-8 manifest as the game, or accept wide arguments and convert paths consistently to UTF-8.

**L3** (should fix): The Windows fixture does not use the game's UTF-8 process configuration, so the new check fails for some valid temporary paths. *When:* When TEMP contains characters outside the active Windows ANSI code page, Python passes the Unicode path to the fixture, but its narrow argv and file APIs cannot represent it; store creation or startup fails before the behavior under test is checked. **Do:** Give the fixture the same UTF-8 manifest as the game, or accept wide arguments and convert paths consistently to UTF-8.
@ -0,0 +398,4 @@
check("the default with LOCALAPPDATA as it is: the record written (the case below needs it)",
recorded(c, b, c.default), c.record())
shutil.rmtree(c.default)
other_case = "".join(ch.swapcase() if ch.isascii() else ch for ch in c.env["LOCALAPPDATA"]) # (ASCII only)
Member

L4 (should fix): The Windows case-fold test changes the case of the entire temporary path, including potentially case-sensitive ancestors.

When: If TEMP is inside a case-sensitive directory, swapping an ancestor's case points LOCALAPPDATA at a different or missing path, so the test fails even when the default-store comparison is correct.

Do: Change the case only of a test-owned component known to be case-insensitive, or skip this case when its ancestors are case-sensitive.

**L4** (should fix): The Windows case-fold test changes the case of the entire temporary path, including potentially case-sensitive ancestors. *When:* If TEMP is inside a case-sensitive directory, swapping an ancestor's case points LOCALAPPDATA at a different or missing path, so the test fails even when the default-store comparison is correct. **Do:** Change the case only of a test-owned component known to be case-insensitive, or skip this case when its ancestors are case-sensitive.
Assisted-by: Codex
fix(dev): carry shader store records with program caches
Some checks failed
beanstalk/approval not approved yet
PR description / Title and description (pull_request_target) Successful in 11s
CI / What the change needs (pull_request) Successful in 15s
CI / Third-party parts and guide screenshots (pull_request) Failing after 19s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 16s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 3m32s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 2m0s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 4m38s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 4m51s
CI / Website build and checks (pull_request) Failing after 34s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
48fa6ef230
Assisted-by: Codex
Member

Beanstalk test farm

Commit d132f22 · 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 `d132f22` · approved by nobody yet · [dashboard](https://beanstalk.magicbean.dev/prs/2768) A member of `BigBeans` can review this commit and comment `@Beanstalk` to test it.
Owner
@review
BeanBot left a comment

Recommendation: Request changes. A recorded network store can block startup indefinitely, and a deleted custom store leaves direct starts repeatedly rebuilding shaders without automatic recovery. The Windows test fixture also still fails on some valid temporary paths.

The change preserves prepared program caches when a game is started directly and carries the store record with development cache transfers. It adds startup file probing and can leave a game without a disk cache when its recorded custom store is unavailable.

Blocking (2): must change before merging.

  1. L1 gpu/vk/vk_progcache.cpp:399: The synchronous probe can hang startup indefinitely on an unavailable hard-mounted network store. When: A direct-start folder has a valid record pointing to a Linux hard-mounted NFS store whose server is offline. The filesystem status or head read waits for the server before disk_init can fall back; main never accessed that custom path. Do: Avoid putting an unbounded remote-filesystem probe on the startup path; arrange a bounded or asynchronous lookup with a usable fallback.
  2. L2 gpu/vk/vk_progcache.cpp:533: Deleting a recorded custom store leaves every subsequent direct start without a disk cache, with no automatic recovery. When: A copied game folder's recorded builder cache is permanently deleted. Each start classifies the missing pack as unknown and returns without writing a cache, so every session recompiles shaders; the reported run translates about 1,200 programs with multi-second frames, whereas main becomes warm after one cold start. Do: Keep the original cache for a potentially returning store, but use a separate writable fallback cache and default store when it is unavailable, so later starts can be warm.

Should fix (2): not blocking, but worth doing before merging.

  • L3 tests/program_cache_store_record_test.cpp:58: The Windows fixture does not use the game's UTF-8 process configuration, so the new check fails for some valid temporary paths. When: When TEMP contains characters outside the active Windows ANSI code page, Python passes the Unicode path to the fixture, but its narrow argv and file APIs cannot represent it; store creation or startup fails before the behavior under test is checked. Do: Give the fixture the same UTF-8 manifest as the game, or accept wide arguments and convert paths consistently to UTF-8.
  • L4 tests/test_program_cache_store_record.py:401: The Windows case-fold test changes the case of the entire temporary path, including potentially case-sensitive ancestors. When: If TEMP is inside a case-sensitive directory, swapping an ancestor's case points LOCALAPPDATA at a different or missing path, so the test fails even when the default-store comparison is correct. Do: Change the case only of a test-owned component known to be case-insensitive, or skip this case when its ancestors are case-sensitive.

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L5 gpu/vk/vk_progcache.cpp:526: The Linux game paths for selecting the recorded store and recovering a deleted default store have not yet been exercised. When: A Linux or Steam Deck direct start may encounter filesystem behavior that the synthetic WSL fixture does not reproduce; the submitted game evidence covers Windows only. Do: Run the two documented direct-start sequences in game on Linux or Steam Deck and report the cache and log results.

@fix can do L1, L2, L3 and L4.

Since the last review (on e7e905695b)
Still open: L1 (The synchronous probe can hang startup indefinitely on an unavailable hard-mounted network…); L2 (Deleting a recorded custom store leaves every subsequent direct start without a disk cache…); L3 (The Windows fixture does not use the game's UTF-8 process configuration, so the new check…); L4 (The Windows case-fold test changes the case of the entire temporary path, including potent…); L5 (The Linux game paths for selecting the recorded store and recovering a deleted default sto…)

Checks: Failing on this head, which is behind its base, where it passes: CI / Third-party parts and guide screenshots (pull_request). @rebase (or @fix) brings it up to date and runs it again; not held against it. Still running: 7 checks.

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

Does it help: Yes: the reported Windows game run kept 47,867 prepared keys and translated no programs in play; the comparison on main lost the cache and translated 582 programs on the next Market visit, with a 41.8-second frame. The warm-cache A/B was within reported noise.

Other systems: The store selection affects Windows and Linux startup, including development runtimes and copied game folders. Windows was exercised in game and both platforms in game-free tests; Linux in-game behavior remains untested.

Switches: No switches added, changed, or removed. LONGSHOT_SHADER_STORE continues to override the record.

Reviewed: 48fa6ef230 against 8cc8079713: Read the repository rules and PR template, the changed cache-transfer lines and surrounding copy and runtime logic, the recorded-store selection code, and the relevant Windows fixture and case-fold test. The remaining changed code, tests, and documentation were not read in full; recorded runs and CI results were reviewed from the PR.; nothing run (a code review).

Checked and fine:

  • The cache-transfer change includes the store record in seed and warm cache handling, with checks that it is copied to a subsequent runtime.
  • The Windows game run and game-free tests cover the principal recorded-store behavior; the reported CI checks are still running.

Testing: No commands that execute project code or tests were run. The PR reports Windows in-game testing and Windows and Linux game-free tests; Linux in-game coverage remains outstanding.

Overlaps and merge order: PR #737 also proposes cache/longshot_shader_store.txt with different contents; coordinate the filename before both merge.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** A recorded network store can block startup indefinitely, and a deleted custom store leaves direct starts repeatedly rebuilding shaders without automatic recovery. The Windows test fixture also still fails on some valid temporary paths. The change preserves prepared program caches when a game is started directly and carries the store record with development cache transfers. It adds startup file probing and can leave a game without a disk cache when its recorded custom store is unavailable. **Blocking (2)**: must change before merging. 1. **L1** `gpu/vk/vk_progcache.cpp:399`: The synchronous probe can hang startup indefinitely on an unavailable hard-mounted network store. *When:* A direct-start folder has a valid record pointing to a Linux hard-mounted NFS store whose server is offline. The filesystem status or head read waits for the server before disk_init can fall back; main never accessed that custom path. **Do:** Avoid putting an unbounded remote-filesystem probe on the startup path; arrange a bounded or asynchronous lookup with a usable fallback. 2. **L2** `gpu/vk/vk_progcache.cpp:533`: Deleting a recorded custom store leaves every subsequent direct start without a disk cache, with no automatic recovery. *When:* A copied game folder's recorded builder cache is permanently deleted. Each start classifies the missing pack as unknown and returns without writing a cache, so every session recompiles shaders; the reported run translates about 1,200 programs with multi-second frames, whereas main becomes warm after one cold start. **Do:** Keep the original cache for a potentially returning store, but use a separate writable fallback cache and default store when it is unavailable, so later starts can be warm. **Should fix (2)**: not blocking, but worth doing before merging. - **L3** `tests/program_cache_store_record_test.cpp:58`: The Windows fixture does not use the game's UTF-8 process configuration, so the new check fails for some valid temporary paths. *When:* When TEMP contains characters outside the active Windows ANSI code page, Python passes the Unicode path to the fixture, but its narrow argv and file APIs cannot represent it; store creation or startup fails before the behavior under test is checked. **Do:** Give the fixture the same UTF-8 manifest as the game, or accept wide arguments and convert paths consistently to UTF-8. - **L4** `tests/test_program_cache_store_record.py:401`: The Windows case-fold test changes the case of the entire temporary path, including potentially case-sensitive ancestors. *When:* If TEMP is inside a case-sensitive directory, swapping an ancestor's case points LOCALAPPDATA at a different or missing path, so the test fails even when the default-store comparison is correct. **Do:** Change the case only of a test-owned component known to be case-insensitive, or skip this case when its ancestors are case-sensitive. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L5** `gpu/vk/vk_progcache.cpp:526`: The Linux game paths for selecting the recorded store and recovering a deleted default store have not yet been exercised. *When:* A Linux or Steam Deck direct start may encounter filesystem behavior that the synthetic WSL fixture does not reproduce; the submitted game evidence covers Windows only. **Do:** Run the two documented direct-start sequences in game on Linux or Steam Deck and report the cache and log results. `@fix` can do L1, L2, L3 and L4. **Since the last review** (on e7e905695bb4) Still open: L1 (The synchronous probe can hang startup indefinitely on an unavailable hard-mounted network…); L2 (Deleting a recorded custom store leaves every subsequent direct start without a disk cache…); L3 (The Windows fixture does not use the game's UTF-8 process configuration, so the new check…); L4 (The Windows case-fold test changes the case of the entire temporary path, including potent…); L5 (The Linux game paths for selecting the recorded store and recovering a deleted default sto…) **Checks:** Failing on this head, which is behind its base, where it passes: `CI / Third-party parts and guide screenshots (pull_request)`. `@rebase` (or `@fix`) brings it up to date and runs it again; not held against it. Still running: 7 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes: the reported Windows game run kept 47,867 prepared keys and translated no programs in play; the comparison on main lost the cache and translated 582 programs on the next Market visit, with a 41.8-second frame. The warm-cache A/B was within reported noise. **Other systems:** The store selection affects Windows and Linux startup, including development runtimes and copied game folders. Windows was exercised in game and both platforms in game-free tests; Linux in-game behavior remains untested. **Switches:** No switches added, changed, or removed. LONGSHOT_SHADER_STORE continues to override the record. **Reviewed:** 48fa6ef230ec against 8cc8079713e3: Read the repository rules and PR template, the changed cache-transfer lines and surrounding copy and runtime logic, the recorded-store selection code, and the relevant Windows fixture and case-fold test. The remaining changed code, tests, and documentation were not read in full; recorded runs and CI results were reviewed from the PR.; nothing run (a code review). **Checked and fine:** - The cache-transfer change includes the store record in seed and warm cache handling, with checks that it is copied to a subsequent runtime. - The Windows game run and game-free tests cover the principal recorded-store behavior; the reported CI checks are still running. **Testing:** No commands that execute project code or tests were run. The PR reports Windows in-game testing and Windows and Linux game-free tests; Linux in-game coverage remains outstanding. **Overlaps and merge order:** PR #737 also proposes cache/longshot_shader_store.txt with different contents; coordinate the filename before both merge. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
Assisted-by: Codex
fix(vk): bound recorded store lookup and keep a warm fallback cache
Some checks failed
CI / What the change needs (pull_request) Successful in 11s
CI / Third-party parts and guide screenshots (pull_request) Failing after 14s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 17s
beanstalk/approval not approved yet
PR description / Title and description (pull_request_target) Successful in 7s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
b1717e2982
Assisted-by: Codex
fix(builder): protect active fallback shader caches from eviction
Some checks failed
CI / What the change needs (pull_request) Successful in 11s
CI / Third-party parts and guide screenshots (pull_request) Failing after 15s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 18s
beanstalk/approval not approved yet
PR description / Title and description (pull_request_target) Successful in 5s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 2m11s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 3m24s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 4m21s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 4m38s
CI / Website build and checks (pull_request) Failing after 35s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 18m46s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 40m7s
85b81519f7
Assisted-by: Codex
HumanBean force-pushed perf/shader-store-self-start from 85b81519f7
Some checks failed
CI / What the change needs (pull_request) Successful in 11s
CI / Third-party parts and guide screenshots (pull_request) Failing after 15s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 18s
beanstalk/approval not approved yet
PR description / Title and description (pull_request_target) Successful in 5s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 2m11s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 3m24s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 4m21s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 4m38s
CI / Website build and checks (pull_request) Failing after 35s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 18m46s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 40m7s
to d132f228ed
Some checks failed
CI / What the change needs (pull_request) Successful in 12s
CI / Third-party parts and guide screenshots (pull_request) Successful in 17s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 18s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 2m14s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 4m10s
PR description / Title and description (pull_request_target) Successful in 8s
beanstalk/approval not approved yet
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 4m58s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 4m42s
CI / Website build and checks (pull_request) Successful in 1m26s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 17m49s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 39m5s
2026-11-29 04:29:07 +00:00
Compare
HumanBean changed title from WIP: fix(vk): a game started by itself keeps the program cache prepared in another shader store to fix(vk): a game started by itself keeps the program cache prepared in another shader store 2026-11-29 05:20:28 +00:00
HumanBean deleted branch perf/shader-store-self-start 2026-11-29 05:20:53 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2768
No description provided.