Skip to content

d3d12: say when the driver's pipeline cache stops keeping new pipelines (RT-PIPELINE-CACHE-GROWTH-STALL) - #2062

Open
thegalaxydev wants to merge 2 commits into
ProjectLeonida:mainfrom
thegalaxydev:rt-pipeline-cache-growth-stall
Open

thegalaxydev wants to merge 2 commits into
ProjectLeonida:mainfrom
thegalaxydev:rt-pipeline-cache-growth-stall

Conversation

@thegalaxydev

@thegalaxydev thegalaxydev commented Nov 25, 2026 •

Copy link
Copy Markdown

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 VkPipelineCache has stopped growing (the numbers below show the format, not a run):

[rt] d3d12: the Vulkan pipeline cache grew 0 bytes (to 1346482377) over 23 pipeline builds that compiled: the driver no longer keeps new pipelines, so the next run compiles them again. A large pipeline_cache.bin or pipeline_cache.session.bin can cause it (docs/d3d12_vulkan.md, pipeline caches)
  • pipeline_profile::DriverCall (it already wraps both title vkCreate*Pipelines calls) always times the call and counts successful builds of at least 200 ms in compiled_builds(). A cache hit takes a few milliseconds, also while the title loads every core. Printing still needs LEONIDA_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.
  • The device takes the size when it creates the cache (after the seed and the session are loaded) and at every session save, checkpoint or teardown, including a save skipped for being over LEONIDA_PIPELINE_CACHE_BYTES. The size query is the one the save already makes.
  • docs/d3d12_vulkan.md records 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:

cache before one ~2 s compute compile (vk_pipeline_check named gta6rt.exe) file afterwards next process
empty +~210 KiB 0.01 s from the file, also with __GL_SHADER_DISK_CACHE=0
1.23 GB (library and main-set compute) same size to the byte hit only through the driver's own disk cache
1.35 GB (the above plus what the game added) same size to the byte compiled again

In the game (main fe15534 + #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

  • RTX 5060 Ti 16 GB, NVIDIA 610.88, Windows 11 23H2, MSVC via scripts/build_runtime.ps1.
  • pipeline_cache_store_test gains test_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.
  • Full ctest -j 8: everything passes except root_sig, d3d12_state_sweep and d3d12_pso_validation, which fail the same way on main fe15534 without this change on this machine.
  • scripts/check_no_game_data.py on 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).

…es (RT-PIPELINE-CACHE-GROWTH-STALL)

A driver can stop adding to a large VkPipelineCache with no error. On NVIDIA 610.88 a 1.23 GB or 1.35 GB cache
came back the same size to the byte after a 2 s compile, so the next run compiles the same pipelines again and
nothing says why. The runtime now takes the cache's size at creation and at each session save, counts the title's
pipeline builds that took at least 200 ms, and logs once when 16 or more compiled while the cache grew less than
64 KiB. pipeline_cache_store_test covers the decision; docs/d3d12_vulkan.md records the measurements.

@MSedgeMC MSedgeMC left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@qhukz13

qhukz13 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Review at 869319b55 (code reading plus a native run on a GTX 1050 Ti, see the end). The check itself reads right: GrowthWatch reports once, re-bases at every observation, and treats a count that went backwards as "no stall". One thing about scope, and one data point.

  • The watch and the build count are process-wide, the cache is per device. pipeline_cache_handle is a DeviceState member created in its own call_once, so two D3D12 devices have two VkPipelineCaches (the tests make two, e.g. d3d12_rebound_second_device; a title can too). pipeline_cache_growth() and pipeline_profile::compiled_builds() are single statics. With two live devices, device A's creation observe()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 a GrowthWatch (and the compiled count at the last observation) per DeviceState, or keyed by the VkPipelineCache handle, would make it per cache. With one device, which is the retail case so far, it is fine as is.
  • The 200 ms line on a slower CPU. With LEONIDA_PSO_PROFILE=1 on 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 (all result=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 that compiled_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 (with test_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 with LEONIDA_VK_VALIDATION=1, and again with LEONIDA_PSO_PROFILE=1. No validation messages, and no growth-stall line in any of them (none reaches 16 compiled builds).

AI-assisted (Claude Code).

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants