Skip to content

pipelines stage: shard caches and a done-list (PIPELINES-STAGE-SHARDS-AND-DONE-LIST) - #2113

Open
Tyrannys wants to merge 6 commits into
ProjectLeonida:mainfrom
Tyrannys:claude/pipelines-shards-done-list
Open

Tyrannys wants to merge 6 commits into
ProjectLeonida:mainfrom
Tyrannys:claude/pipelines-shards-done-list

Conversation

@Tyrannys

@Tyrannys Tyrannys commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: PIPELINES-STAGE-SHARDS-AND-DONE-LIST (claim)

What and why

The pipelines stage ran vk_pipeline_check in batches of 500, and every batch loaded the whole pipeline_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:

  • Shard caches. Each checker process (batches, single-module crash probes, the BVH pass) writes its own small cache in pipeline_shards/NNNNN.bin, without loading or rewriting the big one. At the end the shards are merged into pipeline_cache.bin once, with vkMergePipelineCaches (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.
  • Done-list. pipeline_done.json in --out (written with newline="\n") records each module the checker's new --done-file names, by SHA-256 of its .spv and 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 the cl.exe fallback'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 existing pipeline_cache.bin for that one run, so what it holds still compiles from it instead of from scratch. Entries already merged hold only while pipeline_cache.bin has 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.
  • Migration. The first run over a pipeline_cache.bin from 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.
  • Crash recovery unchanged (BUILD-1030): the in-flight file, the skip file, the crashes_alone probes and range splitting all work on the list of modules still to check, selected with the new --names-file. An older checker without --merge keeps the --start/--count path 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 or pipelineCacheUUID (pipeline_cache_header.h), since a driver may silently drop such data. The seed cache is now read with one read call instead of an istreambuf_iterator copy: 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-file and --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), all tests/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.
  • CTest, 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-file selection and errors), vk_pipeline_check_cli, vk_pipeline_check_stack: 4/4 pass.
  • python -I scripts/check_no_game_data.py on every changed file: clean. No game files were used.

Speed, synthetic. make_game.pipelines with the real checker, --jobs 2, __GL_SHADER_DISK_CACHE=0, 400 synthetic compute shaders in batches of 50 (8 processes), seconds, two runs each:

Full run Rerun, nothing changed Rerun, 20 of 400 changed
old (one shared cache) 2.9 / 3.0 2.3 / 2.4 2.2 / 2.5
new (shards + done-list) 3.2 / 3.5 0.22 / 0.25 0.76 / 0.86

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: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11

AI-assisted: yes (Claude Code)

Checklist

🤖 Generated with Claude Code

…-AND-DONE-LIST)

Every checker process of the pipelines stage loaded the whole pipeline_cache.bin
(9.6 GB for the full set on NVIDIA) and saved it back, and a rerun checked all
26,503 modules again. Now, with a checker that has the new options:

- each process, crash probe and the BVH pass writes its own shard cache in
  pipeline_shards/, and the shards are merged into pipeline_cache.bin once at
  the end with vkMergePipelineCaches (vk_pipeline_check --merge). A stopped run
  keeps its shards for the next one; a good merge removes them.
- pipeline_done.json records each module that passed (--done-file) by the
  SHA-256 of its .spv and index entry. A rerun skips those, so only modules
  whose SPIR-V changed are built. The list is tied to the GPU and driver
  (--device-info: vendor/device ID, driver version, pipelineCacheUUID), the
  checker, the partner stubs and the cache file the last merge wrote.
- the first run over a cache from before the list keeps the old per-process
  load and save, so what that cache holds still compiles from it.

Crash recovery is unchanged: the in-flight file, the skip file, the single
module probes and range splitting work on the list of modules still to check,
selected with --names-file. An older checker keeps the --start/--count path.

The checker also reads its seed cache in one call (2 GiB: 21.6 s -> 1.7 s).

Tests: the batch orchestration tests run with both checker generations plus
done-list cases; CTest pipeline_cache_header (no device) and
vk_pipeline_check_merge (GPU, synthetic shaders: a merged cache gives six
application-cache hits, one shard alone three).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tyrannys and others added 2 commits November 25, 2026 15:21
When only the checker or the partner stubs change, the done-list no longer
holds, but every pipeline in pipeline_cache.bin is still this driver's. Check
every module again by checkpointing into that cache for this one run, as the
first run over an old cache does, instead of starting empty shards that
compile everything from scratch. Leftover shards of the same driver are kept
and merged. A new GPU or driver still starts from empty shards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Tyrannys

Copy link
Copy Markdown
Contributor Author

