perf(vk): a start whose driver lost its shader cache builds the pipelines again before the title, not with draws left out in play #1188
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1188
Loading…
Reference in a new issue
No description provided.
Delete branch "GummiNaomi/Longshot:perf/cold-cache-check"
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: perf · Risk: low · Tested on: Windows 11, RTX 4070 SUPER (NVIDIA 617.42) · Needs: AMD on Windows; Linux (RADV, NVIDIA); a Steam Deck; a real driver update
Why
After a driver update, or once NVIDIA's shader cache evicts past its size (it is shared with every other game), the first session plays with large parts of the picture missing for seconds at a time, and only the next start puts it right.
A start that loads programs at their create calls (
RX_VK_LOAD=create, the default) trusts the marker that says every noted pipeline was built into the pipeline cache. On NVIDIA that cache only refers to the driver's own: with the driver's cache gone, each listed pipeline is in no cache, is compiled in play, and its draws are left out meanwhile. Measured on the gate route with NVIDIA's cache pointed at an empty folder: 10,263 listed pipelines in no cache, 702,312 draws left out in 140 s (in 21 of 163 two-second spans, up to 1,172 a frame there, of about 2,500), and 21 s of draw waits. The safety net then sends the next start to building every listed program before the title (longshot_load_start.txt, which keeps them all for good, 4-5 GB of memory at every later start perload_default.h).Things that did not help here, for the record: stage libraries (
RX_VK_GPL=1) kept in our pipeline cache came back cold too (1,968 of 2,070 libraries, 964,332 draws left out); quick pipelines (RX_VK_QUICK_MS=8) left out 92 % fewer draws but each took 14-80 ms on NVIDIA (frames over 50 ms 46 -> 148, 1 % low 47 -> 29 fps);VK_KHR_pipeline_binarybinaries kept by us also need NVIDIA's cache warm (143 of 8,000 made from them on another empty cache).What changed
A start that would load at create calls first asks the driver whether it still has a sample of the noted pipelines; where it has lost most of them, it builds them all again before the title, behind the progress screen, instead of in play.
notes_lost_by_driver()asks the driver alone (an empty scratch pipeline cache) for 48 noted pipelines spread over the notes file, without compiling (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT, needspipelineCreationCacheControl). Where at least a third were asked and over half are cold,precompile_runremoves the built marker and runs the existing warm pass (precompile_warm) at this start (gpu/vk/vk_draw.cpp). Not in the preparation's own process (LONGSHOT_PREPARE_ONLY, read here, not a new switch). The thread's driver-only state, the scratch cache and the file are put back by a guard however the function ends.RX_VK_COLD_CHECK=0: not asked.tests/test_cold_cache_check.py(the sample asked of the driver alone without a compile, the threshold, the warm pass run after a lost sample, the guard).RX_VK_COLD_CHECKindocs/development.md;docs/tested/2026-11-16-cold-cache-check-gumminaomi.md.Measurements
Verdict: with the driver's cache lost, the first session draws almost everything (456 draws left out against 702,312, no waits against 21 s), for a 4.5-minute build before the title on 16 threads; with it intact, the check costs about 0.2 s a start and changes nothing.
Hardware: Windows 11 Pro 26200, RTX 4070 SUPER 12 GB (NVIDIA 617.42), Ryzen 9 9950X3D (16 cores, SMT off), 32 GB
Scene: save set "First Step into Hyrule Town", Castle Town's gate into Hyrule Field and back (gate-bridge-wall.txt, wall clock), 2560x1440, DLAA, uncapped,
RX_VK_LOAD=createMethod: headless runs; a cold driver cache by
__GL_SHADER_DISK_CACHE_PATH=<an empty folder>(NVIDIA's Windows driver honours it; the player's own cache untouched); the log'sa frame:lines summed (draws left out, waits) and itsshader cache hasandprecompile:linesBaseline: main's behaviour is this PR with
RX_VK_COLD_CHECK=0; the before column is main 13e90a5e's run (cold-1) with #1158's changes beside it, the after column this change on main71b1edd8, then rebased onto main26ce01b5(warm check run again there: 48 of 48 in 220 ms). The numbers still hold on26ce01b5: the one change to this path since13e90a5eis #903 (f9a2195c), which writes the pipeline cache before the title after a long build; on NVIDIA that cache refers to the driver's own, so with the driver's cache emptied the listed pipelines are cold just the same (the cold run itself was on71b1edd8, which has #903)How to reproduce: point
__GL_SHADER_DISK_CACHE_PATHat an empty folder on NVIDIA, start once; compare withRX_VK_COLD_CHECK=013e90a5e(cold-1)5045adf3Flags and settings
One new switch, on by default.
RX_VK_COLD_CHECKTesting
Tested: Windows 11, RTX 4070 SUPER, NVIDIA 617.42: warm starts (the check passes, nothing built) and a cold start (lost, built, played);
tests/test_cold_cache_check.pypasses;python -I -B tests/run_all.py: the same 64 failing tests as main26ce01b5on this PC (its toolchain: Windows line endings, fixtures needing gcc or clang++), plustests/test_longshot_ctl.py's relaunch case, which fails in some full runs on Windows and passes alone here and on main (a timing flake in the control bridge's stand-in; nothing this PR touches).Not tested: a real driver update, AMD (whose Windows driver keeps few entries of its cache), Intel, Linux, the Steam Deck, where 4 cores make the build before the title much longer.
Must be tested:
the driver's shader cache has N of 48line; on a driver that keeps its cache a high N and nothing built, else the build before the title and no draws left out in play (by hand)Risks
What could break: a driver that answers a cache ask wrongly as cold makes every start build the notes again before the title (3-4 s with them in the driver's cache, as the first start after a preparation; minutes if not). A long build before the title on a slow CPU after a driver update, which the next start did anyway; the check moves it to the start that needs it.
Turning it off:
RX_VK_COLD_CHECK=0.Compatibility: Nothing changes.
Issues
None found for this exactly; the safety net it comes before is
load_default.h's.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).tests/that reads changed source updated in this PR, not weakened.🤖 Generated with Claude Code
WIP: perf(vk): a start whose driver lost its shader cache builds the pipelines again before the title, not with draws left out in playto perf(vk): a start whose driver lost its shader cache builds the pipelines again before the title, not with draws left out in play