perf(vk): an update that changes the translator keeps the driver's pipelines and the notes #1927

Open
madebyjordan wants to merge 5 commits from madebyjordan/Longshot:perf/pipelines-outlive-translator into main
Member

Summary

What was wrong: every Longshot update that changed the shader translator made the first start compile every Vulkan pipeline from scratch: 83 minutes on my RX 6700 XT, and hours on many AMD PCs. That's because the driver's pipeline cache (longshot_vk_pipelines.bin) and the pipeline notes (longshot_pipelines.bin, which pipelines play drew) were dropped with the program cache. Yet a new translator gives most programs byte-identical SPIR-V (99.6% between a stable and a nightly, #1649), so nearly every pipeline in that cache was still good. Translator changes are frequent, which makes this the biggest cost of an update after the build itself. nightly-649 and nightly-665 were already one: #1448 moved the translator's stamp, so a player updating to either compiles every pipeline cold. This stops it at the next translator change.

What this changes:

  • The driver's pipeline cache (gpu/vk/pcache_stamp.h) is carried to another translator, within a bound:
    • What is measured is the main file and the play files together, since a start hands the driver all of them.
    • The base (longshot_vk_pipelines.base) is that size when a precompile had finished for the translator being left (the .built record). Only then is it the size of one whole set of pipelines.
    • With a base, the cache is carried while it's at most half as large again, and dropped past that, the base with it.
    • With no finished precompile there is no size to judge by: a preparation stopped early and finished under the next translator is growth that is all live. Such a cache is carried at most 8 times.
    • The base is written before the stamp and names the stamp it moves from. A start cut short between them finishes that carry, a base that can't be written leaves the stamp for the next start, and a cache file that can't be removed is dropped at the next start.
    • A Vulkan pipeline cache can't be pruned (no enumeration; vkMergePipelineCaches only adds), so this bounds the growth that issue 388's drop was for.
  • The notes (gpu/vk/vk_draw.cpp) get a stamp of their own (kNotesFormat, notes_stamp) instead of the program cache's.
    • A note holds what the game asked for: its state, and its program's key, which comes from the guest code.
    • But a pipeline key mixes in what the translator made (key_inputs: the vertex shader's loads, and, without EDS3 blend, the write masks). So every place that keeps a pipeline built from a note under the note's key now checks that the key still holds (note_key_holds): the start's notes build, the load at a create call, and the programs' loader. A note whose key is another translator's is passed over and counted (notes passed over in the log), keeps no shader modules loaded, and play notes it again.
    • tests/test_notes_format.py fingerprints what a note holds (PipeNote, NvnState and the NVN types in it, nvn_va_st included) and fails until kNotesFormat is raised with any change to it.
  • What still starts over with the translator: the program file, the prepare record, the .built record (so the warm runs, finding most pipelines in the cache), the module identifiers and the prediction's files.

The launcher side: LongshotLauncher MagicBeanDev/LongshotLauncher#220 keeps the pipeline side across an update to another translator. Today it keeps nothing then, so the game would have nothing to carry.

Builds on #1926 (merged), whose pipelines_stamp_ok this uses.

Read first: gpu/vk/pcache_stamp.h (judge, check, the base), and in gpu/vk/vk_draw.cpp: notes_stamp, notes_stamp_ok, notes_restamp and note_key_holds.

Testing

Tested: Windows 11 Home 26200, AMD Radeon RX 6700 XT, Ryzen 5 5600.

  • In the game, on the launcher's path (longshot.exe --prepare-shaders --compile-shaders most, as make_game.py runs it), on head 5257fd3f. This is a real translator change: nightly-622 to current main, which has #1448.
    • The dev runtime's cache/ was seeded with a copy of my prepared nightly-622 folder's caches.
    • It ran from a new folder path, so AMD's own driver cache was cold, as after an update's folder rename.
    • The log: pipeline cache: another translator's (1839 MB, no precompile finished for it yet) carried; prepared 38809 shader programs ... in 124.4 s; precompile: 38024 noted pipelines ... (0 and 0 not made ...) in 7.2 s, with the pipeline cache not written: nothing new (every pipeline a hit).
    • 133 s in all, against 83 minutes for nightly-622 on the same PC. The same folder started again took 23 s.
    • nightly-622's notes carry the old program stamp of another translator, so they were dropped once, as designed; the shipped state list noted the same pipelines again.
  • New and changed checks, the test commit first:
    • test_pipelines_outlive_cache_format: another translator's build carries the pipeline cache and keeps the notes; past the bound the cache is dropped and the notes kept; notes stamped as before are stamped anew by their own translator, whether opened for play or only read, and kept by the next; another translator's legacy notes are dropped once.
    • test_pcache_stamp: the verdict and the base's life: the play files counted, a base only from a finished precompile, growth before one not dropped, at most 8 carries without one, a carry cut short finished and not counted twice, a failed base write, a file that won't go, and a base not taken beside another stamp.
    • test_notes_format (new): the layout fingerprint, and the three places checking note_key_holds. test_pipelines_outlive_cache_format also runs the real note_key_check.
    • All of them fail on the parent for this reason: the cache dropped and the notes cut to their head at a translator change, no base, no kNotesFormat. The test_pcache_stamp additions don't compile there (no Base, no judge).
  • Broken variants, each caught: the restamp on read removed; a carry that keeps every stamp; a key site without note_key_holds; a note's layout changed (two members of nvn_vs_st swapped); the play files not counted; a base taken from an unfinished cache; the stamp moved after a failed base write; a resumed carry counted twice; a half-done carry's base refused; a stale base taken; a held file moving the stamp; unlimited unfinished carries; note_key_check always true.
  • The whole suite (tests/run_all.py --strict, what mise run test runs; Windows, llvm-mingw), on this head and on main f1f2dc5b: 712 passed, 146 failed, 48 skipped here; 712, 145, 48 on main. 145 failures are the same on both (tools this PC lacks, and Windows-only differences). The other is test_longshot_ctl, a process-timing check this PR doesn't touch: it failed once with the suite's load and passed 3 of 3 alone. Checks that follow the change: test_fsr4_own_cache's fixture now drops by the bound; test_loaded_modules_drop, test_program_load_wait, test_precompile_pipeline_cleanup, test_note_refs_once and test_state_list_part_record gain the new calls and stand-ins.
  • Compiled whole: vk_draw.cpp and vk_programs.cpp (-fsyntax-only -Wall -Wextra, the build's include folders) give the same diagnostics as the parent, line for line.
  • Cold reviews by a second agent, twice. All blocking findings are fixed here:
    • pipelines built from notes under a key another translator made (now note_key_holds);
    • a base that lagged a start behind and could drop a cache wrongly;
    • the launcher's Undo handing an old build the new stamp (fixed in the launcher PR);
    • a bound that took useful growth for dead weight, which would have brought the full compile back after a stopped preparation;
    • a bound lost to a failed or cut-short write, or to a file that couldn't be removed.

Still to test:

  • linux and windows nvidia: a folder prepared by nightly-622, then this branch (a real translator change, as above), expecting another translator's ... carried, 0 notes passed over, and a preparation of minutes (@Beanstalk)
  • windows AMD: play a few minutes after a translator change that changes SPIR-V, checking the log's notes passed over count and the picture (by hand)
  • windows AMD: RAM, VRAM and warm-start time with a carried cache near its bound against a fresh one (by hand)

Measurements

Verdict: after a translator change the launcher's preparation takes about 2¼ minutes instead of 83: the driver's pipelines are carried, so only the programs are translated again.

Setup: Windows 11, RX 6700 XT, Ryzen 5 5600; the launcher's preparation over a folder prepared by nightly-622, AMD's own driver cache cold (a new folder path); the real translator change from nightly-622 to main f1f2dc5b. One run each, since the gap is 37×. The before is nightly-622's own run: main still drops these files at a translator change, as #1926 covers format changes only.

Before: main @ fb14ba0b (nightly-622, a translator or format change) After: this PR @ 5257fd3f
driver pipeline cache dropped (1.88 GB) carried
translation every program every program, 124.4 s
noted pipelines 38,024 compiled cold 38,024 from the cache, 7.2 s
the preparation in all 83 min 133 s

This translator change added nothing to the cache. One that rewrites more SPIR-V compiles those programs' pipelines, seconds to minutes on AMD by how many.

Risks

  • Memory: a carried cache can be up to half as large again as one translator's (2.8 GB instead of 1.9 GB here), read whole at every start and held by the driver (issue 388's working set). The next translator change past the bound drops it. The RAM, VRAM and warm-start cost of a cache near the bound hasn't been measured (Still to test).
  • Notes only grow: notes whose key moved stay in the file, about 27 KB each, until the notes' format changes. Compacting them after a finished precompile is a follow-up.
  • Wrong pipelines: a note built under a key the translator now makes otherwise would be one. note_key_holds guards every such place, and test_notes_format holds the list. Pipelines built only into the driver's cache (the warm) are found by their contents, so a stale note there costs one useless build at most.
  • Downgrade: a build from before this drops the carried cache by its stamp, as it does today, and leaves the base file, which no later start takes beside another stamp. Notes restamped by this build are dropped by an older build (it doesn't know their stamp): going back from a nightly to a stable loses the notes once.
  • The shipped seed list (make_game.py seed_pipelines, which compares a notes file's first 8 bytes) would need its seed stamped with notes_stamp. No build ships a seed today: neither the downloaded tools nor any build script has one.
  • To turn it off: a revert. There's no switch.

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.
  • 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 **What was wrong:** every Longshot update that changed the shader translator made the first start compile every Vulkan pipeline from scratch: 83 minutes on my RX 6700 XT, and hours on many AMD PCs. That's because the driver's pipeline cache (`longshot_vk_pipelines.bin`) and the pipeline notes (`longshot_pipelines.bin`, which pipelines play drew) were dropped with the program cache. Yet a new translator gives most programs byte-identical SPIR-V (99.6% between a stable and a nightly, #1649), so nearly every pipeline in that cache was still good. Translator changes are frequent, which makes this the biggest cost of an update after the build itself. **nightly-649 and nightly-665 were already one:** #1448 moved the translator's stamp, so a player updating to either compiles every pipeline cold. This stops it at the next translator change. **What this changes:** - **The driver's pipeline cache** (`gpu/vk/pcache_stamp.h`) is carried to another translator, within a bound: - What is measured is the main file and the play files together, since a start hands the driver all of them. - The base (`longshot_vk_pipelines.base`) is that size when a precompile had finished for the translator being left (the `.built` record). Only then is it the size of one whole set of pipelines. - With a base, the cache is carried while it's at most half as large again, and dropped past that, the base with it. - With no finished precompile there is no size to judge by: a preparation stopped early and finished under the next translator is growth that is all live. Such a cache is carried at most 8 times. - The base is written before the stamp and names the stamp it moves from. A start cut short between them finishes that carry, a base that can't be written leaves the stamp for the next start, and a cache file that can't be removed is dropped at the next start. - A Vulkan pipeline cache can't be pruned (no enumeration; `vkMergePipelineCaches` only adds), so this bounds the growth that issue 388's drop was for. - **The notes** (`gpu/vk/vk_draw.cpp`) get a stamp of their own (`kNotesFormat`, `notes_stamp`) instead of the program cache's. - A note holds what the game asked for: its state, and its program's key, which comes from the guest code. - But a pipeline key mixes in what the translator made (`key_inputs`: the vertex shader's loads, and, without EDS3 blend, the write masks). So every place that keeps a pipeline built from a note under the note's key now checks that the key still holds (`note_key_holds`): the start's notes build, the load at a create call, and the programs' loader. A note whose key is another translator's is passed over and counted (`notes passed over` in the log), keeps no shader modules loaded, and play notes it again. - `tests/test_notes_format.py` fingerprints what a note holds (`PipeNote`, `NvnState` and the NVN types in it, `nvn_va_st` included) and fails until `kNotesFormat` is raised with any change to it. - **What still starts over with the translator:** the program file, the prepare record, the `.built` record (so the warm runs, finding most pipelines in the cache), the module identifiers and the prediction's files. **The launcher side:** LongshotLauncher https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/220 keeps the pipeline side across an update to another translator. Today it keeps nothing then, so the game would have nothing to carry. Builds on #1926 (merged), whose `pipelines_stamp_ok` this uses. Read first: `gpu/vk/pcache_stamp.h` (`judge`, `check`, the base), and in `gpu/vk/vk_draw.cpp`: `notes_stamp`, `notes_stamp_ok`, `notes_restamp` and `note_key_holds`. ## Testing **Tested:** Windows 11 Home 26200, AMD Radeon RX 6700 XT, Ryzen 5 5600. - **In the game, on the launcher's path** (`longshot.exe --prepare-shaders --compile-shaders most`, as `make_game.py` runs it), on head `5257fd3f`. This is a real translator change: nightly-622 to current main, which has #1448. - The dev runtime's `cache/` was seeded with a copy of my prepared nightly-622 folder's caches. - It ran from a new folder path, so AMD's own driver cache was cold, as after an update's folder rename. - The log: `pipeline cache: another translator's (1839 MB, no precompile finished for it yet) carried`; `prepared 38809 shader programs ... in 124.4 s`; `precompile: 38024 noted pipelines ... (0 and 0 not made ...) in 7.2 s`, with `the pipeline cache not written: nothing new` (every pipeline a hit). - **133 s in all, against 83 minutes for nightly-622 on the same PC.** The same folder started again took 23 s. - nightly-622's notes carry the old program stamp of another translator, so they were dropped once, as designed; the shipped state list noted the same pipelines again. - **New and changed checks, the test commit first:** - `test_pipelines_outlive_cache_format`: another translator's build carries the pipeline cache and keeps the notes; past the bound the cache is dropped and the notes kept; notes stamped as before are stamped anew by their own translator, whether opened for play or only read, and kept by the next; another translator's legacy notes are dropped once. - `test_pcache_stamp`: the verdict and the base's life: the play files counted, a base only from a finished precompile, growth before one not dropped, at most 8 carries without one, a carry cut short finished and not counted twice, a failed base write, a file that won't go, and a base not taken beside another stamp. - `test_notes_format` (new): the layout fingerprint, and the three places checking `note_key_holds`. `test_pipelines_outlive_cache_format` also runs the real `note_key_check`. - All of them fail on the parent for this reason: the cache dropped and the notes cut to their head at a translator change, no base, no `kNotesFormat`. The `test_pcache_stamp` additions don't compile there (no `Base`, no `judge`). - **Broken variants, each caught:** the restamp on read removed; a carry that keeps every stamp; a key site without `note_key_holds`; a note's layout changed (two members of `nvn_vs_st` swapped); the play files not counted; a base taken from an unfinished cache; the stamp moved after a failed base write; a resumed carry counted twice; a half-done carry's base refused; a stale base taken; a held file moving the stamp; unlimited unfinished carries; `note_key_check` always true. - **The whole suite** (`tests/run_all.py --strict`, what `mise run test` runs; Windows, llvm-mingw), on this head and on main `f1f2dc5b`: 712 passed, 146 failed, 48 skipped here; 712, 145, 48 on main. 145 failures are the same on both (tools this PC lacks, and Windows-only differences). The other is `test_longshot_ctl`, a process-timing check this PR doesn't touch: it failed once with the suite's load and passed 3 of 3 alone. Checks that follow the change: `test_fsr4_own_cache`'s fixture now drops by the bound; `test_loaded_modules_drop`, `test_program_load_wait`, `test_precompile_pipeline_cleanup`, `test_note_refs_once` and `test_state_list_part_record` gain the new calls and stand-ins. - **Compiled whole:** `vk_draw.cpp` and `vk_programs.cpp` (`-fsyntax-only -Wall -Wextra`, the build's include folders) give the same diagnostics as the parent, line for line. - **Cold reviews** by a second agent, twice. All blocking findings are fixed here: - pipelines built from notes under a key another translator made (now `note_key_holds`); - a base that lagged a start behind and could drop a cache wrongly; - the launcher's Undo handing an old build the new stamp (fixed in the launcher PR); - a bound that took useful growth for dead weight, which would have brought the full compile back after a stopped preparation; - a bound lost to a failed or cut-short write, or to a file that couldn't be removed. **Still to test:** - linux and windows nvidia: a folder prepared by nightly-622, then this branch (a real translator change, as above), expecting `another translator's ... carried`, 0 notes passed over, and a preparation of minutes (@Beanstalk) - windows AMD: play a few minutes after a translator change that changes SPIR-V, checking the log's `notes passed over` count and the picture (by hand) - windows AMD: RAM, VRAM and warm-start time with a carried cache near its bound against a fresh one (by hand) ## Measurements **Verdict:** after a translator change the launcher's preparation takes about 2¼ minutes instead of 83: the driver's pipelines are carried, so only the programs are translated again. Setup: Windows 11, RX 6700 XT, Ryzen 5 5600; the launcher's preparation over a folder prepared by nightly-622, AMD's own driver cache cold (a new folder path); the real translator change from nightly-622 to main `f1f2dc5b`. One run each, since the gap is 37×. The before is nightly-622's own run: main still drops these files at a translator change, as #1926 covers format changes only. | | Before: main @ fb14ba0b (nightly-622, a translator or format change) | After: this PR @ 5257fd3f | |---|---|---| | driver pipeline cache | dropped (1.88 GB) | carried | | translation | every program | every program, 124.4 s | | noted pipelines | 38,024 compiled cold | 38,024 from the cache, 7.2 s | | the preparation in all | **83 min** | **133 s** | This translator change added nothing to the cache. One that rewrites more SPIR-V compiles those programs' pipelines, seconds to minutes on AMD by how many. ## Risks - **Memory:** a carried cache can be up to half as large again as one translator's (2.8 GB instead of 1.9 GB here), read whole at every start and held by the driver (issue 388's working set). The next translator change past the bound drops it. The RAM, VRAM and warm-start cost of a cache near the bound hasn't been measured (Still to test). - **Notes only grow:** notes whose key moved stay in the file, about 27 KB each, until the notes' format changes. Compacting them after a finished precompile is a follow-up. - **Wrong pipelines:** a note built under a key the translator now makes otherwise would be one. `note_key_holds` guards every such place, and `test_notes_format` holds the list. Pipelines built only into the driver's cache (the warm) are found by their contents, so a stale note there costs one useless build at most. - **Downgrade:** a build from before this drops the carried cache by its stamp, as it does today, and leaves the base file, which no later start takes beside another stamp. Notes restamped by this build are dropped by an older build (it doesn't know their stamp): going back from a nightly to a stable loses the notes once. - **The shipped seed list** (`make_game.py` `seed_pipelines`, which compares a notes file's first 8 bytes) would need its seed stamped with `notes_stamp`. No build ships a seed today: neither the downloaded tools nor any build script has one. - **To turn it off:** a revert. There's no switch. ## 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] 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)
#1809 raised kProgramCacheFormat from 1 to 3, which changes how
longshot_programs.bin lays out a stage stored in the shader store, not
the SPIR-V. Every cache file is stamped with program_cache_stamp() (the
translator's stamp mixed with the format), so nightly-622's first start
dropped the driver's pipeline cache, truncated the pipeline notes and
started the program file over: every program translated again and every
pipeline compiled again cold.

The check compiles the real pcache_drop_stale() and notes_open_locked()
as two builds of one translator, format 1 and the current one: the second
must keep the first's pipeline cache and notes; another translator must
still drop them. Every other reader of the pipeline side must judge its
head by pipelines_stamp_ok. And program_file_head(), which disk_init
asks, must adopt a format 1 program file of this translator with no
store, and start over on format 2, another translator, a compressed
file, a store named, a head cut short or another magic. It fails on
main: the pipeline cache dropped, the notes cut to their head, no
adoption.

Assisted-by: Claude Code (Claude Opus 5.5)
fix(vk): a program cache format change keeps the programs, the driver's pipelines and the notes
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 9s
CI / Workflow lint (actionlint) (pull_request) Successful in 15s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 16s
Third-party parts / As their notes say (pull_request) Successful in 18s
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Failing after 9s
CI / Website build and checks (pull_request) Has been cancelled
37715c273d
kProgramCacheFormat is about how longshot_programs.bin lays out a record;
the SPIR-V, the program keys and their variants, and so every pipeline
the driver keeps, are the same across a format change. But every file of
the caches was judged by program_cache_stamp(), the translator's stamp
mixed with the format, so #1809's 1 -> 3 made nightly-622's first start
translate every program again and compile every pipeline again cold:
hours on AMD, for programs and pipelines the player already had.

The program file: a format 1 file of this translator, with no store, is
adopted as it is (program_file_head; its head stamped as this format's
before anything is appended, or the file started over if that write
fails). Formats 2 and 3 only added the shader store's kind of stage code;
a format 1 stage ([u64 words][words]) is read as it always was. Format 2
never shipped and its references carry no hash: never adopted. Nor a
compressed file (RX_VK_PROGRAM_CACHE_ZSTD).

The pipeline side: pipelines_stamp_ok() takes this translator's stamp
under the current format or any earlier one (their stamps made once),
and the pipeline cache's files (pcache_stamp::check's `also`, the stamp
file left as it was, so a build of that format keeps them too), the
notes (read, reopened for play's new ones, their references), the
precompile's .built record, the prediction's keys and sample, and
longshot_module_ids.bin (module_ids::Store::open's `also`) are judged by
it. Files written now keep the current stamp. longshot_prepared.bin
still starts over with the format: the preparation runs, finding every
program kept and every pipeline in the driver's cache. Another
translator still drops them all, as before.

A format bump can no longer drop the pipeline side: vk_progcache.cpp's
header says a change to the SPIR-V, the keys or the variants belongs in
the translator's stamp. test_dev_packs, test_native_float_atomic_add and
test_program_cache_format follow program_cache_stamp's move into
program_cache_stamp_of and the head's into program_file_head.

Assisted-by: Claude Code (Claude Opus 5.5)
A translator change gives most programs the same SPIR-V (99.6% between a
stable and a nightly), but the driver's pipeline cache and the pipeline
notes were dropped with the program cache, and every such update compiled
every pipeline again cold, without even knowing which ones play drew.

- test_pipelines_outlive_cache_format: another translator's build carries
  the pipeline cache and keeps the notes; a cache past half as large again
  of its base is dropped, the notes kept; notes stamped as before are
  stamped anew by their own translator (when opened for play, or only
  read) and kept by the next, and dropped once by another.
- test_pcache_stamp: the carry's verdict and its base (none while the
  cache holds one translator's pipelines alone, its size at the first
  carry, taken only beside the stamp it was written with).
- test_notes_format (new): the notes' layout (PipeNote, NvnState and what
  it holds) fingerprinted against kNotesFormat, and every place that
  keeps a pipeline built from a note under its key checking the key holds.

They fail on the parent: the cache dropped and the notes cut to their
head at a translator change, no base, no kNotesFormat.

Assisted-by: Claude Code (Claude Opus 5.5)
perf(vk): an update that changes the translator keeps the driver's pipelines and the notes
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 11s
Website / Website on Cloudflare (pull_request_target) Has been skipped
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 18s
CI / Workflow lint (actionlint) (pull_request) Successful in 19s
Third-party parts / As their notes say (pull_request) Successful in 21s
PR description / Description follows the template (pull_request_target) Failing after 8s
CI / Website build and checks (pull_request) Has been cancelled
060284843b
A translator change dropped the driver's pipeline cache
(longshot_vk_pipelines.bin) and the pipeline notes with the program
cache, so every such update compiled every pipeline again cold (hours on
AMD) and the preparation no longer knew which ones play had drawn. Yet a
new translator gives most programs the same SPIR-V (99.6% of them between
a stable and a nightly), whose pipelines the driver's cache still had.

The pipeline cache (pcache_stamp.h): another translator's files are
carried within a bound. A cache that holds one translator's pipelines
alone is always carried; the first carry records its size as the base
(longshot_vk_pipelines.base, beside the stamp it was written with, and
taken only beside that stamp); from then on, while the file holds
pipelines no one hits again, it is carried while at most half as large
again as its base and dropped past that, the base with it. A Vulkan
pipeline cache cannot be pruned (no enumeration; vkMergePipelineCaches
only adds), so this bounds the growth issue 388's drop was for. The base
is a file of its own so builds from before it read the stamp file as
ever; one that drops by its stamp leaves a base no later start takes.

The notes (vk_draw.cpp): stamped by their own layout (kNotesFormat,
notes_stamp) instead of the program cache's stamp. A note holds what the
game asked, its program found by the guest code's key; but its pipeline
key mixes in what the translator made (key_inputs: the vertex loads, and
without EDS3 blend the write masks), so a note built under another
translator could hand a draw a pipeline made for another state. Every
place that keeps a pipeline built from a note under its key now checks
the key holds (note_key_holds: the start's notes build, the load at a
create call, the programs' loader), passing over and counting the notes
whose key is another translator's ("notes passed over" in the log; 0
under one translator). A notes file of this translator stamped as before
is read and stamped anew; tests/test_notes_format.py fails until
kNotesFormat is raised with any change to what a note holds.

What still starts over with the translator: the program file, the
prepare record, the .built record (so the warm runs, finding most
pipelines in the cache), the module identifiers and the prediction's
files. scripts/devtools/packs.py copies the base with the other caches;
checks that read the changed source follow it (test_fsr4_own_cache's
fixture drops by the bound, stand-ins gain the notes' stamp and
note_key_holds).

Assisted-by: Claude Code (Claude Opus 5.5)
Author
Member

Tested in game: Windows 11, RX 6700 XT: the launcher's preparation (--prepare-shaders --compile-shaders most) of a dev runtime of this branch with the translator's stamp moved (a test-only constant in vk_state.h, no SPIR-V change), over a copy of my prepared nightly-622 caches, AMD's own driver cache cold: 'another translator's (1839 MB) carried', 38809 programs translated in 127.9 s, 38024 noted pipelines from the cache in 6.9 s (nothing new compiled): about 2 1/4 minutes against 83 for nightly-622.

Tested in game: Windows 11, RX 6700 XT: the launcher's preparation (--prepare-shaders --compile-shaders most) of a dev runtime of this branch with the translator's stamp moved (a test-only constant in vk_state.h, no SPIR-V change), over a copy of my prepared nightly-622 caches, AMD's own driver cache cold: 'another translator's (1839 MB) carried', 38809 programs translated in 127.9 s, 38024 noted pipelines from the cache in 6.9 s (nothing new compiled): about 2 1/4 minutes against 83 for nightly-622.
BeanBot left a comment

Recommendation: Request changes. The growth bound excludes play-cache files and can lose its base when metadata writes fail, so it does not reliably bound the cache carried across updates. The additional memory cost is also unmeasured.

The change carries Vulkan pipeline caches and compatible pipeline notes across translator updates, potentially avoiding lengthy recompilation. It adds cache-growth accounting and note-key checks, but the accounting misses play files and does not handle failed metadata writes; the resulting memory and startup costs need measurement.

Does it help: Unproven. The PR reports one Windows RX 6700 XT run at about 2¼ minutes versus 83 minutes for nightly-622, using a synthetic stamp change with identical SPIR-V. This is encouraging, but it is not repeated against the specified base or a real translator change, and warm startup, RAM and VRAM costs are missing.
Other systems: Windows AMD preparation was reported; Linux, Windows NVIDIA, Steam Deck and real translator changes remain untested. Play-cache generations contribute to the cache merged at startup but are excluded from the growth decision. The launcher must also preserve the files; its companion PR is required.
Switches: None added, changed or removed. The carry policy is on by default and has no switch; a revert is the stated way back.

Reviewed: 060284843b against a104182b40: Read AGENTS.md, CONTRIBUTING.md, the PR template, standards, the commits and the production diff, including pcache_stamp.h in full. Inspected portions of the changed renderer code, callers and tests; the very large renderer files, all changed tests and scripts were not read in full. The requested review checklist file is absent. Tooling's external rules and overlapping PRs could not be inspected in this offline review.; nothing run (a code review).
Checked and fine:

  • The three identified paths that keep pipelines under note keys call note_key_holds.
  • The PR identifies the launcher dependency and the one-time loss of legacy notes on a translator change.
  • No switches, third-party files or generated shader files are changed in the diff.

Blocking (to change before merge)

  1. gpu/vk/pcache_stamp.h:129: The bound measures only longshot_vk_pipelines.bin. For example, a main file below the limit with large play-generation files is carried, and play_files_merge subsequently merges those files into the driver's cache. Account for all carried generations when deciding whether to drop, and test that case.
  2. gpu/vk/pcache_stamp.h:137: The carry ignores failures to write the base and stamp. If writing the base fails but the stamp succeeds, the next translator sees no base and treats the already mixed cache as a single-translator cache, allowing repeated growth. Make the metadata transition failure-safe and test failed writes and interrupted transitions.
  3. gpu/vk/pcache_stamp.h:35: The default permits substantially more cache data to be loaded and retained, but the PR provides no before-and-after RAM, VRAM or warm-start measurements. Measure the cost on affected configurations and adjust the policy if it causes a material regression.

Testing: No code or tests were run, as requested. The author's reported source checks, syntax checks and single hardware preparation run were considered as reported evidence.
Overlaps and merge order: Stacked on Longshot #1926, which the author says must merge first; LongshotLauncher #220 supplies the launcher side. Other overlaps were not checked.


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

**Recommendation: Request changes.** The growth bound excludes play-cache files and can lose its base when metadata writes fail, so it does not reliably bound the cache carried across updates. The additional memory cost is also unmeasured. The change carries Vulkan pipeline caches and compatible pipeline notes across translator updates, potentially avoiding lengthy recompilation. It adds cache-growth accounting and note-key checks, but the accounting misses play files and does not handle failed metadata writes; the resulting memory and startup costs need measurement. **Does it help:** Unproven. The PR reports one Windows RX 6700 XT run at about 2¼ minutes versus 83 minutes for nightly-622, using a synthetic stamp change with identical SPIR-V. This is encouraging, but it is not repeated against the specified base or a real translator change, and warm startup, RAM and VRAM costs are missing. **Other systems:** Windows AMD preparation was reported; Linux, Windows NVIDIA, Steam Deck and real translator changes remain untested. Play-cache generations contribute to the cache merged at startup but are excluded from the growth decision. The launcher must also preserve the files; its companion PR is required. **Switches:** None added, changed or removed. The carry policy is on by default and has no switch; a revert is the stated way back. **Reviewed:** 060284843b88 against a104182b4037: Read AGENTS.md, CONTRIBUTING.md, the PR template, standards, the commits and the production diff, including pcache_stamp.h in full. Inspected portions of the changed renderer code, callers and tests; the very large renderer files, all changed tests and scripts were not read in full. The requested review checklist file is absent. Tooling's external rules and overlapping PRs could not be inspected in this offline review.; nothing run (a code review). **Checked and fine:** - The three identified paths that keep pipelines under note keys call note_key_holds. - The PR identifies the launcher dependency and the one-time loss of legacy notes on a translator change. - No switches, third-party files or generated shader files are changed in the diff. **Blocking** (to change before merge) 1. gpu/vk/pcache_stamp.h:129: The bound measures only longshot_vk_pipelines.bin. For example, a main file below the limit with large play-generation files is carried, and play_files_merge subsequently merges those files into the driver's cache. Account for all carried generations when deciding whether to drop, and test that case. 2. gpu/vk/pcache_stamp.h:137: The carry ignores failures to write the base and stamp. If writing the base fails but the stamp succeeds, the next translator sees no base and treats the already mixed cache as a single-translator cache, allowing repeated growth. Make the metadata transition failure-safe and test failed writes and interrupted transitions. 3. gpu/vk/pcache_stamp.h:35: The default permits substantially more cache data to be loaded and retained, but the PR provides no before-and-after RAM, VRAM or warm-start measurements. Measure the cost on affected configurations and adjust the policy if it causes a material regression. **Testing:** No code or tests were run, as requested. The author's reported source checks, syntax checks and single hardware preparation run were considered as reported evidence. **Overlaps and merge order:** Stacked on Longshot #1926, which the author says must merge first; LongshotLauncher #220 supplies the launcher side. Other overlaps were not checked. --- <sub>Automated code review by BeanBot (gpt-6.1-terra), on the pull request's opening. Nothing was run; a maintainer decides.</sub>
@ -22,1 +32,4 @@
inline const char* kPlayPrefix = "longshot_vk_pipelines_play_";
inline const char* kBaseFile = "longshot_vk_pipelines.base";
/// How far the main file may have grown past its base and still be carried to another translator (3/2: half as large again)
Member

Please measure RAM, VRAM and warm-start costs for this default against the base, including a grown carried cache. The reported preparation time does not establish whether the extra resident cache is acceptable on affected systems.

Please measure RAM, VRAM and warm-start costs for this default against the base, including a grown carried cache. The reported preparation time does not establish whether the extra resident cache is acceptable on affected systems.
@ -67,0 +126,4 @@
std::error_code size_ec;
const uintmax_t main = std::filesystem::file_size(dir + kMainFile, size_ec);
d.main = size_ec ? 0 : (uint64_t)main;
d.base = have ? read_base(dir, kept) : 0;
Member

This measures only the main file, but startup also merges the play-generation files. A small main file plus large play files can pass the bound and load a much larger cache. Please include the carried generations in the decision and cover that case.

This measures only the main file, but startup also merges the play-generation files. A small main file plus large play files can pass the bound and load a much larger cache. Please include the carried generations in the decision and cover that case.
@ -67,0 +134,4 @@
write_base(dir, Base{d.base, stamp});
write(dir, stamp);
d.carried = true;
return d;
Member

Please handle failure of these writes as a single failure-safe transition. If the base write fails but the stamp write succeeds, the next update treats the mixed cache as having no base and can carry it as though it held one translator.

Please handle failure of these writes as a single failure-safe transition. If the base write fails but the stamp write succeeds, the next update treats the mixed cache as having no base and can carry it as though it held one translator.
HumanBean changed title from WIP: perf(vk): an update that changes the translator keeps the driver's pipelines and the notes to perf(vk): an update that changes the translator keeps the driver's pipelines and the notes 2026-11-21 00:03:50 +00:00
Owner
@fix
Member

I didn't change this pull request: what the review asks needs the author (runs, measurements or decisions, which can't be done here).

Left for the author

  • Pipeline cache growth and metadata transitions: Changed gpu/vk/pcache_stamp.h:140 to count play generations and preserve the base across interrupted transitions; gpu/vk/vk_draw.cpp:1073 disables cache reads and saves when a transition fails. Added cases in tests/test_pcache_stamp.cpp:103. Nothing was run. The author must measure RAM, VRAM and warm-start costs against the specified base, including a grown carried cache, on affected configurations, then adjust the policy if the regression is material. The reported preparation run does not provide those measurements.

Nothing was pushed.


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

I didn't change this pull request: what the review asks needs the author (runs, measurements or decisions, which can't be done here). **Left for the author** - **Pipeline cache growth and metadata transitions**: Changed gpu/vk/pcache_stamp.h:140 to count play generations and preserve the base across interrupted transitions; gpu/vk/vk_draw.cpp:1073 disables cache reads and saves when a transition fails. Added cases in tests/test_pcache_stamp.cpp:103. Nothing was run. The author must measure RAM, VRAM and warm-start costs against the specified base, including a grown carried cache, on affected configurations, then adjust the policy if the regression is material. The reported preparation run does not provide those measurements. Nothing was pushed. --- <sub>Automated fix by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
madebyjordan force-pushed perf/pipelines-outlive-translator from 060284843b
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 11s
Website / Website on Cloudflare (pull_request_target) Has been skipped
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 18s
CI / Workflow lint (actionlint) (pull_request) Successful in 19s
Third-party parts / As their notes say (pull_request) Successful in 21s
PR description / Description follows the template (pull_request_target) Failing after 8s
CI / Website build and checks (pull_request) Has been cancelled
to 736e1be462
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 24s
PR description / Description follows the template (pull_request_target) Failing after 28s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 33s
CI / Workflow lint (actionlint) (pull_request) Successful in 33s
Third-party parts / As their notes say (pull_request) Successful in 36s
CI / Website build and checks (pull_request) Has been cancelled
2026-11-21 00:11:09 +00:00
Compare
madebyjordan force-pushed perf/pipelines-outlive-translator from 736e1be462
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 24s
PR description / Description follows the template (pull_request_target) Failing after 28s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 33s
CI / Workflow lint (actionlint) (pull_request) Successful in 33s
Third-party parts / As their notes say (pull_request) Successful in 36s
CI / Website build and checks (pull_request) Has been cancelled
to 5f447a9d3b
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 12s
CI / Workflow lint (actionlint) (pull_request) Successful in 16s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 17s
Third-party parts / As their notes say (pull_request) Successful in 19s
PR description / Description follows the template (pull_request_target) Successful in 8s
CI / Website build and checks (pull_request) Failing after 12s
2026-11-21 00:24:37 +00:00
Compare
Owner
@fix
Member

I didn't change this pull request: what the review asks needs the author (runs, measurements or decisions, which can't be done here).

Left for the author

  • Cache growth, metadata transitions and measurements: Changed gpu/vk/pcache_stamp.h:142 to count play files and handle failed or interrupted metadata transitions; gpu/vk/vk_draw.cpp:1072 disables cache loading and saving after an unsafe failure. Added coverage in tests/test_pcache_stamp.cpp:57 and tests/test_pcache_stamp.cpp:135. Nothing was run. The author must compare RAM, VRAM and warm-start time against the base on affected configurations, including a grown carried cache, and adjust the policy if the measurements show a material regression.

Nothing was pushed.


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

I didn't change this pull request: what the review asks needs the author (runs, measurements or decisions, which can't be done here). **Left for the author** - **Cache growth, metadata transitions and measurements**: Changed gpu/vk/pcache_stamp.h:142 to count play files and handle failed or interrupted metadata transitions; gpu/vk/vk_draw.cpp:1072 disables cache loading and saving after an unsafe failure. Added coverage in tests/test_pcache_stamp.cpp:57 and tests/test_pcache_stamp.cpp:135. Nothing was run. The author must compare RAM, VRAM and warm-start time against the base on affected configurations, including a grown carried cache, and adjust the policy if the measurements show a material regression. Nothing was pushed. --- <sub>Automated fix by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
Owner
@fix
Member

I didn't change this pull request: what the review asks needs the author (runs, measurements or decisions, which can't be done here).

