mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:30:53 +01:00
[PR #2113] pipelines stage: shard caches and a done-list (PIPELINES-STAGE-SHARDS-AND-DONE-LIST) #2120
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#2120
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/2113
Author: @Tyrannys
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:claude/pipelines-shards-done-list📝 Commits (5)
3eb9a8dpipelines stage: shard caches and a done-list (PIPELINES-STAGE-SHARDS-AND-DONE-LIST)be4d94cpipelines stage: a new checker rechecks from the existing cache1e48dcdMerge remote-tracking branch 'upstream/main' into claude/pipelines-shards-done-list5ca599dpipelines: check fspx/ and exe/ too, keep the done-list over outside cache writes16854a2Merge remote-tracking branch 'upstream/main' into claude/pipelines-shards-done-list📊 Changes
10 files changed (+1350 additions, -40 deletions)
View changed files
📝
README.md(+7 -5)📝
docs/pipeline_check.md(+67 -2)📝
make_game.py(+431 -19)📝
runtime/CMakeLists.txt(+12 -0)➕
runtime/test/check_vk_pipeline_merge.py(+170 -0)➕
runtime/test/pipeline_cache_header.h(+74 -0)➕
runtime/test/pipeline_cache_header_test.cpp(+66 -0)📝
runtime/test/vk_pipeline_check.cpp(+176 -9)📝
tests/test_make_game_pipeline_batches.py(+341 -4)📝
tests/test_make_game_pipelines.py(+6 -1)📄 Description
Claimed in the coordination issue as: PIPELINES-STAGE-SHARDS-AND-DONE-LIST (claim)
What and why
The
pipelinesstage ranvk_pipeline_checkin batches of 500, and every batch loaded the wholepipeline_cache.bin(9.6 GB for the full set on an RTX 4070 SUPER, NVIDIA 621.01) and saved it back: 1-2 minutes of I/O per batch, times 53. A rerun after a translator change also walked all 26,503 modules again.With a checker that has the new options, the stage now:
pipeline_shards/NNNNN.bin, without loading or rewriting the big one. At the end the shards are merged intopipeline_cache.binonce, withvkMergePipelineCaches(vk_pipeline_check --merge <out> <in>...), and removed. A stopped run (Ctrl+C, setup error, crash retries running out) keeps its shards and the next run merges them; a failed merge leaves cache and shards as they were. A run with a validation failure still merges what was built, as each batch's own save did before.pipeline_done.jsonin--out(written withnewline="\n") records each module the checker's new--done-filenames, by SHA-256 of its.spvand of its index entry, and which shard (or the merged cache) holds it. A rerun skips them, so after a translator change only modules whose SPIR-V changed are built. The whole list is tied to the GPU and driver (--device-info: vendor/device ID, driver version,pipelineCacheUUID), the checker (hash of its sources when it is this checkout's current build, so thecl.exefallback's relink doesn't throw the list away; else hash of the executable), the partner stubs and the list format. Any change checks every module again. A new GPU or driver starts from empty shards (the old cache is no use to it). A new checker or new stubs on the same driver checkpoint into the existingpipeline_cache.binfor that one run, so what it holds still compiles from it instead of from scratch. Entries already merged hold only whilepipeline_cache.binhas the size and mtime the last merge left. Failed or crashed modules are never on the list, so they get a fresh chance every run, as before. The BVH pass is recorded by a hash of its index and.spv, so an unchanged corpus starts no checker process and needs no merge.pipeline_cache.binfrom before the done-list keeps the old per-process load and save, so what that cache holds still compiles from it instead of from scratch; later runs use shards.crashes_aloneprobes and range splitting all work on the list of modules still to check, selected with the new--names-file. An older checker without--mergekeeps the--start/--countpath exactly as it was.Checker changes (
runtime/test/vk_pipeline_check.cpp):--names-file,--done-file,--device-info,--merge. The merge refuses an input whose header names another vendor, device orpipelineCacheUUID(pipeline_cache_header.h), since a driver may silently drop such data. The seed cache is now read with onereadcall instead of anistreambuf_iteratorcopy: loading a 2 GiB cache file went from 21.6 s to 1.7 s on this PC.What ends up in the cache is the same: each pipeline is created by the same checker with the same device setup, just into a smaller cache that is merged afterwards. The merge test below shows the merged cache gives application-cache hits for every pipeline of both shards.
Tested
python -I tests/test_make_game_pipeline_batches.py: the existing real-orchestration tests now run with both checker generations (the fake checker speaks--names-file,--done-fileand--merge), plus done-list cases: one shard per process and one merge, LF-only done-list, rerun with nothing to do, only the changed module rebuilt, changed index entry, new driver /pipelineCacheUUID/ GPU rebuild everything into shards, new checker / stubs recheck everything from the existing cache and keep leftover shards, interrupted run keeps its shard and the next run finishes the rest, failed merge keeps the shards, removed cache rebuilds, crashed and failed modules not done, migration over an old cache, BVH pass skipped when unchanged. 45 tests, OK (1 skip: the old-checker-only case in the shard subclass).python -I tests/test_make_game_pipelines.py(pinned to the legacy protocol), alltests/test_make_game*.py,test_text_write_line_endings.py,test_ctest_registration.py,test_vk_pipeline_check_index.py,test_vk_pipeline_check_isolate.py(on the GPU, with this checker),test_build_runtime_fallback.py,test_docs_repo_paths.py: all pass.python -m compileall -q make_game.py tools tests,python -I make_game.py --help.cmake --build ... --parallel 2:pipeline_cache_header(new, no device),vk_pipeline_check_merge(new, GPU: two caches of three synthetic compute shaders, merged; a run over all six seeded with the merge reports 6 application-cache hits, the first shard alone 3; merging into an existing output keeps it; a foreign-header input fails with exit 1 and leaves the output byte-identical;--names-file/--done-fileselection and errors),vk_pipeline_check_cli,vk_pipeline_check_stack: 4/4 pass.python -I scripts/check_no_game_data.pyon every changed file: clean. No game files were used.Speed, synthetic.
make_game.pipelineswith the real checker,--jobs 2,__GL_SHADER_DISK_CACHE=0, 400 synthetic compute shaders in batches of 50 (8 processes), seconds, two runs each:Reruns are about 10x and 3x faster here. That corpus's cache is only 2.8 MB, so the full run shows the fixed cost of the new path (device query, hashing, one merge process: +0.3 s) and none of the cache I/O, which is what dominates the real corpus. There the stage no longer loads and saves 9.6 GB per batch (1-2 min each, 53 batches: roughly 1-1.5 h of a full run and nearly all of a rerun) but once in the merge, which is also faster now that the seed is read in one call (2 GiB: 21.6 s -> 1.7 s). I did not run the full corpus: another build was using this GPU.
GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.01, Windows 11
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (also test-merged cleanly with the open PRs touching the checker or the stage: #2042, #2088, #1891, #1890, #1833, #1930, #2098).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.