Merged main (1fe5072) at 1e48dcd; README conflict resolved keeping both sides. Tests passed: test_make_game_pipeline_batches, test_make_game_pipelines, CTest pipeline_cache_header, vk_pipeline_check_merge and vk_pipeline_check_cli (RTX 4070 SUPER, 621.01). AI-assisted (Claude Code)

Tyrannys and others added 2 commits November 25, 2026 18:02
…cache writes

The stage now checks the fspx/ and exe/ shader sets after the main set, like
bvh/, each recorded in the done-list under "extras" by a digest of its folder
and written to its own shard. library/ and fspx_gfx/ stay out: on NVIDIA the
seed does not hit for them. A failing set is not recorded and fails the stage,
but the other sets and the merge still run. A done-list with the old "bvh"
key keeps that record.

Entries merged into pipeline_cache.bin no longer depend on the file's size
and mtime. A write from outside (a checker run straight into the cache) only
adds pipelines, so the list is kept and the new stamp recorded. Merged entries
are dropped, with a log line saying why, only when the cache is gone or empty,
shrank since the last merge, or its header names another vendor, device or
pipelineCacheUUID.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Tyrannys

Copy link
Copy Markdown
Contributor Author

Real-corpus test (RTX 4070 SUPER, NVIDIA 621.01): first run over an existing cache: 26,555 pipelines OK (26,503 modules + 52 BVH), 0 failed, 7,879 s. Second run with nothing changed: 3 s, all 26,503 modules already built, no checker process and no merge.

Two fixes from that run, now pushed (16854a2, also merges current main):

  • The stage now also checks fspx/ and exe/ after the main set, like bvh/, each recorded in the done-list (under extras) and written to its own shard. library/ and fspx_gfx/ stay out (the seed does not hit for them on NVIDIA, see Coordinating who works on what (continued from #14) #1608).
  • A write to pipeline_cache.bin from outside the stage (e.g. running the checker straight into it) no longer throws away the done-list. Merged entries are dropped only when the cache is gone or empty, smaller than the last merge left it, or its header names another vendor, device or pipelineCacheUUID, and the log says which.

New fake-checker tests cover both; the pipelines Python suites and CTest pipeline_cache_header, vk_pipeline_check_cli, vk_pipeline_check_merge pass.

AI-assisted (Claude Code)

@Tyrannys

Copy link
Copy Markdown
Contributor Author

Follow-up to my earlier runs of this PR on the real corpus (RTX 4070 SUPER, NVIDIA 621.01, --jobs 14), now with 5ca599d (the head 16854a2 adds only a merge of main on top of it; I took 5ca599d alone so the runtime under test stayed the same).

Starting state: the 6.9 MB pipeline_done.json from my run 2 above, put back by hand. Since then, pipeline_cache.bin had grown from outside the stage, through direct checker runs for fspx/ and exe/ (11.51 GB after run 1, 12.94 GB now). Before this commit, that change made the next run start again from "0 of 26503" and write an empty done-list (449 bytes).

run what it said time
3 "pipeline_cache.bin changed since the last merge but is no smaller and is this driver's; keeping the done-list", then "26503 of 26503 modules are already built ...; 0 to check". It then ran FSPX (29 cs ok, 0 failed, 13 s) and the .exe graphics programs (11 ps + 1 vs ok, 0 failed) into 2 shards, and merged them (seeded with the 12.94 GB cache, about 62 s). 81 s
4 (nothing changed) "26503 of 26503 ... 0 to check", then done. No FSPX, .exe or merge step. 3 s

pipeline_done.json went from 6,867,169 to 6,867,375 bytes, so the FSPX and .exe entries are now in it. pipeline_cache.bin stayed 12,940,236,731 bytes, because those pipelines were already in it. tests/test_make_game_pipeline_batches.py: 51 passed, 1 skipped.

Not checked: a driver update, a shrinking cache, the library and fspx_gfx folders (still built at runtime).

AI-assisted (Claude Code).

@Tyrannys

Copy link
Copy Markdown
Contributor Author

Overlap: #2208 (keep checking pipelines when the crash report is locked) touches the same end-of-stage block of pipelines(). A test-merge with this head (16854a2) conflicts in one hunk: keep this PR's block and use #2208's report_written = bool(crashed) and record_crashes(out, spirv, crashed) in place of the if crashed: record_crashes(...) call. With that resolution the pipelines tests, the batch/done-list tests and the line-endings test pass. Suggest #2208 lands first; I'll merge main here afterwards with that resolution.

AI-assisted (Claude Code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants