Repository navigation
d3d12: a pipeline cache for the offline cache's misses, written while the game runs (RT-HEAVY-PIPELINE-CACHE) - #1914
Conversation
… the game runs (RT-HEAVY-PIPELINE-CACHE) pipeline_cache.session.bin can't keep what a crashed run compiled: it is written at device teardown only, and a cache seeded from the multi-GiB corpus returns the whole corpus, over its write limit. So the slow builds the corpus misses (the pipeline library's compute programs, 3 to 7 s each on an RTX 5070 Ti) are compiled again on every boot. Each graphics and compute build now first asks the corpus cache with VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT. A miss is built against a second cache, seeded from pipeline_cache.heavy.bin next to pipeline_cache.bin, so that cache holds only the misses. A build of at least LEONIDA_HEAVY_PIPELINE_CACHE_MS (500 by default) schedules a write. A thread of its own writes the cache 3 s after the newest slow build and no later than 20 s after the first unwritten one, through the session cache's staging file and rename. At teardown it writes what is left. 0 turns it off, and with it pipelineCreationCacheControl unless LEONIDA_PIPELINE_COMPILE=cache-only asks for it. Measured with vk_pipeline_check on the RTX 5070 Ti (617.42): a cache-only create of four library compute programs the corpus lacks returns VK_PIPELINE_COMPILE_REQUIRED in under 1 ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, counted, not timed; teardown keeps fast builds too GetTickCount64 moves in 10-16 ms steps, so a slow build noted during a write in the write's own tick was taken as written. The schedule now counts notes. And without an offline seed every build goes to the heavy cache: fast ones never schedule a write, so teardown writes the cache whenever any build went into it, which is what pipeline_cache.session.bin used to keep. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Data point for this PR and for thegalaxydev's RT-PIPELINE-CACHE-GROWTH-STALL. With a complete offline cache, the session cache can't be saved at all under the current limit. Counts only.
The session snapshot is the whole driver cache, seed included, so once the seed alone is over the limit, every session save is refused. A separate cache for the builds the seed misses, as this PR does, avoids that. So does a limit that is measured against what the run added rather than against the total. AI-assisted (Claude Code). |
lixonik
left a comment
There was a problem hiding this comment.
Independent CPU check at e4c413a3a: heavy_pipeline_cache_test passes. A failure-injection harness using the current writer and teardown methods exposed one remaining issue with saving during a run. No GPU or game files.
AI-assisted.
| save_heavy_pipeline_cache(context->vk, info.device, heavy_cache_handle, heavy_compiles.load(), | ||
| heavy_hits.load()); | ||
| lock.lock(); | ||
| heavy_schedule.written(generation, now); |
There was a problem hiding this comment.
[P2] Retry unsuccessful periodic saves while the device is live
The writer ignores the save result and marks the captured generation written. If staging or publication fails briefly and no further slow compile occurs, the writer goes idle with the cache still unsaved. With the exact methods at this head, a mocked first save failure followed by 30 s on the clock produced one attempt while live and a second only at normal teardown. A crash in that interval still loses the cache. Keep the generation dirty on a failed save and retry after a bounded delay so persistent failures do not spin.
|
One difference to the session saver, from the code at this head ( Also a measurement about size, RTX 5060 Ti 16 GB, NVIDIA 621.01: the file was 1.09 GB, and with about 640 more programs 1.60 GB. The writes are whole, so each of them was that size, one every 10 to 20 s while compiles ran ( AI-assisted (Claude Code, Claude Opus 5.5). |
…LETE snapshot Review of RT-HEAVY-PIPELINE-CACHE: - The writer thread marked a generation written even when the save failed, so the cache stayed unsaved until teardown. A failed save now keeps the cache dirty and is retried after a bounded backoff (5 s, doubling, capped at 2 min), so a write that keeps failing does not spin. WriteSchedule::failed() holds that decision and heavy_pipeline_cache_test checks it. - save_heavy_pipeline_cache accepted VK_INCOMPLETE and published the truncated blob over a complete file. It now requires VK_SUCCESS, like the session cache, and keeps the previous file; the next try queries a fresh size. Changes made by Claude Code (AI-assisted). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JPqXc6svM4pbBagTsVEYA3
|
These changes were made by Claude Code (AI-assisted) in aab7653, after the review:
Tested: Generated by Claude Code |
|
Real boots with this PR (earlier head, before aab7653) on an RTX 4070 Laptop 8 GB, NVIDIA 621.40, main + #2077 + the mesh-indirect branch: |
main's per-pipeline compute journal (pipeline_cache_journal.h) now persists every compute build and survives a crash, so the compute build takes main's build_compute_pipeline and the heavy cache keeps graphics pipelines only. CMake keeps both test sets; docs and the create_pipeline comment say so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged main (c50ed94) in a42bffd; the PR had a conflict with it. main now has its own crash-safe store for compute pipelines: the per-pipeline journal (
The docs section and the Tested (Windows 11, MSVC RelWithDebInfo, RTX 5070 Ti, NVIDIA 617.42), including the
AI-assisted (Claude Code, Claude Opus 5.5). |
Tested on main a73a57e: Wine suite (clang-cl + xwin, RDNA2 iGPU, RADV) 412 pass / 22 fail / 39 skip on main and on main + #1886, 0 changes; Linux portable ctest 108/108; the new over_save_limit cases fail on main and pass here. Review points addressed in 66e96cc. Windows CI cancelled; linux-gpu-tools CI failed at Build (log not available yet; the same job also fails on #1914, and it builds locally). AI-assisted (Claude Code, Claude Opus 5.5 review, Claude Fable 5.2).
|
Thank you, @kawaii-shakal. This went into AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2) |
Claimed in the coordination issue as RT-HEAVY-PIPELINE-CACHE: #1608 (comment)
Problem
The builds the offline
pipeline_cache.binmisses are compiled again on every boot. On an RTX 5070 Ti these are the pipeline library's compute programs, 3 to 7 s each and about 40 per boot before the world starts, and they are what keeps the render thread waiting at the title's hang watchdog.pipeline_cache.session.bincan't keep them for two reasons:LEONIDA_STARTUP_CACHE_CHECKPOINTShas the same problem.Change
VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT(DeviceState::create_pipeline).pipeline_cache.heavy.bin, next topipeline_cache.bin. That cache holds only the corpus's misses, so it stays small.LEONIDA_HEAVY_PIPELINE_CACHE_MS(500 by default) marks the cache dirty. A thread of its own writes it 3 s after the newest slow build and no later than 20 s after the first unwritten one, through the existing staging file and rename (CacheStagingFile), so the file on disk is always complete. A crash loses at most the last 20 s of slow builds. At teardown the thread stops and writes what is left.LEONIDA_HEAVY_PIPELINE_CACHE_MS=0turns it off, and with itpipelineCreationCacheControlunlessLEONIDA_PIPELINE_COMPILE=cache-onlyasks for it. A cache-only create (cache-only) is left exactly as it was.runtime/src/heavy_pipeline_cache.h, withheavy_pipeline_cache_test.vk_test_device.htakes the heavy path whenLEONIDA_HEAVY_PIPELINE_CACHE_MSis set, andd3d12_mesh_heavy_cacheruns the mesh test's draws through it.docs/d3d12_vulkan.mddescribes it next to the session cache.Measured (Windows 11 Pro 26300, RTX 5070 Ti, NVIDIA 617.42, VS 2026 RelWithDebInfo)
vk_pipeline_checkand a local probe that adds the flag (not part of this PR), against an empty cache. Four library compute programs the corpus lacks returnVK_PIPELINE_COMPILE_REQUIREDin under 1 ms, so the heavy path is taken for them. The mesh test's small shaders come backVK_SUCCESSfrom a cache-only create even into an empty cache, because the driver's own shader cache already holds them. That is why the CTest case checks correctness, not the file.heavy_pipeline_cache,pipeline_cache_store,pipeline_cache_file,d3d12_msaa_draw,d3d12_meshandd3d12_mesh_heavy_cacheall pass, 6 of 6.Not done here
🤖 Generated with Claude Code