Repository navigation
d3d12: the Vulkan pipeline cache is also saved while the session runs (LEONIDA_PIPELINE_CACHE_SAVE_SECONDS) - #9467
thedarkcr0w wants to merge 5 commits into
Conversation
…the next session from it The device destroyed its VkPipelineCache without keeping the pipelines the session created. It now saves the cache to pipeline_cache.user.bin beside the executable (or LEONIDA_PIPELINE_CACHE) through a staging file and a rename, loads it first when its header matches the device and it is not older than the build's pipeline_cache.bin, never writes the seed, and never fails the run on an I/O error. Pipeline creation reports VK_EXT_pipeline_creation_feedback, logged at teardown and read by d3d12_pipeline_cache_persist_test.
…under 1 GiB; LEONIDA_PIPELINE_CACHE=off for tests A session whose pipelines all came from the cache writes nothing, and a cache over LEONIDA_PIPELINE_CACHE_MAX_MB (default 1024) is skipped with one log line instead of writing the full-corpus 3.8 GB at exit. LEONIDA_PIPELINE_CACHE=off loads and saves no session file; CTest sets it for every test but d3d12_pipeline_cache_persist.
…red between sessions A session file is the driver's data behind a frame with its byte count and hash, read with ReadFile (a cut or changed file never reaches the driver). Seed and session paths are resolved once at device creation and compared by file identity at the save; a seed rebuilt during the session stops the save; pipelines another session saved are merged in first; the replacement waits for a reader holding the file; names are logged in UTF-8 so nothing throws at teardown; a creation without valid feedback counts as a miss. Tests cover each, and LEONIDA_PIPELINE_CACHE=off is checked in the working directory too.
…Leonida into pipeline-cache-periodic-save
…DA_PIPELINE_CACHE_SAVE_SECONDS), for a title that never tears its device down
|
Review of
This has been measured on the retail boot. #9438's description, finding 7: "Saving from the creating thread trips the title's hang watchdog, because a 1.5 GB save takes ~2 s. Saving periodically from a separate thread works." The cache reaches that size in exactly the cold-boot case this PR targets: about 2,700 library compute pipelines, plus tens of thousands of graphics PSOs. Suggestion: keep the policy (interval, the missed-since-last-save check, A test that would catch the regression: time one AI-assisted (Claude Code). No game files. |
|
Tested
The new periodic test:
The #7396 persistence test, RX 7900 XTX, so the driver's data really is reused:
I didn't measure the threading concern above. These caches are tens of KB and each save takes about 1 ms here, so the test sizes can't show the 2.7–13.9 s saves from the description. No game files. AI-assisted (Claude Code). |
|
Tested 291b10c on NVIDIA GeForce RTX 4080, driver 617.42, Windows 11 Pro (26300), MSVC 14.41, Vulkan SDK 1.4.363.0: pass.
AI-assisted (Claude Code) test run. |
|
Independent native Windows/Vulkan check of
Synthetic compute pipelines and Vulkan validation off. AI-assisted. |
|
Tested 291b10c merged onto main 5d74c27 (clean merge) on NVIDIA GeForce RTX 4070, driver 621.24, native Windows 11 Pro 26300, MSVC 14.44.35207, Ninja RelWithDebInfo: pass.
No game data used. AI-assisted (Claude Code). |
|
Tested For this change. Setup. Built with MSVC 14.52 (Visual Studio 18), Windows SDK 10.0.26100, Vulkan SDK 1.4.363.1, Ninja RelWithDebInfo on Windows Server 2025 (no Vulkan driver there), then the same binaries run through
Against This was a combined run: the six PRs were built into one tree, so it is weaker evidence than a run of this PR alone, and there is no per-PR negative control. A regression would have shown as a difference from |
|
Tested
AI-assisted (Claude Code). |
…rojectLeonida#7896, remaining PRs (ProjectLeonida#9670 ProjectLeonida#9419 ProjectLeonida#9549 ProjectLeonida#9499 ProjectLeonida#9229 ProjectLeonida#9189 ProjectLeonida#7685 ProjectLeonida#9467) and lazy PSO Tree is the integrated boot-path state; history keeps the fork's earlier merges.
Claimed in #9401: #9401 (comment)
Depends on: #7396. Review only the last commit,
291b10c9a. Below it is #7396, merged cleanly.What and why
#7396 saves the runtime's
VkPipelineCacheat device teardown. A retail title never gets there: it is killed, or leaves throughTerminateProcess, so nothing is saved exactly where it matters. On a retail 1.0.2.1 boot the title creates its 2,693 pipeline-library compute pipelines one after another while loading. Cold, that is about one every 0.85 s on an RTX 4090 (700 done at 570 s), and every launch started from nothing.Design
DeviceState::save_pipeline_cache_if_due()runs d3d12: persist the runtime's Vulkan pipeline cache across launches (framed and checked file, merged across sessions, never the build seed; 26x faster PSO creation on the second launch) #7396's own save if both hold:LEONIDA_PIPELINE_CACHE_SAVE_SECONDShave passed (default 120;0= teardown only, as before);try_lock); the others keep creating, and the driver synchronizes the cache.LEONIDA_PIPELINE_CACHE=off.docs/d3d12_vulkan.mdnames the switch.Tested
Windows 11, MSVC 2022 Build Tools RelWithDebInfo (Vulkan headers fetched), NVIDIA GeForce RTX 4090 (driver 32.0.16.1062).
d3d12_pipeline_cache_persist_periodic, in its own process with a 1 s interval:save_pipeline_cache_if_due()calls removed, the periodic test fails (no session file while the device is alive); restored, it passes.d3d12_pipeline_cache_persistandpipeline_cache_store_teststill pass.scripts/check_no_game_data.pyon the changed files: clean.tests/test_docs_repeated_lines.pyfails onmaintoo (docs/boot.md), not from this change.Caveat
A save is synchronous on the creating thread: 2.7 to 13.9 s for 310 to 380 MB here. A title that measures its own frame time during loading sees one long creation every interval. Moving the write to a background thread is a possible follow-up; it needs care with #7396's merge-across-sessions step.
AI-assisted (Claude Code).