d3d12: say when the driver's pipeline cache stops keeping new pipelines (RT-PIPELINE-CACHE-GROWTH-STALL) #2062
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2062
Loading…
Reference in a new issue
No description provided.
Delete branch "rt-pipeline-cache-growth-stall"
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?
Pull request successfully merged and closed
RT-PIPELINE-CACHE-GROWTH-STALL, claimed in #1608 after the finding just above it.
What
The runtime says once, in the log, when the title's pipeline builds keep compiling but the driver's
VkPipelineCachehas stopped growing (the numbers below show the format, not a run):pipeline_profile::DriverCall(it already wraps both titlevkCreate*Pipelinescalls) always times the call and counts successful builds of at least 200 ms incompiled_builds(). A cache hit takes a few milliseconds, also while the title loads every core. Printing still needsLEONIDA_PSO_PROFILE=1.pipeline_cache_store::GrowthWatch(pure, no Vulkan) compares two cache sizes with the builds that compiled between them: 16 or more compiled and less than 64 KiB of growth reports once.LEONIDA_PIPELINE_CACHE_BYTES. The size query is the one the save already makes.docs/d3d12_vulkan.mdrecords the measurements under "Pipeline caches".Why
A driver can stop adding to a large cache without an error, and then a session file stops helping without anything saying so. Measured on an RTX 5060 Ti, NVIDIA 610.88, Windows 11 23H2:
vk_pipeline_checknamedgta6rt.exe)__GL_SHADER_DISK_CACHE=0In the game (main fe1553456 + #1886): seeded with the 1.23 GB file, 68 of the ~110 builds over 200 ms in one run were over 200 ms again in the next; started with no seed, 5 of 164 were. An older cache of mostly main-set graphics pipelines stopped growing at 4.9 GB, so there is no fixed size to test against, hence a growth check instead of a size limit. #1886 measured a 1,285 MB session on an RTX 5080, still growing.
Tested
scripts/build_runtime.ps1.pipeline_cache_store_testgainstest_growth(no Vulkan, no GPU): no reference at creation, a growing cache at any size, too few builds, report once, counting from the previous save, a count that went backwards.ctest -R "pipeline_cache|compile_teardown|pipeline_workers|pso_profile|d3d12_pipeline": 10/10 pass.ctest -j 8: everything passes exceptroot_sig,d3d12_state_sweepandd3d12_pso_validation, which fail the same way on main fe1553456 without this change on this machine.scripts/check_no_game_data.pyon the changed files: clean.Related: #1886 (raises the save limit, so sessions reach this size), #1756 (checkpoint scheduling; both touch
save_session_pipeline_cache, the overlap is one added line).Verified on the PR branch: python3 -m unittest discover -s tests -p 'test_docs_*.py' -> 47 tests OK; the new GrowthWatch logic is backed by runtime/src/pipeline_cache_store.h:78 and runtime/src/pipeline_profile.h:46, and the standalone C++ unit test compiles and passes (g++ -std=c++20 runtime/test/pipeline_cache_store_test.cpp -> exit 0). The new docs describe the watch condition and remedy consistently with the source. Caveat: the NVIDIA 610.88 growth-stall measurements in the docs are GPU-specific observations I cannot reproduce on this host; I verified their consistency with the code, not the numbers. Advisory: branch carries 7 older commits not on main.
Review at
869319b55(code reading plus a native run on a GTX 1050 Ti, see the end). The check itself reads right:GrowthWatchreports once, re-bases at every observation, and treats a count that went backwards as "no stall". One thing about scope, and one data point.pipeline_cache_handleis aDeviceStatemember created in its owncall_once, so two D3D12 devices have twoVkPipelineCaches (the tests make two, e.g.d3d12_rebound_second_device; a title can too).pipeline_cache_growth()andpipeline_profile::compiled_builds()are single statics. With two live devices, device A's creationobserve()s A's size, then device B's save compares B's size against it and against builds that both devices compiled, which can report a stall that is not one (B's cache is smaller than A's) or hide one. Keeping aGrowthWatch(and the compiled count at the last observation) perDeviceState, or keyed by theVkPipelineCachehandle, would make it per cache. With one device, which is the retail case so far, it is fine as is.LEONIDA_PSO_PROFILE=1on a Xeon E5-2670 v3 (2.3 GHz) + GTX 1050 Ti, the pipeline tests below made 1,447 title builds: 1,443 succeeded with median 0.7 ms, p90 2.3 ms, p99 15.6 ms; 5 took 201-206 ms (allresult=0), the rest under 16 ms. So cache-hit-sized builds stay far below 200 ms here too, while a real compile of a small test shader sits right at the line on this CPU (on a faster one it would fall under it and not count). That direction only makes the watch report less, so it is safe; it may be worth saying in the comment thatcompiled_builds()undercounts on fast CPUs rather than counting every compile.Run: this head merged onto main
8564bb48b(clean), GTX 1050 Ti, Windows 10 Pro 19045, NVIDIA 582.66, MSVC RelWithDebInfo.pipeline_cache_store(withtest_growth),pipeline_cache_file,pipeline_cache_seed,pipeline_cache_snapshot,pipeline_workers,d3d12_pipeline_library,d3d12_pipeline_library_host,d3d12_pipeline_workers,d3d12_pipeline_workers_eager,d3d12_compile_teardown,d3d12_rebound_second_device: 11/11, 3 runs each, plain and withLEONIDA_VK_VALIDATION=1, and again withLEONIDA_PSO_PROFILE=1. No validation messages, and no growth-stall line in any of them (none reaches 16 compiled builds).AI-assisted (Claude Code).
Hi @thegalaxydev, thanks for this pull request. It currently conflicts with
main(conflicting file(s):docs/d3d12_vulkan.md,runtime/shims/d3d12_vulkan_device.cpp), so it carries theneeds rebaselabel. CONTRIBUTING.md asks authors to rebase their branch onmain; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.AI-assisted (Claude Code, Claude Opus 5.5).
Carried as #2737 because of the conflict with main after #2566; @thegalaxydev, if you come back, say so and the carry is dropped.