Left for the author

  • Cache growth, metadata failures, and measurements: Updated gpu/vk/pcache_stamp.h:137 to count play generations and protect interrupted transitions, disabled unsafe cache use in gpu/vk/vk_draw.cpp:1072, and added cases in tests/test_pcache_stamp.cpp:57. Nothing was run. The author must measure warm-start time, RAM, and VRAM against the specified base on affected configurations, including a grown carried cache and a real translator change, then adjust the policy if the regression is material.

Nothing was pushed.


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

I didn't change this pull request: what the review asks needs the author (runs, measurements or decisions, which can't be done here). **Left for the author** - **Cache growth, metadata failures, and measurements**: Updated gpu/vk/pcache_stamp.h:137 to count play generations and protect interrupted transitions, disabled unsafe cache use in gpu/vk/vk_draw.cpp:1072, and added cases in tests/test_pcache_stamp.cpp:57. Nothing was run. The author must measure warm-start time, RAM, and VRAM against the specified base on affected configurations, including a grown carried cache and a real translator change, then adjust the policy if the regression is material. Nothing was pushed. --- <sub>Automated fix by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
madebyjordan force-pushed perf/pipelines-outlive-translator from 5f447a9d3b
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 12s
CI / Workflow lint (actionlint) (pull_request) Successful in 16s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 17s
Third-party parts / As their notes say (pull_request) Successful in 19s
PR description / Description follows the template (pull_request_target) Successful in 8s
CI / Website build and checks (pull_request) Failing after 12s
to 5257fd3fce
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 8s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 10s
CI / Workflow lint (actionlint) (pull_request) Successful in 12s
Third-party parts / As their notes say (pull_request) Successful in 12s
CI / Website build and checks (pull_request) Failing after 20s
PR description / Description follows the template (pull_request_target) Successful in 5s
2026-11-21 05:03:51 +00:00
Compare
Author
Member

