Repository navigation
Runtime: use the Vulkan pipeline cache produced by the build (D3D-34) - #367
Conversation
VictorJulianiR
left a comment
There was a problem hiding this comment.
The runtime now consumes the cache emitted by vk_pipeline_check. Its existing save_cache writer (lines 594–602) uses a temporary ofstream without checking write or close, then removes the previous cache and ignores the rename result. For example, a disk-full short write after the header can publish a truncated cache and still print the expected size as saved. The runtime’s device/header check cannot distinguish that prefix from a complete cache. Could the producer check vkGetPipelineCacheData, write and close successfully, then replace the previous file without removing it first? An injected write failure should leave the previous cache readable.
AI-assisted static review of 4e4b338. No project code was executed.
|
Cold-cache numbers for the corpus, since the cache you are adding is exactly what this decides. Measured with Hardware: RX 7600 (
Wall time 1,393.7 s on 6 threads for the whole set, i.e. about 8,311 s of compile work. Tail: 1,440 pipelines take more than 1 s, 479 more than 5 s, 11 more than 10 s, 6 more than 20 s, 2 more than 50 s. The two worst are the Warm cache is a different world: the same set re-runs in 32.5 s with 13 pipelines over 1 s. So the cache changes first-run cost by two orders of magnitude, and the tail is a small, known set that could be precompiled into the seed. Two implications for the key: the cache UUID already covers the driver, but on this machine Mesa moved from 27.0.0-devel builds between runs and invalidated everything, which is the expected cost. And a missing seed is not a small regression: one 122 s pipeline is a visible stall at level load even if everything else is cached. I can post the full list of the >1 s shaders (names only) if that helps pick what to precompile. |
|
Clean rerun, replaces the numbers I posted earlier in this thread: those were taken while another job was using the CPU, and the wall times were inflated. Setup: RX 7600 (
So the earlier 32.5 s was pure hits, not a mix: the warm runs have zero misses. The cold and control runs still show ~9.8k gfx hits, and the control has the disk cache disabled, so those hits are duplicates inside the corpus (the same graphics pipeline rebuilt for another variant), not a warm disk cache. Cache after the cold run: 436 MiB, 30,493 files, median entry 341 B. The default 1 GB limit is enough for this corpus; 16G changes nothing (23.8 vs 28.7 s is noise), so no Cold percentiles, seconds:
Compute is 10% of the pipelines and 60% of the compile time. The clean tail is two ScreenProbes ActivateProbes at 124.0 s and 108.2 s, ActivateRays at 47.9 s, then RTShadowTrace32 at 29–31 s. That tail is module size, not cache: the two largest are 47 MB modules, which is #881. For a seed: cold work is 7,734 s of compile time, warm is 28.7 s, so a cache that covers the tail is worth a lot. The cache file itself is 436 MiB for the whole corpus, so a full seed is above the 200 MB target; a tail-only seed would be far smaller, and the two ScreenProbes plus the RTShadow family are the place to start. |
|
Seed measurement, local, nothing committed. The short version: a top-N seed does not meet a 200 MB / 50% budget; 50% needs about 260 MB, and the cost curve is broad rather than a handful of shaders. Setup: RX 7600 ( Seeds were built from a directory holding only the shaders whose cold time covers 25/50/75% of the 7,734 s total, then loaded into a full-corpus run:
So:
The curve is broad: 25% of the cost is 240 shaders, 50% is 614, 75% is 2,060 out of 26,503. This is not a "precompile the ten worst" problem. If a hard 200 MB budget matters, select by time per byte, not by top-N time. The two ScreenProbes ActivateProbes are 124.0 and 108.2 s but are 47 MB modules each (#881), so they are likely the worst value per cache byte and should be candidates for exclusion; medium shaders should fill the seed instead. I can measure that variant if useful, but the expectation is roughly 35–40% at 200 MB, not 50%. Key stays (GPU + Mesa build + enabled features), and the seed is dead after a driver update. |
|
#291's stack is on main now (through #1083, at 99f9989): the GPU address arena, shader_library, PSOs and draws, and the M0/M1 tests. This PR still carries the old #291 commits, so it conflicts in d3d12_draw_test, d3d12_present_test, shader_library_test, vk_pipeline_check and vk_test_device. Could you rebase only the pipeline-cache part onto main? It's what lets a first boot reuse the build's pipeline_cache.bin, and I'll merge it once ctest and the GPU suites pass. |
|
@mrb-eel, a heads-up so our PRs don't collide: #1865 (M5) adds one Your PR does the seeding, i.e. maps AI-assisted (Claude Code). |
4e4b338 to
58226b4
Compare
The README said the pipelines stage saves a pipeline cache "so the first boot doesn't compile them". Nothing in runtime/src or runtime/shims reads pipeline_cache.bin yet (only vk_pipeline_check in runtime/test writes it; D3D-34 / ProjectLeonida#367 is meant to load it), so the sentence promised something the runtime does not do. Reword it to what make_game.py does: create every translated shader on the GPU driver, check that they compile, and save the cache to pipeline_cache.bin in --out, and say the runtime does not load it yet. Claimed in ProjectLeonida#2716. Written with AI assistance (Claude, via OpenBot). Tested: python -I tests/test_docs_{design_rows,links,list_items,repo_paths}.py, tests/test_i18n_index.py and tests/test_text_write_line_endings.py pass (Windows 11, docs only; no GPU involved). Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
What changes
D3D-34 adds Vulkan runtime cache seeding from the offline build. Coordination claim.
pipeline_cache.binbeside the runtime executable on the first graphics or compute PSO creation. Map the file read-only and match its Vulkan header against the device and pipeline-cache UUID. An absent, incompatible, or rejected seed falls back to an empty cache.Validation
f847748cand building with MSVC 19.44 and Windows SDK 10.0.26100.0 succeeded.vk_pipeline_check_cli,d3d12_compute,d3d12_draw, andd3d12_set0_computepassed. GPU tests ran with Vulkan validation and synchronization validation enabled on an RTX 4070 SUPER (616.92).0x3(valid application-cache hit). With a missing file, a truncated header, or a changed UUID, flags were0x1(valid, no application-cache hit). All four runs matched 64 elements across each of three dispatches.AI-assisted implementation and testing. No game files were used.