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

Open
opened 2026-11-26 21:20:06 +01:00 by 4ld0 · 0 comments
Owner

📋 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)

  • 3eb9a8d pipelines stage: shard caches and a done-list (PIPELINES-STAGE-SHARDS-AND-DONE-LIST)
  • be4d94c pipelines stage: a new checker rechecks from the existing cache
  • 1e48dcd Merge remote-tracking branch 'upstream/main' into claude/pipelines-shards-done-list
  • 5ca599d pipelines: check fspx/ and exe/ too, keep the done-list over outside cache writes
  • 16854a2 Merge 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 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: NVIDIA GeForce RTX 4070 SUPER, driver 621.01, Windows 11

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (also test-merged cleanly with the open PRs touching the checker or the stage: #2042, #2088, #1891, #1890, #1833, #1930, #2098).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of 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.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2113 **Author:** [@Tyrannys](https://github.com/Tyrannys) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `claude/pipelines-shards-done-list` --- ### 📝 Commits (5) - [`3eb9a8d`](https://github.com/ubiquitarianism/leonida/commit/3eb9a8d9db505b75117e4ab1e681ef4457a080a7) pipelines stage: shard caches and a done-list (PIPELINES-STAGE-SHARDS-AND-DONE-LIST) - [`be4d94c`](https://github.com/ubiquitarianism/leonida/commit/be4d94c134358dedd59585309c83993571b4a4e1) pipelines stage: a new checker rechecks from the existing cache - [`1e48dcd`](https://github.com/ubiquitarianism/leonida/commit/1e48dcd69a2e92afe15064c28060a23032948e2b) Merge remote-tracking branch 'upstream/main' into claude/pipelines-shards-done-list - [`5ca599d`](https://github.com/ubiquitarianism/leonida/commit/5ca599dcc32e646e6978df54c91106b81ccf3e00) pipelines: check fspx/ and exe/ too, keep the done-list over outside cache writes - [`16854a2`](https://github.com/ubiquitarianism/leonida/commit/16854a2293d14164b3f27a3adfdc279ce1064563) Merge remote-tracking branch 'upstream/main' into claude/pipelines-shards-done-list ### 📊 Changes **10 files changed** (+1350 additions, -40 deletions) <details> <summary>View changed files</summary> 📝 `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) </details> ### 📄 Description Claimed in the coordination issue as: PIPELINES-STAGE-SHARDS-AND-DONE-LIST ([claim](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7174076789)) ### 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: NVIDIA GeForce RTX 4070 SUPER, driver 621.01, Windows 11 AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (also test-merged cleanly with the open PRs touching the checker or the stage: #2042, #2088, #1891, #1890, #1833, #1930, #2098). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#2120
No description provided.