Rebased onto main f1f2dc5b (head 5257fd3f), now that #1926 has merged. BeanBot's three points on the older head:

  1. The bound missed the play files: fixed. It now measures the main file and the play files together. A second review found the bound was also wrong the other way: a preparation stopped early and finished under the next translator looked like dead weight, so the following update dropped it and compiled everything again. The base now comes only from a cache a precompile finished for. A cache with no finished precompile is carried at most 8 times.
  2. Failed or interrupted metadata writes: fixed. The base is written first and names the stamp it moves from, and the stamp moves only once the base is in place. A start cut short between them finishes that carry without counting it twice. A cache file that can't be removed leaves the stamp as it was, so the next start drops it.
  3. RAM, VRAM and warm-start cost: not measured yet. It's in Still to test and in Risks. The worst case the bound allows is half as large again (2.8 GB instead of 1.9 GB on my PC).

In the game on this head (Windows 11, RX 6700 XT, the launcher's preparation path, AMD's own cache cold): a real translator change, nightly-622's caches to current main. The cache was carried, 38,809 programs translated in 124.4 s, and 38,024 noted pipelines came from the cache in 7.2 s with nothing compiled. That's 133 s in all, against 83 minutes for nightly-622. The same folder started again took 23 s.

Linux and NVIDIA still need the Test Farm. nightly-649 and nightly-665 already contain #1448, so players updating to them have already recompiled once. This PR protects the next translator change.

