perf(vk): with the shader preparation off, kept programs are indexed at start and load at create: ~70 % fewer draws left out (dev builds) #2193
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!2193
Loading…
Reference in a new issue
No description provided.
Delete branch "Jer9/Longshot:perf/vk-saveload-warm-cache"
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?
Summary
With the shader preparation off (
RX_VK_PRECOMPILE=0: the default of development builds; release builds always prepare, and players have no setting that turns it off), loading a save leaveslongshot_programs.binunindexed andpcacheuninitialized duringpipeline_cache_play(). Every program the game creates is then read at its first draw, and its draws are left out meanwhile:2,740–2,774draws left out on a warm-cache save load (6,792across a 3-zone tour) and538–549synchronous program loads on the 860M, about 187k draws left out a run on an RTX 3090.Three issues caused it:
pipeline_cache_play()ran beforepcache_init(), leavingpcacheasVK_NULL_HANDLEand bypassingplay_cache_begin()(play-cache tracking off wheneverprecompile_run()had not initializedpcachefirst; census counters stayed0/0/0).programs_index()only ran insideprecompile_run(). WithRX_VK_PRECOMPILE=0, kept program records inlongshot_programs.binwere never indexed, so none was loaded ahead of its first draw.longshot_load_start.txtleft by an earlier run (with the preparation on) switched the start to loading programs before the title, which only the preparation does: with it off, nothing was loaded before the title and the index was skipped too.This change:
pcache_init()beforeplay_cache_begin()inpipeline_cache_play().programs_index()inpipeline_cache_play()when the preparation is off,RX_VK_NO_PROGRAM_CACHEis not set, and kept program records exist (~2.1 msat start), guardsprograms_index()as one-shot viaindex_ready, and guardsprograms_frames_note()andload_wait_note()soRX_VK_PRECOMPILE=0never writes load-start markers.longshot_load_start.txtaside when the preparation is off (load_default::choose'sprepared): loads at create, since start would load nothing.Split out: the non-compiling cache probe in
graphics_pipeline()(VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BITbefore a play pipeline's background build) was part of this PR until9d2f7b54and goes to a change of its own. With the preparation on it never ran in testing (no pipeline was made in play); with it off it found about 13 % of play's pipelines in the driver's cache on an RTX 3090, at an unmeasured driver call for each of the rest, on every Vulkan 1.3 GPU.Who it helps: development builds, testers and
dev.pyruntimes, whose runs then look closer to players'. Players are unaffected: their preparation builds this index.Read first:
pipeline_cache_playingpu/vk/vk_draw.cpp,programs_index,load_wait_note,programs_frames_noteandprograms_load_decideingpu/vk/vk_programs.cpp,chooseingpu/vk/load_default.h, andtests/test_saveload_warm_cache.py.Testing
Tested: Windows 11, AMD Radeon 860M (Adrenalin 26.10.1 LLPC),
handheld_profile=1(1600x1000,67%render scale,sharpness=80,vsync=0,amd_anti-lag_2=1,threaded_rendering=0).Standalone in-game save load (Kokiri Forest, warm cache,
RX_VK_PRECOMPILE=0, 3 interleaved rounds + 12 s settle) plus 1 cold-cache run: verified0draws left out,0pipeline waits,0synchronous program loads,0VK_ERROR_DEVICE_LOST, and clean 3D transition in a side-by-side Dev FPS counter capture (starting0.50 sbefore Load click; timer starts on Load click).Standalone 3-zone traversal tour (Kokiri Forest, Hyrule Field, Market; 3 interleaved rounds): verified
-95.0%dropped draws,+15.5%1% low lift, flat steady VRAM, and0VK_ERROR_DEVICE_LOST.Game-free regression test
tests/test_saveload_warm_cache.py(includingRX_VK_NO_PROGRAM_CACHE=1skipping indexing and a behavioral C++ check callingprograms_index()twice to verify theindex_readyone-shot guard): fails onmain @ a2dc5385and passes onb6e5f76c(rebased cleanly ontomain @ a2dc5385).Targeted checks on
b6e5f76c:test_saveload_warm_cache.py,test_pipeline_play_cache.py,test_quick_pipelines.py,test_same_draw.py,test_pipeline_share.py,test_draw_side_effects.py,test_jobs_wait_runs_queued.py,test_load_default.py,test_program_load_wait.py,test_note_refs_once.py,test_fallback_loaded.py,test_thinlto_tls.py,test_log_levels.py,test_vk_braces.py,test_utf8_paths.py,test_doc_anchors.py,test_program_stamp_knobs.py,test_cpp_preflight.py, andscripts/check_third_party.py(19/19) all pass. Pre-existing / host caveats:tests/test_switch_table.pyfails identically onmain(RX_VK_GRASS_DISTANCEordering; this PR does not touchswitches.def), andtests/test_job_queue.pyis excluded on Windows shared consoles.Linux, RTX 3090 (NVIDIA proprietary), by HumanBean on
e4ad718b(with the probe),RX_VK_PRECOMPILE=0, loads at create, 2 interleaved runs a side: draws left out 200,436 / 174,720 -> 60,396 / 60,000 a run, worst save-load frame 1,744 / 1,737 -> 1,486 / 1,441 ms, 2,211 programs queued at create (0 onmain). At the default settings, no difference past the spread and no pipeline made in play on either side. Details: #2193 (comment)9d2f7b54(the probe split out, the marker rule): built for Linux (clang); not yet run in the game; its checks not yet run.Still to test:
9d2f7b54in the game withRX_VK_PRECOMPILE=0, with and without a leftoverlongshot_load_start.txt: the index built and programs queued at create in both (by hand)b6e5f76c(RX 9070, RX 6600,RX_VK_GPL=1,RX_VK_PRECOMPILE=0): pictures 0.82–1.0 apart frommain's; whethermain's pictures are the ones missing geometry (@Beanstalk linux-radv)9d2f7b54,test_saveload_warm_cache.pyandtest_load_default.pyamong them (by hand, or CI on the push)Measurements
Verdict: (measured with the cache probe in, which this PR no longer has; the probe served 3 of the save load's pipelines here and about 13 % of play's on the RTX 3090, so most of the gain is the index's) Standalone on
main @ 9e10f6f7, eliminates100%of warm-cache save-load dropped draws (2,773 -> 0) and synchronous program loads (539 -> 0,185.2 ms -> 0.0 ms), cuts 3-zone traversal dropped draws by95.0%(6,792 -> 339), and lifts 3-zone traversal 1% lows by+15.5%(21.71 -> 25.07 FPS,p99 46.06 -> 39.89 ms) with no cold-cache regression.Setup: Windows 11 (26200), AMD Ryzen AI 7 350, AMD Radeon 860M (RDNA 3.5, Adrenalin 26.10.1 LLPC);
handheld_profile=1(1600x1000,67%render scale,sharpness=80,vsync=0,amd_anti-lag_2=1,threaded_rendering=0),RX_VK_PRECOMPILE=0; Kokiri Forest warm-cache save load (12 s settle) and 3-zone traversal (Kokiri Forest, Hyrule Field, Market), 3 interleaved unprofiled runs each, median[min, max].Rebase note: Branch is rebased onto
main @ a2dc5385(#2174simulated-turf floor +#1722castle-gate save); measurements below remain frommain @ 9e10f6f7because#2174did not affect ourKokiri Forest -> Hyrule Field -> Markettour (Hyrule Fieldmax_msonmain @ 9e10f6f7was30.94 / 71.01 / 72.49 ms,gt_50ms0 / 4 / 4, zero 250 ms turf stalls).9e10f6f7e4ad718bfrom_driver, save load)load at create)Cold cache (1 run each, empty cache,
RX_VK_PRECOMPILE=0):2,747 -> 2,172(-20.9%)440 (2,779.0 ms) -> 429 (2,738.0 ms)from_driver/from_start):0 / 0 -> 469 / 2462,709.9 ms -> 2,706.8 ms(-3.1 ms, no regression)2,998 MB -> 3,062 MBMatched headless Dev FPS counter capture (
HOS_HEADLESS=1,RX_VK_SHOT_MENU=1,RX_VK_SHOT_EVERY=3, 1 run each, timed from Load button click with0.50 spre-roll):main @ 9e10f6f7):2,731draws left out,536program loads (204.0 ms),1st 3D: 13.59 sthis PR @ e4ad718b):0draws left out,0program loads (0.0 ms),1st 3D: 12.74 s(-0.85 s)Raw
longshot_log.txtlines (Round 1 save load and Round 1 traversal):Risks
~2.1 msat start, one-shot, skipped underRX_VK_NO_PROGRAM_CACHE=1) and loads at create where a marker used to choose start. A PC where loads at create wait seconds (the RX 580 the marker was made for) now loads at create with the preparation off; before, it read every program at its first draw instead, which is no better. With the preparation on (every release build) nothing changes.RX_VK_LOAD=startorRX_VK_PRECOMPILE=1, or a revert.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (not yet at9d2f7b54, whose two checks changed; earlier, onb6e5f76c: 18 targeted Vulkan/program/pipeline/preflight tests +test_saveload_warm_cache.py+check_third_party.pypass on Windows;test_switch_table.pyfails identically onmain @ 9e10f6f7, andtest_job_queue.pyis excluded on Windows shared consoles).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.Tested in game: Windows 11 (26200), AMD Radeon 860M (Adrenalin 26.10.1 LLPC), handheld_profile=1 (1600x1000, 67%, sharpness=80), RX_VK_PRECOMPILE=0. Kokiri Forest warm-cache save load (3 interleaved rounds + 12 s settle): 2,773 -> 0 draws left out, 539 -> 0 sync program loads (185.2 -> 0.0 ms), 0 pipeline waits, 0 device lost; cold cache: 2,747 -> 2,172 draws left out. 3-zone traversal (Kokiri Forest, Hyrule Field, Market, 3 interleaved rounds): 6,792 -> 339 draws left out (-95.0%), 1% low 21.71 -> 25.07 FPS (+15.5%), 0 device lost.
Possibly related, for context:
Independent test log on a second RDNA 3.5 system (courtesy of
nwgaton Discord):Setup: Windows 11 (
10.0.26300), AMD Ryzen AI 9 365, AMD Radeon 880M (Adrenalin26.11.2 LLPC),1920x1080,handheld_profile=1, FSR 4, VSync on,threaded_rendering=1, defaultRX_VK_LOAD=create(RX_VK_PRECOMPILE=1),KokiriForest_Child(74.7 ssession,pr-2193-e4ad718b).Result: Clean run on default precompile/create settings with
threaded_rendering=1and FSR 4 —0draws left out,0pipeline waits,0shader-translate/pipeline-wait hitches,4driver-cache hits (play file 10 saved),0program_failed,0device_lost,0vram_over_budget, steady VRAM4.1 of 10.2 GB. (Single run without a pairedmainlog on this PC; verifies no regression on default settings +threaded_rendering=1+ Adrenalin 26.11.2.)Key lines from
longshot_log.txtand perf report (1795321223-0.json):Side-by-side real-time wall-clock comparison (
Before: main @ 9e10f6f7vsAfter: this PR @ e4ad718b,HOS_HEADLESS=1,RX_VK_SHOT_MENU=1,RX_VK_SHOT_EVERY=3,RX_VK_PRECOMPILE=0).Starts
0.50 sbefore clicking Load on the Kokiri Forest save dialog; timer starts att = 0.00 son Load click. Live Dev FPS counter showsDraws left out: 2,731 -> 0,Program loads: 536 (204.0 ms) -> 0 (0.0 ms), and clean 3D transition (13.59 s -> 12.74 s,-0.85 s; the remaining~2.4 sstall is unrelated GPU ASTC terrain decoding).Read of
e4ad718bon9e10f6f7(merge-base9e10f6f7; current main isa2dc5385). The three fixes are coherent and the test is real. The headline numbers, though, are measured on a main two commits behind current main, and the probe's "non-compiling" property is the driver's promise, not the code's.1. The before/after is not current main.
9e10f6f7is the merge-base;a2dc5385=9e10f6f7+ #2174 + #1722. #2174 is "simulated-turf lists keep the game's size in areas without turf, so Hyrule Field no longer stalls 250 ms at a time on the way in" — the 3-zone traversal is Kokiri Forest, Hyrule Field and Market, so its entry into Hyrule Field is exactly the path #2174 fixes. The Before row's p9946.06 ms, 1% low21.71 fpsand32 frames ≥ 50 msare therefore measured with stalls that current main no longer has, and the+15.5%1% low /-6.17 msp99 are not the delta a player on current main gets. The body is honest ("Standalone onmain @ 9e10f6f7"), but the checklist ticks "on currentmain" and Still to test has no rebase/re-run. Rebase ontoa2dc5385and re-run the 3-zone tour; the save-load rows are not #2174's path and can stand as measured. This is the same scope problem #2194 was flagged for.2. The probe trusts the fail-on-compile flag.
graphics_pipeline's probe (vk_draw.cpp:3119-3141) callsbuild_graphics(..., &cold), which asks underVK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BITand accepts any non-null pipeline, countingmade_how1 (driver) or 2 (start). A driver that returns success from a miss (ignores the flag) makes the draw thread pay the full compile inside the probe: the 6 msFrameBudgetonly gates later probes in the frame (the new test's case 12 itself runs an 8 ms probe that overspends), and because the ask was made against the generation cache,create_cachedcounts that compile asfrom_driver— so "pipelines from the driver's cache 15" and "non-compiling" are only as good as the driver. No correctness break (the pipeline is valid); the safety net is the spec plusdev.vk13.pipelineCreationCacheControl, which many drivers advertise. If the farm's cold-cache runs on NVIDIA/RADV/Intel show a miss path that stalls (the body's own Risk), the!gpl_wanted()gate or a device-policy gate needs to be part of the merge, not a follow-up: the probe runs on every Vulkan 1.3 device.3. The program index.
programs_index(vk_programs.cpp:408-438) fills keyed maps and sets from the same validatedstart_note_refs(true)the precompile path uses, and nothing is indexed by a file-supplied count, so I found no lookup-bounds issue in the new call. Two notes: it is called beforeprograms_play_begin()and once per process (start()callspipeline_cache_playatvk_main.cpp:1896/1944), butprograms_indexappends — it never clearsindex_notes/index_signatures— so a secondpipeline_cache_playwould duplicate the index; a one-shot assert would keep that from being discovered later. And the new block runs withRX_VK_NO_PROGRAM_CACHE=1too (the kept-keys guard does not check that switch): it builds an index over a cache the run will not read and starts the load workers, for nothing. Add!env_on("RX_VK_NO_PROGRAM_CACHE")to the guard.4. Drop/threshold. The title's 95-100% matches the table (95.0% traversal, 100% save load), and the rest is stated plainly: the cold-cache run still drops 2,172 (-20.9%), the warm traversal leaves 339, and the save-load max frame time is ASTC-bound (+0.8%). The 6 ms cap is per frame but soft (see 2).
5. The default. No new switch; the probe runs on every Vulkan 1.3 device with
pipelineCreationCacheControl, i.e. the release default (precompile on) and GPL included, while the measurement is one AMD 860M iGPU with precompile off and threaded rendering off. The save-load/index half is better evidenced:RX_VK_LOADdefaults tocreate, so with precompile off (development builds' default) it applies to every dev run, and the log line shows it. The probe's GPL/NVIDIA/RADV/Intel runs in Still to test are the gate for the release default.6. The test. Real and broad: it cuts
graphics_pipeline,pipeline_cache_playand the two program-note functions from the sources and covers the pcache-init order, the index guard, the marker guard, probe hits from the start and driver caches, a miss falling through to the async job, the fault gate busy, modules dropped, nopipelineCreationCacheControl, a deferred cold entry probed once, and the budget overrun. It cannot exercise a lying driver (by construction), and it uses{cxx}for the compiler, so it runs where the builder's clang does.No approval, and no claim on it.
e4ad718b82eb68178622Thanks for the review @dazemc! I've rebased onto
main @ a2dc5385and addressed each point ineb681786:RX_VK_NO_PROGRAM_CACHEguard (gpu/vk/vk_draw.cpp): Moved!env_on("RX_VK_NO_PROGRAM_CACHE")into the outerifinpipeline_cache_play()(removing the redundant inner check), so disabling the program cache skipsstart_note_refs(), notes/state file opening, andprograms_index()cleanly.programs_index()(gpu/vk/vk_programs.cpp): Addedif (index_ready.load(std::memory_order_acquire)) return;at entry so a second call can never duplicateindex_notes,index_signatures, orindex_compute_variantsentries.tests/test_saveload_warm_cache.py): Added test case1bverifyingRX_VK_NO_PROGRAM_CACHE=1skips indexing/file opens while keepingpcache_init()+play_cache_begin(), plus a source check for theindex_readyone-shot guard inprograms_index(). Verified 19/19 targeted Vulkan/program/pipeline/preflight checks pass oneb681786(andtest_saveload_warm_cache.pyfails onmain @ a2dc5385).## Risks& rebase note): Clarified that6 msis a soft per-frame budget (a single driver probe that ignoresFAIL_ON_PIPELINE_COMPILE_REQUIREDoverspends that probe before halting further probes in the same frame), and explicitly committed to adding!gpl_wanted()or a policy gate in this PR before merge if Test Farm cold-cache runs on NVIDIA/RADV/Intel show a stall. KeptBefore: main @ 9e10f6f7in the table and noted why#2174did not affect ourKokiri Forest -> Hyrule Field -> Markettour (Hyrule Fieldmax_msonmain @ 9e10f6f7was30.94 / 71.01 / 72.49 ms,gt_50ms0 / 4 / 4, zero 250 ms turf stalls).eb68178622b6e5f76c4fTested in game: Linux (CachyOS, kernel 7.3), RTX 3090 24 GB, NVIDIA proprietary driver, Ryzen 9 7900X. Headless through the job queue (timing mode), Render resolution fixed at 67 %, uncapped (
HOS_FPS_MAX=1000), V-Sync off.Verdict: with
RX_VK_PRECOMPILE=0it does what it says (programs indexed at start, about 70 % fewer draws left out, a shorter save-load stall); at the default settings nothing changes on this PC, better or worse. This PR @e4ad718bagainstmain@9e10f6f7(its merge base), the same base and pack layer, interleaved main / PR.Routine:
kokiri-startsave, 12 s settle, teleport to Kokiri Forest, Market and Hyrule Field with a 10 s camera spin in each, back to Kokiri Forest, then three pause menus (PLUS, 4 s, PLUS, 5 s measured).RX_VK_PRECOMPILE=0, programs loaded at create (the PR's case), 2 runs each:program loads at create (play)longshot_load_start.txtwrittenThe tour's fps and p99 lean
main's way here; on these runsmainleaves out many more of the Market's draws, so it has less to draw while they build, which I'd read as the cause rather than a cost of the probe. Market still leaves out ~47k draws with the PR on a runtime whose caches had not seen these states with precompile off.Default settings (
RX_VK_PRECOMPILEunset), warm runtimes: main 3 runs, this PR 2 runs (its first run was cold and is left out): 0 draws left out on both, save-load worst frame 222–312 ms against 295–412 ms, tour p99 27.5–31.0 ms against 22.4–29.4 ms, after-menu p99 11.1–13.1 ms against 11.0–12.4 ms: within the spread.One thing to know for anyone repeating this: a runtime whose cold first run compiled more than 500 listed pipelines writes
cache/longshot_load_start.txtand then loads programs before the title (start) on every later run, which hides this PR's index entirely. My firstPRECOMPILE=0pair ran in that mode (the file came from default-settings runs, not fromPRECOMPILE=0), so I deleted it on both runtimes and ran again; the numbers above are from those runs. In that earlierstart-mode pair, one of this PR's two runs had a single 13.3 s frame during the save load, all of it the game's main thread blocked (main_blocked_ms), none of it the renderer; it did not happen in the other run or onmain, and I could not tie it to this change.No device lost, no crash in any run. Not tested here: AMD, Intel, GPL (
RX_VK_GPL=1), a cold driver cache.@Beanstalk
Beanstalk test farm · an earlier run: commit
b6e5f76(the newer results are in a comment below)Commit
b6e5f76· approved by HumanBean (reviewed) · dashboard⚠️ Note: Cache-controlled scenarios are Linux-only; Windows NVIDIA, AMD and Intel coverage and the precompilation-enabled path are omitted to keep the run short.
⚠️ Note: Driver-cold retains game caches, and a retained load-start marker can hide the precompile-off indexing path.
⚠️ Note: Single runs cannot establish the claimed dropped-draw reduction or statistically compare frame-time changes; no reliable dropped-draw log pattern was provided.
Done (started 16:21 UTC, last report 17:04 UTC). Comment
@Beanstalkto run it again.linux+radvWhy it failed
linux+radv:driver-cold-tourscreenshot.max_diff:limit 0.1linux+radv:driver-warm-tourscreenshot.max_diff:limit 0.1What was tested
What will be tested · AI plan (
gpt-6.1-terra)On Linux RADV, compare main and the PR through Kokiri Forest, Hyrule Field, and Market with cold and warm driver caches and precompilation disabled. The run takes about 30 minutes per tester and records transition hitches and load time. A crash, device loss, frame over 5 seconds, or substantial image difference fails the PR.
kokiri-start(switchesRX_VK_GPL=1,RX_VK_PRECOMPILE=0; each start with an empty driver shader cache, Linux only for now), then take the picture kokiri to compare with main, teleport to Hyrule Field, move the stick, take the picture field to compare with main, teleport to Market, take the picture market to compare with main; 1 run on each side.kokiri-start(switchesRX_VK_GPL=1,RX_VK_PRECOMPILE=0; each side's driver shader cache kept across its starts, filled first by an unmeasured start, Linux only for now), then take the picture kokiri to compare with main, teleport to Hyrule Field, move the stick, take the picture field to compare with main, teleport to Market, take the picture market to compare with main; 1 run on each side.Measurements on `linux+radv`, for the PR description
Verdict: fail on linux+radv (2 reports):
driver-cold-tour screenshot.max_diff;driver-warm-tour screenshot.max_difffailed.Hardware: 1: linux+amd+radv+dgpu
AMD Radeon RX 9070 (RADV GFX1201), 26.0.8AMD Ryzen 7 5800X 8-Core Processor, 32 GB RAM; 2: linux+amd+radv+dgpuAMD Radeon RX 6600 (RADV NAVI23), 26.2.6AMD Ryzen 5 5600X 6-Core Processor, 64 GB RAMScene: driver-cold-tour, from the repository's save kokiri-start (RX_VK_GPL=1, RX_VK_PRECOMPILE=0); driver-warm-tour, from the repository's save kokiri-start (RX_VK_GPL=1, RX_VK_PRECOMPILE=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); driver-cold-tour: 1 game start a side; driver-warm-tour: 1 game start a side; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)a2dc538b6e5f76Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
The testers' hardware
linux+radvAMD Radeon RX 9070 (RADV GFX1201), 26.0.8AMD Ryzen 7 5800X 8-Core Processor, 32 GB RAMlinux+radvAMD Radeon RX 6600 (RADV NAVI23), 26.2.6AMD Ryzen 5 5600X 6-Core Processor, 64 GB RAMRecommendation: Request changes. The index and play-cache half fixes real dropped draws in runs with precompile off. The cache probe, though, is on for every Vulkan 1.3 device with no way to turn it off. It runs on the render thread, its cost is not logged, and it was measured only on one AMD iGPU with precompile off. On an RTX 3090 with precompile off the tour lost fps and p99 with the PR, and nothing yet shows whether the probe caused that.
For a player or developer: with
RX_VK_PRECOMPILE=0(the default in development builds), a warm save load and the first visits to an area leave out far fewer draws, because the kept programs are indexed at start and play's pipeline generations start. With the release default (precompile on), nothing measured changes. The probe adds a driver call on the render thread for every pipeline first seen in play, on every GPU.Does it help: Yes for draws left out with precompile off; Unproven for frame time and for players.
9e10f6f7:mainrun.pr statuswarns that the numbers are from9e10f6f7while the PR is ona2dc5385.Other systems:
ask_start_first).create_cached's own comment says a play ask made that way grows pcache in memory, because NVIDIA copies in what it takes from its own disk cache, and the result is counted as "from the start's cache". Not measured.RX_VK_GPLis off by default (gpl_wantedneeds it; switches.def row "off (no stage libraries)"), not on as Risks says. With it on, the probe runs before the link and adds one miss's cost ahead of it.PcacheUsetakespcache_fetch_mushared, so a probe on the render thread can wait behind a cache fetch, where before only required draws' quick asks could.Switches: none added. The probe has no switch, and
RX_VK_QUICK_MS=0does not turn it off. That is the problem in Blocking 1.pr status's hints aboutLONGSHOT_PREPARE_ONLY,RX_VK_NO_STATE_LISTandRX_VK_NO_PROGRAM_CACHEare false positives: those switches already exist and are only read here.Reviewed: head
b6e5f76cagainsta2dc5385, the merge base and currentmain. HumanBean testede4ad718b;git range-diffshows the rebase is identical, plus the third commit (theRX_VK_NO_PROGRAM_CACHEguard and theprograms_indexone-shot).graphics_pipeline,build_graphics,create_cached,quick_pipeline,pcache_init,play_cache_begin,pipeline_cache_play,precompile_at_create's opening, the draw's caller,programs_index,load_wait_note,programs_frames_note,load_at_create,quick_pipe.h,vk_pipelines.h, andprogram_cache_kept_keysandprogram_cache_complete_graphicsinvk_progcache.cpp.Fixed in this review: nothing.
Checked and fine:
probe_budgetisthread_local, andgraphics_pipelineruns only on the render thread (pipelinesis the replay's map and has no lock). The budget is not a shared counter, and there is no race.VK_PIPELINE_COMPILE_REQUIRED,create_cachedsets*plto null andbuild_graphicsreturns null with*coldset. No handle leaks, the GPL link is still tried, and the async job is still pushed.begin(key, false), so a busy gate returns at once andendis called after a build. Intel's gate is non-blocking forcompiles_nothingasks.graphics_pipeline(cp->failed), and dropped modules are guarded.pcache_initinpipeline_cache_play: it runs on the start thread before any draw. Onmainwith precompile off,play_cache_beginreturned early on a nullpcache, so the reorder is right.programs_index:precompile_runor the new block (exclusive byprecompile_wanted);index_readyis stored with release after the maps are filled, andload_at_createreads it with acquire;programs_play_begin, as on the precompile path;longshot_load_start.txtand flip later default starts.RX_VK_NO_PROGRAM_CACHEnow skips the whole block.Blocking (to change before merge)
gpu/vk/vk_draw.cpp:3124). It is on for every Vulkan 1.3 device, on one AMD iGPU's evidence, and the only way back is a revert.quick_pipeline's ask step a second time, with its own 6 ms constant. That ask exists underRX_VK_QUICK_MS, whose default (required, #1643) was chosen to leave skippable draws alone. The probe overrides that choice, andRX_VK_QUICK_MS=0does not stop it.switches.def, with a default chosen per platform from measurements.gpu/vk/vk_draw.cpp:3134).ask_start_firsthere (vk_draw.cpp:3132). Without it, thecoldflag already gives the non-compiling order (the play generation, then pcache), and NVIDIA's pcache doesn't grow in play.RX_VK_PRECOMPILE=0. Precompile is on in release builds, and at that default the 3090 shows nothing.RX_VK_GPL=1a default; it is off by default.9e10f6f7(pr statuswarns).a2dc5385, or say why the numbers hold, and scope the title and verdict to precompile-off runs plus whatever the probe proves.Suggestions
pcache_initorder, the index at create and the marker guards are a clear fix for precompile-off runs and could merge alone. The probe can follow once it has a switch and numbers.vk_draw.cpp:12815). When a default run has leftlongshot_load_start.txt,programs_load_at_create()is false and the index is skipped, which is what HumanBean hit. But "start" without precompile loads nothing before the title. Consider loading at create whenever precompile is off (inprograms_load_decide), so the fix isn't hidden.program_cache_kept_keys()builds the whole set (47,867 keys in nwgat's run) only to test.empty(), andprograms_indexbuilds it again. A count, or an any-kept call, would do.precompile_at_create's; one helper for both would keep them from drifting.quick_pipelineasks the same caches again in the same draw. Skip its ask when the probe has just missed.Questions
Testing:
Overlaps and merge order:
programs_frames_note, the same marker logic. Settle which goes first; the second rebases over the other's guard.programs_index,load_wait_noteandprograms_frames_note.pipeline_cache_play's module release.graphics_pipeline.quick_pipeline's switches live; Blocking 1 would put the probe under that policy.@ -3119,0 +3121,4 @@// (longshot) Bounded non-compiling cache probe before queuing an async build: a warm pipeline or driver cache answers in// sub-millisecond time without invoking the shader compiler, preventing warm-cache draws from being skipped on first sight,// while the per-frame cap keeps cold-cache probe bursts from stalling the recording thread.if (!probed_cold && dev.vk13.pipelineCreationCacheControl && !program_modules_dropped(p)) {On for every Vulkan 1.3 device with no switch and no way back; RX_VK_QUICK_MS=0 doesn't stop it. It repeats quick_pipeline's ask step with its own 6 ms constant, overriding the 'required' default #1643 chose for skippable draws. Put it under the quick policy (an ask-only budget for skippable draws) or give it its own switches.def row, with a default chosen from measurements.
@ -3119,0 +3129,4 @@const auto t0 = std::chrono::steady_clock::now();use_counters.made_how = 0;bool cold = false;const quick_pipe::Raise asking(ask_start_first);ask_start_first asks pcache first. create_cached's comment says a play ask in that order grows pcache in memory on NVIDIA and is counted as from the start's cache. Without the Raise, the cold flag already gives the non-compiling order: the play generation, then pcache.
@ -3119,0 +3131,4 @@bool cold = false;const quick_pipe::Raise asking(ask_start_first);const VkPipeline pl = build_graphics(p, s, at, topo, -1, &cold);probe_budget.spend(std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - t0).count());The budget is checked only before a probe, so one slow probe (a driver that compiles anyway, or a cache lock held by a worker) overruns it without bound, on the render thread. Please count probes, hits, total ms and the worst ms in the census line, and A/B probe off against probe on with the index on. The RTX 3090 tour with precompile off lost 132-143 to 111-123 fps, and nothing yet separates the probe's cost from the extra draws.
@ -12783,0 +12812,4 @@// for RX_VK_LOAD=create (zero compilation) so create calls load kept programs and noted pipelines from caches ahead of// first use instead of discarding them before the index is ready.if (!precompile_wanted() && !env_on("LONGSHOT_PREPARE_ONLY") && !env_on("RX_VK_NO_PROGRAM_CACHE") &&programs_load_at_create() && !program_cache_kept_keys().empty()) {program_cache_kept_keys() builds the whole set (47,867 keys in one run) only to test .empty(), and programs_index builds it again. Also: when a default run has left longshot_load_start.txt, programs_load_at_create() is false and this whole block is skipped, though 'start' without precompile loads nothing before the title. Consider loading at create whenever precompile is off.
Ignore comment, bad bot
Beanstalk test farm
Commit
9d2f7b5· approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.perf(vk): cut dropped draws 95-100% and lift 1% lows +15.5% on Vulkan 1.3 GPUs via driver-cache probe and program indexingto perf(vk): with the shader preparation off, kept programs are indexed at start and load at create: ~70 % fewer draws left out (dev builds)Pushed
9d2f7b54on top of your three commits (a fast-forward, your history kept; the old head wasb6e5f76c), and updated the title and the description to match. @Jer9, what changed and why:1. The cache probe is out of this PR (
graphics_pipeline, theprobed_coldflag and the probe block; the fixture's cases 5–12). From testing on an RTX 3090 (Linux, NVIDIA):So it doesn't help players and only somewhat helps dev runs. It's not lost: I'm sending you the probe as a patch that applies on top of
9d2f7b54, so it can come back as a PR of its own with its probes, hits and ms logged and a probe on/off A/B (in areas the notes haven't seen, and withRX_VK_PRECOMPILE=0), on NVIDIA, RADV and Windows AMD/Intel.2. A leftover
longshot_load_start.txtno longer hides the index.load_default::choosetakes a newprepared(default true): withRX_VK_PRECOMPILE=0the marker is left aside and programs load at create. Start only loads programs inside the preparation, so with it off a marker meant nothing loaded before the title and no index: every program read at its first draw, which I hit in testing (one cold default-settings run wrote the marker, and every laterRX_VK_PRECOMPILE=0run skipped your index).tests/load_default_test.cppchecks it; the switch and the compressed cache still decide as before.3. The description now says who it helps (the preparation off: development builds and testers; players aren't affected), drops the "Vulkan 1.3 GPUs" and "players who turn precompilation off" claims (there's no player setting for it) and the
RX_VK_GPL=1default, marks the measurements as taken with the probe in, and adds the 3090 numbers.The changed checks haven't run at
9d2f7b54yet (CI will), and9d2f7b54hasn't been in the game: built for Linux only. Still open before merge: CI, one run in the game with and without a leftover marker, and the farm's RADV picture failure onb6e5f76c(pictures 0.82–1.0 frommain's; my guess ismain's are the ones missing geometry, but someone has to look).My request for changes was about the probe and the description, so I've dismissed it.
Addressed in
9d2f7b54: the cache probe split out of this PR, the marker left aside without the preparation, the description rewritten (see the comment above).