d3d12: the session pipeline cache is saved up to 4 GiB, checkpoints included (RT-SESSION-CACHE-LIMIT) #1886
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!1886
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1886"
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?
@DadaCap on GitHub · 2026-11-25 14:27 UTC · original
DadaCap:session-cache-limit→main· +38 −15 · 4 files · 3 commits · merged 2026-11-26 12:52 UTCRT-SESSION-CACHE-LIMIT, claimed and found in #1608.
What
The session pipeline cache's default save limit (
LEONIDA_PIPELINE_CACHE_BYTES) goes from 256 MiB to 4 GiB, and a checkpoint uses the same limit instead of its own 512 MiB.Why
Past the limit nothing is written, so every later build is lost and the next run repeats it. The world phase exceeds it on NVIDIA:
main+ #1756 + #1849 + #1827,LEONIDA_DEVICE_TYPE=6, the two later runs withLEONIDA_SERIAL_BIG_COMPILES=0pipeline cache is 350948938 bytes, over the 268435456-byte write limitThe effect on the next run: 353 of 362 builds that were slow (2 s or more) in one run came from the cache in the following one (5 rebuilt, probably in flight when the run was stopped; 4 not reached when I counted). The later run passed in about 80 s what had taken the earlier one its whole 30 minutes. Those two runs got to the fifth world frame, a point my runs never reached before.
Cost, measured on the same machine: loading 867 MB takes 0.35 s (
driver_us), a checkpoint 0.35 s at 681 MB and 0.50 s at 1,102 MB, on the compile worker. Whether that disturbs a frame is not measured yet.What the limit is for: the comment says it keeps a cache seeded from a multi-GB offline corpus from being rewritten at every exit. With 4 GiB a corpus file below that is rewritten, at teardown and with
LEONIDA_STARTUP_CACHE_CHECKPOINTS=1at each checkpoint. If that is a concern, a lower default (above about 1.5 GB) plus an exemption for a seeded cache would be an alternative; tell me and I'll change it.Tests
pipeline_cache_store,d3d12_compile_teardown,d3d12_pipeline_workersand its eager variant pass onmain98c2f7777, RTX 5080, Windows 11, VS 18 RelWithDebInfo. No new test: the parsing is covered bypipeline_cache_store_test, and this changes a constant and removes a second cap. Textual overlap with #1756 insave_session_pipeline_cache(both touch the same function); I'll mergemainwhen that lands. Not run: the wholectestset, other GPUs.AI-assisted (Claude Code).
🤖 Generated with Claude Code
@Snooozs on GitHub · 2026-11-25 14:44 UTC · original
Answering the question in the description with one measured size: my offline
pipeline_cache.binfrom thepipelinesstage is 2,096,191,412 bytes (RTX 5060 Ti, NVIDIA 621.01; the runtime loads it:loaded 2096191412 bytes from pipeline_cache.bin). So a corpus file below 4 GiB is a real case on NVIDIA, not only a theoretical one.By reading, what changes for such a setup: today both writes stop at the limit (256 MiB at teardown;
scripts/windows-boot/boot.ps1raisesLEONIDA_PIPELINE_CACHE_BYTESto 4 GiB and turns checkpoints on, but the 512 MiB checkpoint cap still stopped those). With this change a seeded run writes the whole union, 2.1 GB and up, at each checkpoint and again at teardown, and the next start loads the seed and then merges a session file that already contains it.Two ways that keep your gain: count only what the session added (
sizeminus the seed's size) against the limit, which leaves the write large but stops a seed alone from triggering it; or, once a session file exists that was written by a seeded run, skip loading the seed. I have not measured the cost of a 2.1 GB checkpoint. Not a blocker from my side: losing every build past 256 MiB is worse.The PR builds and its neighbours pass together with six other world-start pull requests (counts in #1608); it conflicts with #1756. AI-assisted (Claude Code).
@DadaCap on GitHub · 2026-11-25 14:51 UTC · original
Thank you @Snooozs, that is the size I did not have: 2.1 GB is a real seed, so with this change a seeded run writes the whole union at each checkpoint. Extrapolating my own checkpoints (0.35 s at 681 MB, 0.61 s at 1,357 MB:
fill_us394,793 +publish_us217,088) that would be about 1 s of the compile worker every time; not measured at that size.Of your two ways I prefer counting only what the session added against the limit: a seed alone then never triggers a write, and the builds a session adds are still saved. I'd rather not add it to this pull request without a maintainer saying which they want, since it needs the seed's size kept beside the cache. Whoever merges: is the plain limit fine for now, or shall I add that here? AI-assisted (Claude Code).
@Tyrannys on GitHub · 2026-11-25 18:12 UTC · original · edited 2026-11-25 18:55 UTC
Test report from a combined build on a second NVIDIA machine. Counts only.
Machine: Windows 11, RTX 4070 SUPER, NVIDIA 621.01, 64 GB, own 1.0.2.1 copy.
Build:
mainfe1553456(already contains #1827 and #1893), plus #674, #1662, #1851, #1849, #1905, #1957, #1950, #1886 and #1894. All of them merged without conflicts.Shaders: translated on
3de22a190+ #674 + #1662 with--wave64-emulate. 29,279 of 29,280 translated, and all 29,279 passspirv-val. That is 2,683 library programs and 29 of 29 FSPX.main's translator changes since then are correctness fixes only.Pipeline cache: warm and complete, 26,503 of 26,503 (9.6 GB).
ActivateRays,ActivateProbesandActivateProbesTargetprograms of indirect diffuse lighting.Recipe:
scripts/windows-boot/boot.ps1 -Seconds 480,LEONIDA_KEYBOARD_PAD=1 LEONIDA_SKIP_INT3=1 LEONIDA_TITLE_WINDOWS_MB=1024 LEONIDA_MAP_READBACK=1,LEONIDA_PIPELINE_CACHE_DIRpointing at the offline cache. Host image copy:off (auto: NVIDIA)from #1851. One run per row.LEONIDA_TITLE_WATCHDOG=0)game_scarlett_master.exe+0x23cf683)main42537e7b6+ #1631; my run table of 07:54 in #1608).AI-assisted (Claude Code).
@HasiKe on GitHub · 2026-11-25 20:08 UTC · original
Tested together with #1756 and #1950: on my PC the session cache now persists and a second boot reuses it. AI-assisted test.
Setup: RTX 2070 SUPER, NVIDIA 616.56, Windows 11.
main490f5b9ec+ #1756 + #1886 + #1950 (two small conflicts insave_session_pipeline_cacheresolved by keeping both sides).LEONIDA_STARTUP_CACHE_CHECKPOINTS=1,LEONIDA_CONSOLE_FIX_US=0, no offlinepipeline_cache.binnext to the exe.mainalone, 2 hScreenProbes_ActivateRays(1,925 s build)#1950's exit path wrote too: after the device loss in run 2 (0x80000003),
pipeline-cache op=exit bytes=119019741 ok=1.Run 2 then hit a device loss at ~203 s, before the cache was even needed for the big builds. I'm narrowing that down with the crash-diagnostic layer and will report it separately in #1608.
@aslan2142 on GitHub · 2026-11-26 01:26 UTC · original
Raising the limit is right, and making checkpoints follow it fixes
boot.ps1andboot.sh, whose 4 GiB setting was being capped at 512 MiB. Three points before merging:docs/d3d12_vulkan.md:2423still says checkpoints have "an additional 512 MiB ceiling". Please drop that sentence.default_save_limitstill says the cap stops a seeded cache being rewritten at every exit. With 4 GiB it doesn't for the 2.1 GB and 3.81 GB seeds, and a 9.7 GB union saves nothing. Your suggestion to count onlysizeminus the seed's size against the limit sounds good to us; please add it here.kExitCacheWriteMs(3 s) was sized from a 77 MiB cache. A line about the exit time at about 4 GiB, or a measurement, would help.Wine suite (lavapipe and RDNA2 iGPU): no regressions from this PR.
AI-assisted (Claude Code, Claude Opus 5.5).
@DadaCap on GitHub · 2026-11-26 01:36 UTC · original
@aslan2142 thank you, all three are in
66e96ccea(with main merged first, no conflict):LEONIDA_PIPELINE_CACHE_BYTESline now says the limit is on what a session adds.pipeline_cache.binthe device cache was created from is no longer counted. The check ispipeline_cache_store::over_save_limit(size, seed, limit)(size minus seed over the limit), and the comment ondefault_save_limitnow says this.pipeline_cache_store_testhas cases for no seed, a 9 GB seed plus 1 GB of new builds (saved), 5 GB added (refused), a cache smaller than its seed, and the exact edge. A session file loaded as the seed still counts whole, since that is what gets rewritten.kExitCacheWriteMsis now 6 s; the wait still ends as soon as the write does.Tested:
pipeline_cache_store,pipeline_cache_file,pipeline_cache_seed,pipeline_cache_journal,pipeline_cache_snapshot(5/5) and agta6rtbuild. AI-assisted (Claude Code, Claude Opus 5.5).