Rebased onto main `f1f2dc5b` (head `5257fd3f`), now that #1926 has merged. BeanBot's three points on the older head: 1. **The bound missed the play files: fixed.** It now measures the main file and the play files together. A second review found the bound was also wrong the other way: a preparation stopped early and finished under the next translator looked like dead weight, so the following update dropped it and compiled everything again. The base now comes only from a cache a precompile finished for. A cache with no finished precompile is carried at most 8 times. 2. **Failed or interrupted metadata writes: fixed.** The base is written first and names the stamp it moves from, and the stamp moves only once the base is in place. A start cut short between them finishes that carry without counting it twice. A cache file that can't be removed leaves the stamp as it was, so the next start drops it. 3. **RAM, VRAM and warm-start cost: not measured yet.** It's in Still to test and in Risks. The worst case the bound allows is half as large again (2.8 GB instead of 1.9 GB on my PC). **In the game on this head** (Windows 11, RX 6700 XT, the launcher's preparation path, AMD's own cache cold): a real translator change, nightly-622's caches to current main. The cache was carried, 38,809 programs translated in 124.4 s, and 38,024 noted pipelines came from the cache in 7.2 s with nothing compiled. That's 133 s in all, against 83 minutes for nightly-622. The same folder started again took 23 s. Linux and NVIDIA still need the Test Farm. nightly-649 and nightly-665 already contain #1448, so players updating to them have already recompiled once. This PR protects the next translator change.
madebyjordan force-pushed perf/pipelines-outlive-translator from 5257fd3fce
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 8s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 10s
CI / Workflow lint (actionlint) (pull_request) Successful in 12s
Third-party parts / As their notes say (pull_request) Successful in 12s
CI / Website build and checks (pull_request) Failing after 20s
PR description / Description follows the template (pull_request_target) Successful in 5s
to 0b35542811
All checks were successful
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 35s
CI / Conventional Commit title (pull_request) Successful in 25s
CI / Workflow lint (actionlint) (pull_request) Successful in 33s
Guide screenshots / Guide images and local UI source review (pull_request) Successful in 38s
Third-party parts / As their notes say (pull_request) Successful in 45s
CI / Website build and checks (pull_request) Successful in 2m42s
2026-11-21 06:29:50 +00:00
Compare
Owner
@review
Member

