fix(vk): a start that compiled its noted pipelines writes the pipeline cache before the title #903
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!903
Loading…
Reference in a new issue
No description provided.
Delete branch "zeldaootr/Longshot:precompile-save-before-title"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type: fix · Risk: medium · Tested on: Linux game-free checks; Steam Deck OLED (SteamOS 3.9.5, RADV): a start that compiled for 1,454 s wrote the cache before the title, and the next start compiled nothing · Needs: Windows, any GPU (a start that compiles for 30 s or more: the write's time)
Why
A start that had to compile its noted pipelines should keep them, so the next start finds them. On a Steam Deck a start compiled all 32,438 of them for about 20 minutes and kept none in our pipeline cache, because in play the cache is written only once it has grown 64 MB, and those pipelines grew it by 4.3 MB (RADV keeps a pipeline as its key and its shaders' hashes, and the code was already there). The next start could find them only in the driver's own folder.
The compile in that case came from Game Mode's
RADV_FORCE_VRS_CONFIG_FILE, which the sibling PR #900 removes. A start still compiles everything after a driver update, or withRX_VK_HALF_RATE_SHADING=1. #789 (a driver update warms the noted pipelines again underRX_VK_LOAD=create) is related; that path already writes the cache, and this PR covers the other one. No issue on the tracker covers it (searched: pipeline cache save, before the title, noted pipelines).How to reproduce
Seen on: SteamOS 3.9.5 (Steam Deck OLED), RADV VANGOGH, Mesa 26.2.0-devel
Settings and switches: defaults;
RADV_FORCE_VRS_CONFIG_FILEnaming a file (as Game Mode does) on main, to make the start compileSteps: prepare outside Game Mode, start with the variable set, wait through "Loading pipelines" to the title, quit, and start the same way again.
Expected: the second start finds the pipelines in our cache.
Actual:
vk: pipeline cache 4303 KB larger in play: written once it is 64 MB larger, or by a forced save; the cache file is not written, and the second start depends on what the driver's folder kept.What changed
A start whose noted pipelines took
RX_VK_PRECOMPILE_SAVE_S(30 s) or more to build writes the pipeline cache before the title, with the start-up screen showing it as saving. The log says what the save did and how long it took. The warm pass underRX_VK_LOAD=create, which already wrote the cache, now reports the same way.gpu/vk/precompile_save.h(new, standard library only):after_sreads the switch;duedecides the save (the build took that long, the precompile reached its end, and this is a game start, since the preparation's process writes the cache anyway);saidputs what a save did into words.gpu/vk/vk_draw.cpp:precompile_run: whendue, it setsprepare_saving_now(the start-up screen's saving state, asprecompile_warmdoes), callspipeline_cache_save(true), and logsvk: precompile: its pipelines took N s (compiled, not found in the caches): the pipeline cache <what it did>, in T ms, before the title.precompile_warm: its forced save logsthe pipeline cache <what it did>, in T msinstead of an unconditional "written out".pipeline_cache_saverecords how each save ended inpcache_save_outcome, thread-local: a forced save runs on its caller's thread.docs/development.md's row forRX_VK_PRECOMPILE_SAVE_S;docs/tested/2026-11-15-precompile-save-zeldaootr-deck02.md, the Deck run below.tests/test_precompile_save.py(cuttingvk_draw.cpp's functions withtests/srccut.py'sblock) withtests/precompile_save_test.cpp.tests/pipeline_cache_save_test.cpp, which compiles the realpipeline_cache_save, also checks the recorded outcome: written with its size, nothing new, fetch failed, write failed.This changes behaviour on every platform: after any precompile of 30 s or more (the first start after a driver update on Windows, for one) the whole cache is written before the title, only when it grew. That costs seconds once (821 ms for 439 MB on a Deck's internal storage), and what was compiled is no longer lost if the game is closed or crashes before play writes it.
Measurements
Verdict: fixed on the Deck: after a 1,454 s compile the pipeline cache (439.3 MB) was written before the title, in 821 ms, and the next start from that folder compiled nothing and reached the title in 46 s; on main the same kind of start left the cache unwritten. Starts that found their pipelines (12-21 s) did not save, as intended.
Baseline: the After column is the local integration
vrs-verify(bfc69759): main @aa95d35fwith this PR and its two siblings (#900, #902), since the compiling start needs #900'sRX_VK_HALF_RATE_SHADING=1. The Before column is an earlier build of main @aa95d35fwith other open PRs, the same Deck and caches. Since then this PR was rebased onto main @a8a30c22with its code unchanged (only the test's cutter moved totests/srccut.py); main's changes inprecompile_run(Linux notes built programs) andpipeline_cache_save(its background thread registered) do not touch the save before the title, so the numbers hold.Hardware: Steam Deck OLED, AMD Custom GPU 0932 (RADV VANGOGH), Mesa 26.2.0-devel (git-5c65d4fc31), SteamOS 3.9.5 (20261023.100), 16 GB
Scene: the start-up, up to the title; scratch game folders; headless, defaults, the precompile at its default and
RX_VK_PRECOMPILE_SAVE_Sunset (30)Method: the log's
vk: precompile:andvk: pipeline cachelines, the time to the title and the cache file's size. Run deck01 (the starts that found their pipelines): 4 starts interleaved a, b, b, a, each from a fresh copy of the same warm caches. Run deck02 (the save): c1 from a fresh copy of those caches made without the variable, withRADV_FORCE_VRS_CONFIG_FILEnaming a1x1file andRX_VK_HALF_RATE_SHADING=1, so every graphics pipeline is compiled again; then c2 from the folder c1 left, the same variables. One c1 and one c2: the fix is shown by its log lines and the next start, not by a timing comparison, and each time below is a single run.How to reproduce:
printf 1x1 > vrs-1x1.txt; restore the warmcache/; start to the title withRADV_FORCE_VRS_CONFIG_FILE=<that file> RX_VK_HALF_RATE_SHADING=1; quit and start again the same way without restoring.aa95d35f(with other open PRs)53c0be91(invrs-verifybfc69759)written once it is 64 MB larger: never written(The
...are parts of the lines not copied off the Deck in the run's notes; the logs stayed on it.)Flags and settings
One new switch, on by default.
RX_VK_PRECOMPILE_SAVE_S=<s>0: never)LONGSHOT_PREPARE_ONLYvk_main.cpp, not a switch)Testing
Tested:
vrs-verifybfc69759 (main @aa95d35fwith #900 and #902), run deck02: c1 compiled every pipeline (1,454 s) and logged the save before the title (439.3 MB in 821 ms), title at 1,501 s; c2 from that folder compiled nothing, title at 46 s. Run deck01: 4 starts that found their pipelines (12-21 s), none saved before the title, as intended.tests/test_precompile_save.py, with g++ 13.3 and clang 23.1: fails at the test commit (4aa2097c:vk_draw.cpp does not include precompile_save.h,gpu/vk/precompile_save.h is missing) and passes at the fix; its cuts compared with the old brace counter (SRCCUT_CHECK_NAIVE=1): the same.python -I -B tests/run_all.py --changed forge/mainon Linux, 8 at once: withCXX=g++113 passed, 6 failed, 14 skipped; withCXX=clang++114 passed, 5 failed, 14 skipped.test_crash_dialog,test_pipeline_tour,test_vk_occlusion_queries,test_vk_pgoandtest_walk_keyfail the same way on main @a8a30c22. The sixth with g++,test_pipeline_cache_save, timed out in its in-play case's 3 s wait (FAIL line 350: wait_until(play_saves, 3)) on a loaded PC (load average 50 on 16 threads); run alone, interleaved with main, it passed 3 of 3 here and 2 of 3 on main, whose failure is the same wait (line 341).gpu/vk/precompile_save.hcompiled alone (-std=c++20 -Wall -Wextra -Werror) with g++ (libstdc++), clang and llvm-mingw clang (Windows target).gpu/vk/vk_draw.cppwhole-file syntax check with the build's renderer flags, Linux (clang) and Windows (llvm-mingw), before the rebase, on main @f637b42d: the same as main (Linux 103 warnings and main's one narrowing error at an unchanged line; Windows 0 errors, 105 warnings). The rebase applied the same hunks without conflict; the names they use (built0,gone_on,prepare_stopped,prepare_saving_now,env_on) are all still inprecompile_runon main @a8a30c22.python -I -B tests/run_all.pyon Linux at this PR's head, 8 at once: 547 passed, 21 failed, 78 skipped (tools this PC lacks). The 21 fail the same way on main @a8a30c22run alone:test_appimage_player_build,test_bake_portability,test_bug_reportandtest_hardware_report(the Tooling checkout not beside the clone),test_crash_dialog,test_crt_options,test_env_on,test_lift_cache,test_lift_cleanup_error,test_linux_preflight,test_linux_update,test_make_game_cache,test_missing_nup,test_mods_size_table,test_options_budget_once,test_pipeline_tour,test_readback_late,test_run_all_changed,test_vk_occlusion_queries,test_vk_pgo,test_walk_key.test_precompile_save,test_pipeline_cache_saveandtest_tested_configurationspassed in it.Not tested: whether the start-up screen showed its "saving" state during the 821 ms (the run was headless); a real Game Mode start from Steam (the run set the variable by hand, as Game Mode does); the write's time on a microSD card and on Windows; a full renderer build and run on Windows (the change is platform-neutral code); this PR on its own, without #900 and #902, in the game.
Must be tested:
longshot_vk_pipelines.binout of the cache folder (or start after a driver update), start the game to the title, expectingvk: precompile: its pipelines took N s (compiled, not found in the caches): the pipeline cache written, M MB, in T ms, before the titlewhen the precompile took 30 s or more and no such line otherwise, the start-up screen showing it saves, and the next start finding the pipelines (by hand: report N, M and T and what the start-up screen showed).Risks
What could break: a start that compiled for 30 s or more now writes the whole pipeline cache before the title, on every platform: 821 ms for 439 MB on a Deck's internal storage, more on a microSD card or a slow disk. A start that took 30 s while finding its pipelines (a slow disk) asks the driver for the cache's size and writes nothing when it didn't grow.
Turning it off:
RX_VK_PRECOMPILE_SAVE_S=0.Compatibility: nothing changes in the caches beyond
longshot_vk_pipelines.binbeing written earlier; saves,longshot_options.iniand the vk ABI are unchanged.Checklist
Everyone
type(scope): description) of the status line's type.main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.docs/tested/for each new measured run (format indocs/tested-configurations.md).mainand passing here.tests/that reads changed source updated in this PR, not weakened.53c0be913a3ac77beb07Measured on a Steam Deck OLED (RADV, in the integration build
vrs-verifybfc69759): withRX_VK_HALF_RATE_SHADING=1a start compiled every pipeline for 1,454 s and wrote the pipeline cache before the title (439.3 MB in 821 ms), and the next start from that folder compiled nothing and reached the title in 46 s; the start-up screen's saving state was not seen, as the run was headless. Rebased onto main @a8a30c22with the code unchanged: the test now cutsvk_draw.cppwithtests/srccut.py'sblock, and the run is indocs/tested/2026-11-15-precompile-save-zeldaootr-deck02.md. Measurements, Testing and the checklist are updated; Windows is still to be tested.WIP: fix(vk): a start that compiled its noted pipelines writes the pipeline cache before the titleto fix(vk): a start that compiled its noted pipelines writes the pipeline cache before the title@Beanstalk windows, any GPU: start from cold shader caches so the start compiles its pipelines for more than 30 seconds, and let it reach the title. Expecting the log line
the pipeline cache written, ... before the title, and a second start from the same folder that reaches the title without compiling. On a start that compiles nothing, no change from main.@zeldaootr only members of
BigBeanscan start the farm.One of them can approve this request by reacting 👍 to it.This request was for3ac77be, and the PR has changed since (ae5a2fa), so a 👍 no longer approves it. Comment@Beanstalkagain to ask for the new commit.A Windows run for Must be tested, by hand. In short: the save-before-title branch works on Windows, but only with the threshold lowered. This PC never reaches 30 s.
Hardware: Windows 11 Pro 26300, RTX 3080 10 GB (NVIDIA 621.14), i9-12900K, 64 GB
Build: this PR's head
3ac77bebmerged onto main @1764fed2(d3a106c4, local only, no conflict), a standalone build (llvm-mingw). It's a development build, so the precompile needsRX_VK_PRECOMPILE=1. Each start went to the title through the control bridge and quit there.longshot_vk_pipelines.binand its stamp were moved out of the cache folder before each cold start. NVIDIA's own driver cache was left alone, since other games on this PC use it.RX_VK_PRECOMPILE=1(soRX_VK_LOAD=create, the default with mesh shaders)pipeline cache ... (0 KB); the warm path builds1913 noted pipelines ... in 1.0 sand writesthe pipeline cache written, 93.6 MB, in 69 ms. Your branch doesn't apply on this pathRX_VK_PRECOMPILE=1;RX_VK_LOAD=startwith the default 30 sRX_VK_PRECOMPILE=1;RX_VK_LOAD=start;RX_VK_PRECOMPILE_SAVE_S=1precompile: 1402 programs, 1913 graphics and 151 compute pipelines ... in 1137 ms, thenpipeline cache saved (95873 KB)andvk: precompile: its pipelines took 1 s (compiled, not found in the caches): the pipeline cache written, 93.6 MB, in 71 ms, before the title (RX_VK_PRECOMPILE_SAVE_S=0: not)RX_VK_PRECOMPILE=1;RX_VK_LOAD=startpipeline cache ... (95873 KB)found; the precompile in 280 ms; no save lineSo on Windows the new branch writes the cache before the title, and the next start finds every pipeline in it. The title came in 46-47 s on every start, and there was no device loss,
VK_ERRORor FATAL line.Not seen: the start-up screen's "saving" text. The write took 71 ms, and screenshots every 120 presents didn't catch it. Also not reached: a real precompile of 30 s or more. The driver's own cache makes this card's compile take about 1 s, so the "compiled, not found in the caches" wording held only because I lowered the threshold. A PC with an empty driver cache, after a driver update, is where the default 30 s path would show.
Posted by an AI agent (Claude Code) for d4nkn3ss.
Thanks @d4nkn3ss. So on Windows the save before the title works and the next start finds every pipeline in it, and the default 30 s threshold is never reached on a card whose driver cache already holds the pipelines, which is the intended quiet case. The 30 s path with a cold driver cache is still shown only on the Steam Deck run in the description.
Code-only review of
3ac77beb07; informational findings, with final approval left to another reviewer.No new correctness defect found in the changed save path. The early forced save follows worker joins, excludes abandoned/stopped/preparation-only runs, and uses the existing atomic file publication and fetch synchronization. Its outcome is thread-local, matching the forced save's synchronous execution.
The Windows result provides useful coverage beyond the description: the 1 s override exercised publication and the following start reused the cache. It does not cover the listed default-threshold cold-driver case or the visible saving state; the Deck integration run covers the long-compile case. Those remaining observations are validation gaps, not a code defect established by this review.
The helper tests exercise the threshold and cancellation decisions, and the existing save fixture checks publication failures and outcomes. The new caller wiring check is textual: negating
due(...)would retain its expected strings, so it does not independently prove the caller obeys that decision. A behavioral caller test would strengthen regression coverage.Merge coordination: 789 handles cache invalidation for the separate load-at-create path; 902 adds environment diagnostics. Neither replaces this persistence change. Preserve 498's quit-marker handling when integrating startup changes.
Read the full diff, startup/cancellation/save callers, storage contract, tests and current discussion. No tests, builds or game runs performed.
Tested in the game on Linux with NVIDIA, the start path with every pipeline compiled. In short: the save before the title works, and a start with nothing new to save costs 1 ms.
Hardware: RTX 3090 (NVIDIA 620.70.06), Ryzen 9 7900X, 30 GB, CachyOS (Linux 7.3)
Build: this PR's two commits on main @
02903b04(a renderer pack over a prepared base: only this PR's files differ from it), headless, through the PC's job queue (shared)Switches:
RX_VK_PRECOMPILE=1 RX_VK_LOAD=start. Before run 1,longshot_vk_pipelines.binand its stamp moved out of the cache folder. Each run with its own empty NVIDIA shader cache (__GL_SHADER_DISK_CACHE_PATH), so nothing could come from the driver's folder.pipeline cache ... (0 KB))precompile: 33375 programs, 32390 graphics and 9927 compute pipelines ... in 333177 ms, thenpipeline cache saved (1426415 KB)andprecompile: its pipelines took 327 s (compiled, not found in the caches): the pipeline cache written, 1393.0 MB, in 5148 ms, before the title. The file was on disk (1,460,649,748 bytes) before the first present1426415 KB), the pipelines compiled again in 321652 ms, thenthe pipeline cache not written: nothing new since it was read or last written (1393.0 MB), in 1 ms, before the titleRun 2 compiled everything again because NVIDIA answers a new process from its own shader cache, not from
VkPipelineCachedata (development.md,RX_VK_LOAD), and that cache was empty on purpose. So the faster second start is RADV's, shown on the Deck run; what this run shows is the save itself, on a driver the Deck run didn't cover, and the save's no-op path.Pushed to the branch (a merge of main, no rewrite),
ae5a2fa2:tests/test_quit_not_crash.py, which came to main after this branched, pastesprecompile_warm'sif (all && !prepare_stopped())block into its fixture. That block now namesprecompile_save::saidandpcache_save_outcome, which the fixture didn't declare, so the check stopped compiling. Both are added under__has_include, ascrash_markers.his. No tests were run on this PC (a code read only); the other checks that cutprecompile_run,precompile_warmorpipeline_cache_savewere read and either compile stubs or match strings this PR leaves alone.Approving. The save before the title is right:
pipeline_cache_save(true)runs on the precompile's thread, so thethread_localoutcome is read where it was written; a forced save can't be put off (hadis always true withwait_ms-1), so it never logs "did not run"; the 64 MB play rule applies only unforced, andpcache_saved_sizemoves with the write. Tested on an RTX 3090 (comment above): 1.39 GB written in 5.1 s after a 327 s compile, and 1 ms when nothing was new.The one blocker I found,
tests/test_quit_not_crash.py's fixture missing the two namesprecompile_warmnow uses, is fixed on the branch (ae5a2fa2). Two nits inline, neither blocking.@ -9601,6 +9604,19 @@ void precompile_run(void (*progress)(size_t done, size_t total)) {cs_cached + cs_compiled, cs_cached, cs_compiled, cs_failed);// (every note built, by a run that got to its end: RX_VK_LOAD=create may load them from the caches from the next start on)if (!gone_on && !prepare_stopped()) precompile_built_write(graphics_n);// (pipelines that took this long were compiled, not found: written before the title, the start-up screen saying so, asNit:
precompile_warmwrites the cache before its marker ("in the file before the marker says they are there"); hereprecompile_built_writeruns just above, then a write that takes seconds (5 s for 1.4 GB on an RTX 3090). A start closed during that write leaves a marker saying the notes are in a cache that doesn't have them. Main has the same order with no save, so it's not new, but putting this save above that line would keep the two paths alike.@ -9604,0 +9613,4 @@prepare_saving_now.store(true, std::memory_order_relaxed);pipeline_cache_save(true);prepare_saving_now.store(false, std::memory_order_relaxed);logf("vk: precompile: its pipelines took %.0f s (compiled, not found in the caches): the pipeline cache %s, in %.0f ms, "Nit:
duegoes by time alone, so a slow disk whose start found everything but took 30 s gets here too, and the line then says "compiled, not found in the caches".kSamemakes it a no-op when the cache didn't grow, so only the words are off: "its pipelines took N s" would say just what's known.