The ChatGPT usage limit is reached (it resets Nov 25th, 2026 1:04 AM), so this review is paused. It runs by itself once the limit lifts (tried again every 30 minutes); nothing needs asking again.


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

The ChatGPT usage limit is reached (it resets Nov 25th, 2026 1:04 AM), so this review is paused. It runs by itself once the limit lifts (tried again every 30 minutes); nothing needs asking again. --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
BeanBot left a comment

Recommendation: Request changes. The carry can establish its size bound from a cache that was never fully built or saved, and some notes can be lost or remain permanently stale. The reported preparation speedup is promising, but its baseline and the memory cost need controlled measurements.

The change preserves driver pipelines and notes across translator updates, potentially avoiding lengthy cold compilation. It adds cache-lifetime metadata and retains stale notes, increasing startup memory and storage until the cache or notes are reset.

@fix will do (4)

  1. L1 gpu/vk/pcache_stamp.h:97: The .built stamp does not prove the cache contains a finished precompile. (more on the line)
  2. L2 gpu/vk/vk_draw.cpp:1924: Stale notes are still inserted into noted by their old keys. (more on the line)
  3. L3 gpu/vk/vk_draw.cpp:12179: This reader accepts legacy notes but never restamps them. (more on the line)
  4. L5 (its part an edit can do) gpu/vk/pcache_stamp.h:42: Reduce the carry bound or discard accumulated stale cache data sooner if the measurements show an unacceptable cost.

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

  • L4 (minor): Measure the update preparation against the merge base using the same seeded cache, build settings and hardware, with repeated runs. The 83-minute comparison is against nightly-622, so it does not establish the size of this change's gain against its base.
  • L5 (minor) gpu/vk/pcache_stamp.h:42: Measure cold and warm startup, RAM and VRAM with a carried cache near the bound against a fresh cache, including affected Linux and NVIDIA systems. (more on the line)

Checks: Still running: CI / Website build and checks (pull_request).

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

Does it help: Unproven against the requested baseline: the author reports 133 seconds versus 83 minutes on an RX 6700 XT, but these are single runs on different builds, with the before run using nightly-622 rather than the merge-base build. The reported cache hits are strong evidence for the mechanism.

Other systems: Windows AMD preparation was exercised; Linux and NVIDIA remain untested. A changed translator with moved note keys has not been tested in play. Carried caches affect startup time, RAM and potentially VRAM; their near-bound costs are unmeasured. The launcher must preserve these files for updates to benefit.

Switches: No switches added, changed or removed.

Reviewed: 0b35542811 against e6196f0f54: Read the repository rules, PR template, standards, commit messages, pcache_stamp.h and test_notes_format.py; inspected the production diff and surrounding cache, precompile and notes-reader paths. Skimmed the remaining changed tests and pack-script change. The full large production files, generated files and translations were not read in full. docs/review-checklist.md and ../Tooling were absent.; nothing run (a code review).

Checked and fine:

  • The changed commits record AI assistance.
  • No game-derived files, generated shaders, renderer API changes or switch-table changes appear in the diff.
  • The carry calculation includes play cache files, and the new tests exercise interrupted metadata writes and the carry count.

Testing: No code, tests or project scripts were run, as requested. The author reports an in-game Windows AMD preparation and a suite run; the website check is still running.

Overlaps and merge order: LongshotLauncher#220 must preserve the pipeline files across translator updates for the launcher update path to benefit; coordinate its merge with this change.


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

**Recommendation: Request changes.** The carry can establish its size bound from a cache that was never fully built or saved, and some notes can be lost or remain permanently stale. The reported preparation speedup is promising, but its baseline and the memory cost need controlled measurements. The change preserves driver pipelines and notes across translator updates, potentially avoiding lengthy cold compilation. It adds cache-lifetime metadata and retains stale notes, increasing startup memory and storage until the cache or notes are reset. **`@fix` will do (4)** 1. **L1** `gpu/vk/pcache_stamp.h:97`: The .built stamp does not prove the cache contains a finished precompile. (more on the line) 2. **L2** `gpu/vk/vk_draw.cpp:1924`: Stale notes are still inserted into noted by their old keys. (more on the line) 3. **L3** `gpu/vk/vk_draw.cpp:12179`: This reader accepts legacy notes but never restamps them. (more on the line) 4. **L5** (its part an edit can do) `gpu/vk/pcache_stamp.h:42`: Reduce the carry bound or discard accumulated stale cache data sooner if the measurements show an unacceptable cost. **For the author (2)** (a run, a measurement or a decision) - **L4** (minor): Measure the update preparation against the merge base using the same seeded cache, build settings and hardware, with repeated runs. The 83-minute comparison is against nightly-622, so it does not establish the size of this change's gain against its base. - **L5** (minor) `gpu/vk/pcache_stamp.h:42`: Measure cold and warm startup, RAM and VRAM with a carried cache near the bound against a fresh cache, including affected Linux and NVIDIA systems. (more on the line) **Checks:** Still running: `CI / Website build and checks (pull_request)`. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven against the requested baseline: the author reports 133 seconds versus 83 minutes on an RX 6700 XT, but these are single runs on different builds, with the before run using nightly-622 rather than the merge-base build. The reported cache hits are strong evidence for the mechanism. **Other systems:** Windows AMD preparation was exercised; Linux and NVIDIA remain untested. A changed translator with moved note keys has not been tested in play. Carried caches affect startup time, RAM and potentially VRAM; their near-bound costs are unmeasured. The launcher must preserve these files for updates to benefit. **Switches:** No switches added, changed or removed. **Reviewed:** 0b3554281107 against e6196f0f5413: Read the repository rules, PR template, standards, commit messages, pcache_stamp.h and test_notes_format.py; inspected the production diff and surrounding cache, precompile and notes-reader paths. Skimmed the remaining changed tests and pack-script change. The full large production files, generated files and translations were not read in full. docs/review-checklist.md and ../Tooling were absent.; nothing run (a code review). **Checked and fine:** - The changed commits record AI assistance. - No game-derived files, generated shaders, renderer API changes or switch-table changes appear in the diff. - The carry calculation includes play cache files, and the new tests exercise interrupted metadata writes and the carry count. **Testing:** No code, tests or project scripts were run, as requested. The author reports an in-game Windows AMD preparation and a suite run; the website check is still running. **Overlaps and merge order:** LongshotLauncher#220 must preserve the pipeline files across translator updates for the launcher update path to benefit; coordinate its merge with this change. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
@ -23,0 +39,4 @@
/// How far the cache may have grown past its base and still be carried to another translator (3/2: half as large again)
constexpr uint64_t kCarryGrowthNum = 3, kCarryGrowthDen = 2;
/// How many translators a cache no precompile has finished for is carried through, having no size to be judged by
constexpr uint64_t kUnfinishedCarries = 8;
Member

L5 (minor): Measure cold and warm startup, RAM and VRAM with a carried cache near the bound against a fresh cache, including affected Linux and NVIDIA systems. The author estimates 2.8 GB versus 1.9 GB of cache on the tested PC, but the resulting working-set and startup costs are unknown.

**L5** (minor): Measure cold and warm startup, RAM and VRAM with a carried cache near the bound against a fresh cache, including affected Linux and NVIDIA systems. The author estimates 2.8 GB versus 1.9 GB of cache on the tested PC, but the resulting working-set and startup costs are unknown.
@ -47,0 +94,4 @@
/// Whether a precompile got to its end for `kept`: the cache then holds every noted pipeline
inline bool finished_for(const std::string& dir, uint64_t kept) {
FILE* f = fopen((dir + kBuiltFile).c_str(), "rb");
Member

L1: The .built stamp does not prove the cache contains a finished precompile. precompile_warm writes it after two interrupted starts without building the notes, and precompile_run writes it before its subsequent cache save. After either case, a translator update can record a partially populated cache as the base; finishing the missing pipelines later can exceed 1.5 times that base and make the following update discard the useful cache. Write and use a separate completion record only after a successful full cache save.

**L1**: The .built stamp does not prove the cache contains a finished precompile. precompile_warm writes it after two interrupted starts without building the notes, and precompile_run writes it before its subsequent cache save. After either case, a translator update can record a partially populated cache as the base; finishing the missing pipelines later can exceed 1.5 times that base and make the following update discard the useful cache. Write and use a separate completion record only after a successful full cache save.
@ -1869,2 +1921,4 @@
const bool same = notes_stamp_ok(head[0]) && head[1] == sizeof(PipeNote);
if (same) notes_restamp(path, head[0]);
if (same) cut_part_record(path, sizeof head, sizeof(PipeNote));
if (same && known) {
Member

L2: Stale notes are still inserted into noted by their old keys. If a translator change makes an old note's key invalid and a different current state uses that key, the old note is passed over during precompile, but play cannot record the current state because noted already contains the key. That pipeline then remains absent from future precompiles and can repeatedly compile during play. Remove or replace invalid notes when their keys are checked, and test a moved key reused by another state.

**L2**: Stale notes are still inserted into noted by their old keys. If a translator change makes an old note's key invalid and a different current state uses that key, the old note is passed over during precompile, but play cannot record the current state because noted already contains the key. That pipeline then remains absent from future precompiles and can repeatedly compile during play. Remove or replace invalid notes when their keys are checked, and test a moved key reused by another state.
@ -12121,7 +12177,7 @@ std::vector<NoteRef> pipe_notes_refs(bool* whole) {
FILE* f = fopen(pipe_notes_path().c_str(), "rb");
if (!f) return refs;
uint64_t head[2] = {0, 0};
Member

L3: This reader accepts legacy notes but never restamps them. For example, a create-mode warm that only reads references can finish on the old translator, yet the next translator rejects and loses those notes. Restamp an accepted legacy header after closing this reader and cover this reader in the migration test.

**L3**: This reader accepts legacy notes but never restamps them. For example, a create-mode warm that only reads references can finish on the old translator, yet the next translator rejects and loses those notes. Restamp an accepted legacy header after closing this reader and cover this reader in the migration test.
madebyjordan force-pushed perf/pipelines-outlive-translator from 0b35542811
All checks were successful
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 35s
CI / Conventional Commit title (pull_request) Successful in 25s
CI / Workflow lint (actionlint) (pull_request) Successful in 33s
Guide screenshots / Guide images and local UI source review (pull_request) Successful in 38s
Third-party parts / As their notes say (pull_request) Successful in 45s
CI / Website build and checks (pull_request) Successful in 2m42s
to 73a55f53f0
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
CI / Website build and checks (pull_request) Waiting to run
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 7s
PR description / Description follows the template (pull_request_target) Successful in 10s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 11s
CI / Workflow lint (actionlint) (pull_request) Successful in 12s
Third-party parts / As their notes say (pull_request) Successful in 13s
2026-11-21 09:25:46 +00:00
Compare
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
CI / Website build and checks (pull_request) Waiting to run
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 7s
PR description / Description follows the template (pull_request_target) Successful in 10s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 11s
CI / Workflow lint (actionlint) (pull_request) Successful in 12s
Third-party parts / As their notes say (pull_request) Successful in 13s
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!1927
No description provided.