d3d12: a pipeline cache for the offline cache's misses, written while the game runs (RT-HEAVY-PIPELINE-CACHE) #1914

Manually merged
github merged 5 commits from github-bot/gh-1914 into main 2026-11-26 14:53:19 +00:00 AGit
Owner

@⁠kawaii-shakal on GitHub · 2026-11-25 15:41 UTC · original
kawaii-shakal:heavy-pipeline-cache → main · +439 −5 · 9 files · 5 commits · merged 2026-11-26 14:41 UTC

Update (a42bffdc3, merged with main c50ed94b3): main now persists compute pipelines in its per-pipeline journal (src/pipeline_cache_journal.h), so the heavy cache here covers graphics pipelines only; compute builds use main's build_compute_pipeline unchanged. The text below describes the original version, where it covered both.

Claimed in the coordination issue as RT-HEAVY-PIPELINE-CACHE: #1608

Problem

The builds the offline pipeline_cache.bin misses are compiled again on every boot. On an RTX 5070 Ti these are the pipeline library's compute programs, 3 to 7 s each and about 40 per boot before the world starts, and they are what keeps the render thread waiting at the title's hang watchdog. pipeline_cache.session.bin can't keep them for two reasons:

  • It is written at device teardown only, and a boot that ends in a crash never gets there.
  • A cache seeded from the corpus returns the whole corpus (9.2 GB here), so even a clean teardown is over the 256 MiB write limit and writes nothing. LEONIDA_STARTUP_CACHE_CHECKPOINTS has the same problem.

Change

  • Corpus first, without compiling. Every graphics and compute build first asks the corpus cache with VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT (DeviceState::create_pipeline).
  • A miss goes to a cache of its own. It is built against a second cache seeded from pipeline_cache.heavy.bin, next to pipeline_cache.bin. That cache holds only the corpus's misses, so it stays small.
  • Written while the game runs. A build of at least LEONIDA_HEAVY_PIPELINE_CACHE_MS (500 by default) marks the cache dirty. A thread of its own writes it 3 s after the newest slow build and no later than 20 s after the first unwritten one, through the existing staging file and rename (CacheStagingFile), so the file on disk is always complete. A crash loses at most the last 20 s of slow builds. At teardown the thread stops and writes what is left.
  • Off switch. LEONIDA_HEAVY_PIPELINE_CACHE_MS=0 turns it off, and with it pipelineCreationCacheControl unless LEONIDA_PIPELINE_COMPILE=cache-only asks for it. A cache-only create (cache-only) is left exactly as it was.
  • Pure logic, tested on its own. The threshold parsing and the write schedule are in runtime/src/heavy_pipeline_cache.h, with heavy_pipeline_cache_test.
  • Test devices. vk_test_device.h takes the heavy path when LEONIDA_HEAVY_PIPELINE_CACHE_MS is set, and d3d12_mesh_heavy_cache runs the mesh test's draws through it.
  • Docs. docs/d3d12_vulkan.md describes it next to the session cache.

Measured (Windows 11 Pro 26300, RTX 5070 Ti, NVIDIA 617.42, VS 2026 RelWithDebInfo)

  • Does the driver honour cache-only for the heavy programs? Checked with vk_pipeline_check and a local probe that adds the flag (not part of this PR), against an empty cache. Four library compute programs the corpus lacks return VK_PIPELINE_COMPILE_REQUIRED in under 1 ms, so the heavy path is taken for them. The mesh test's small shaders come back VK_SUCCESS from a cache-only create even into an empty cache, because the driver's own shader cache already holds them. That is why the CTest case checks correctness, not the file.
  • CTest: heavy_pipeline_cache, pipeline_cache_store, pipeline_cache_file, d3d12_msaa_draw, d3d12_mesh and d3d12_mesh_heavy_cache all pass, 6 of 6.

Not done here

  • No real boot yet. I haven't run this PR in a real boot, so the next one will measure how much of the inline compile time goes away on the second boot.
  • Graphics variants share the same path. They are only slow when the corpus misses them.

🤖 Generated with Claude Code

**@⁠kawaii-shakal** on GitHub · 2026-11-25 15:41 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1914) `kawaii-shakal:heavy-pipeline-cache` → `main` · +439 −5 · 9 files · 5 commits · merged 2026-11-26 14:41 UTC > **Update (a42bffdc3, merged with main c50ed94b3):** main now persists compute pipelines in its per-pipeline journal (`src/pipeline_cache_journal.h`), so the heavy cache here covers **graphics pipelines only**; compute builds use main's `build_compute_pipeline` unchanged. The text below describes the original version, where it covered both. Claimed in the coordination issue as RT-HEAVY-PIPELINE-CACHE: https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608 ### Problem The builds the offline `pipeline_cache.bin` misses are compiled again on every boot. On an RTX 5070 Ti these are the pipeline library's compute programs, 3 to 7 s each and about 40 per boot before the world starts, and they are what keeps the render thread waiting at the title's hang watchdog. `pipeline_cache.session.bin` can't keep them for two reasons: - It is written at device teardown only, and a boot that ends in a crash never gets there. - A cache seeded from the corpus returns the whole corpus (9.2 GB here), so even a clean teardown is over the 256 MiB write limit and writes nothing. `LEONIDA_STARTUP_CACHE_CHECKPOINTS` has the same problem. ### Change - **Corpus first, without compiling.** Every graphics and compute build first asks the corpus cache with `VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT` (`DeviceState::create_pipeline`). - **A miss goes to a cache of its own.** It is built against a second cache seeded from `pipeline_cache.heavy.bin`, next to `pipeline_cache.bin`. That cache holds only the corpus's misses, so it stays small. - **Written while the game runs.** A build of at least `LEONIDA_HEAVY_PIPELINE_CACHE_MS` (500 by default) marks the cache dirty. A thread of its own writes it 3 s after the newest slow build and no later than 20 s after the first unwritten one, through the existing staging file and rename (`CacheStagingFile`), so the file on disk is always complete. A crash loses at most the last 20 s of slow builds. At teardown the thread stops and writes what is left. - **Off switch.** `LEONIDA_HEAVY_PIPELINE_CACHE_MS=0` turns it off, and with it `pipelineCreationCacheControl` unless `LEONIDA_PIPELINE_COMPILE=cache-only` asks for it. A cache-only create (`cache-only`) is left exactly as it was. - **Pure logic, tested on its own.** The threshold parsing and the write schedule are in `runtime/src/heavy_pipeline_cache.h`, with `heavy_pipeline_cache_test`. - **Test devices.** `vk_test_device.h` takes the heavy path when `LEONIDA_HEAVY_PIPELINE_CACHE_MS` is set, and `d3d12_mesh_heavy_cache` runs the mesh test's draws through it. - **Docs.** `docs/d3d12_vulkan.md` describes it next to the session cache. ### Measured (Windows 11 Pro 26300, RTX 5070 Ti, NVIDIA 617.42, VS 2026 RelWithDebInfo) - **Does the driver honour cache-only for the heavy programs?** Checked with `vk_pipeline_check` and a local probe that adds the flag (not part of this PR), against an empty cache. Four library compute programs the corpus lacks return `VK_PIPELINE_COMPILE_REQUIRED` in under 1 ms, so the heavy path is taken for them. The mesh test's small shaders come back `VK_SUCCESS` from a cache-only create even into an empty cache, because the driver's own shader cache already holds them. That is why the CTest case checks correctness, not the file. - **CTest:** `heavy_pipeline_cache`, `pipeline_cache_store`, `pipeline_cache_file`, `d3d12_msaa_draw`, `d3d12_mesh` and `d3d12_mesh_heavy_cache` all pass, 6 of 6. ### Not done here - **No real boot yet.** I haven't run this PR in a real boot, so the next one will measure how much of the inline compile time goes away on the second boot. - **Graphics variants share the same path.** They are only slow when the corpus misses them. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
pipeline_cache.session.bin can't keep what a crashed run compiled: it is written at device teardown only, and
a cache seeded from the multi-GiB corpus returns the whole corpus, over its write limit. So the slow builds
the corpus misses (the pipeline library's compute programs, 3 to 7 s each on an RTX 5070 Ti) are compiled
again on every boot.

Each graphics and compute build now first asks the corpus cache with
VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT. A miss is built against a second cache, seeded from
pipeline_cache.heavy.bin next to pipeline_cache.bin, so that cache holds only the misses.

A build of at least LEONIDA_HEAVY_PIPELINE_CACHE_MS (500 by default) schedules a write. A thread of its own
writes the cache 3 s after the newest slow build and no later than 20 s after the first unwritten one,
through the session cache's staging file and rename. At teardown it writes what is left. 0 turns it off,
and with it pipelineCreationCacheControl unless LEONIDA_PIPELINE_COMPILE=cache-only asks for it.

Measured with vk_pipeline_check on the RTX 5070 Ti (617.42): a cache-only create of four library compute
programs the corpus lacks returns VK_PIPELINE_COMPILE_REQUIRED in under 1 ms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GetTickCount64 moves in 10-16 ms steps, so a slow build noted during a write in the write's own tick was taken
as written. The schedule now counts notes. And without an offline seed every build goes to the heavy cache:
fast ones never schedule a write, so teardown writes the cache whenever any build went into it, which is what
pipeline_cache.session.bin used to keep.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review of RT-HEAVY-PIPELINE-CACHE:
- The writer thread marked a generation written even when the save failed, so the
  cache stayed unsaved until teardown. A failed save now keeps the cache dirty and
  is retried after a bounded backoff (5 s, doubling, capped at 2 min), so a write
  that keeps failing does not spin. WriteSchedule::failed() holds that decision and
  heavy_pipeline_cache_test checks it.
- save_heavy_pipeline_cache accepted VK_INCOMPLETE and published the truncated blob
  over a complete file. It now requires VK_SUCCESS, like the session cache, and
  keeps the previous file; the next try queries a fresh size.

Changes made by Claude Code (AI-assisted).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JPqXc6svM4pbBagTsVEYA3
main's per-pipeline compute journal (pipeline_cache_journal.h) now persists every compute build and survives a
crash, so the compute build takes main's build_compute_pipeline and the heavy cache keeps graphics pipelines only.
CMake keeps both test sets; docs and the create_pipeline comment say so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:11:00 +00:00
Author
Owner

@⁠Tyrannys on GitHub · 2026-11-25 19:11 UTC · original

Data point for this PR and for thegalaxydev's RT-PIPELINE-CACHE-GROWTH-STALL. With a complete offline cache, the session cache can't be saved at all under the current limit. Counts only.

  • Machine: Windows 11, RTX 4070 SUPER, NVIDIA 621.01, 64 GB, own 1.0.2.1 copy.
  • Runtime: main fe1553456 + #1886 + #1950 (plus #674, #1662, #1851, #1849, #1905, #1957, #1894, which don't touch the cache).
  • Offline cache: pipeline_cache.bin from a full make_game.py --stages pipelines run, every module of the 26,503-shader set including the three ScreenProbes compute shaders (each built on its own, about 30-40 min apiece; three at once crashed the driver compiler with "NVVM compilation failed: 3"). About 9.6 GB on disk.
  • Boot: warm cache via LEONIDA_PIPELINE_CACHE_DIR. At exit the session save was refused: the driver's cache data was 9.72 GB, over the 4 GiB save limit. So nothing the boot compiled was kept, even though the run ended cleanly.

The session snapshot is the whole driver cache, seed included, so once the seed alone is over the limit, every session save is refused. A separate cache for the builds the seed misses, as this PR does, avoids that. So does a limit that is measured against what the run added rather than against the total.

AI-assisted (Claude Code).

**@⁠Tyrannys** on GitHub · 2026-11-25 19:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1914#issuecomment-7171941355) Data point for this PR and for thegalaxydev's RT-PIPELINE-CACHE-GROWTH-STALL. With a **complete** offline cache, the session cache can't be saved at all under the current limit. Counts only. - **Machine:** Windows 11, RTX 4070 SUPER, NVIDIA 621.01, 64 GB, own 1.0.2.1 copy. - **Runtime:** `main` `fe1553456` + #1886 + #1950 (plus #674, #1662, #1851, #1849, #1905, #1957, #1894, which don't touch the cache). - **Offline cache:** `pipeline_cache.bin` from a full `make_game.py --stages pipelines` run, every module of the 26,503-shader set including the three ScreenProbes compute shaders (each built on its own, about 30-40 min apiece; three at once crashed the driver compiler with "NVVM compilation failed: 3"). About 9.6 GB on disk. - **Boot:** warm cache via `LEONIDA_PIPELINE_CACHE_DIR`. At exit the session save was refused: the driver's cache data was 9.72 GB, over the 4 GiB save limit. So nothing the boot compiled was kept, even though the run ended cleanly. The session snapshot is the whole driver cache, seed included, so once the seed alone is over the limit, every session save is refused. A separate cache for the builds the seed misses, as this PR does, avoids that. So does a limit that is measured against what the run added rather than against the total. AI-assisted (Claude Code).
Author
Owner

@⁠lixonik on GitHub · 2026-11-25 19:27 UTC · original · reviewed

Independent CPU check at e4c413a3a: heavy_pipeline_cache_test passes. A failure-injection harness using the current writer and teardown methods exposed one remaining issue with saving during a run. No GPU or game files.

AI-assisted.

**@⁠lixonik** on GitHub · 2026-11-25 19:27 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1914#pullrequestreview-6063712709) · **reviewed** Independent CPU check at `e4c413a3a`: `heavy_pipeline_cache_test` passes. A failure-injection harness using the current writer and teardown methods exposed one remaining issue with saving during a run. No GPU or game files. AI-assisted.
Author
Owner

@⁠lixonik on GitHub · 2026-11-25 19:27 UTC · original
On runtime/shims/d3d12_vulkan_device.cpp line 2133 (outdated):

@@ -1989,6 +2072,103 @@ struct DeviceState {
         return pipeline_cache_handle;
     }
 
+    // The heavy pipeline cache (src/heavy_pipeline_cache.h) and the thread that writes it.
+    std::once_flag heavy_cache_once;
+    VkPipelineCache heavy_cache_handle = VK_NULL_HANDLE;
+    std::mutex heavy_mutex;
+    std::condition_variable heavy_wake;
+    leonida::heavy_pipeline_cache::WriteSchedule heavy_schedule;  // under heavy_mutex
+    bool heavy_stop = false;                                      // under heavy_mutex
+    std::thread heavy_writer;                                     // started at the first slow build
+    std::atomic<std::uint64_t> heavy_compiles{0}, heavy_hits{0};
+    std::atomic<bool> heavy_changed{false};  // a build went into the heavy cache since it was loaded
+
+    VkPipelineCache heavy_cache() {
+        std::call_once(heavy_cache_once, [this] {
+            if (context->vk.vkCreatePipelineCache)
+                heavy_cache_handle = create_heavy_pipeline_cache(context->vk, info.device, pso_identity);
+        });
+        return heavy_cache_handle;
+    }
+
+    // A build past the offline cache took `took_ms`: a slow one schedules a write.
+    void note_heavy_build(ULONGLONG took_ms) {
+        heavy_changed = true;
+        if (took_ms < heavy_pipeline_cache_ms()) {
+            ++heavy_hits;
+            return;
+        }
+        ++heavy_compiles;
+        std::lock_guard lock(heavy_mutex);
+        if (heavy_stop) return;
+        heavy_schedule.note_heavy(GetTickCount64());
+        if (!heavy_writer.joinable()) {
+            try {
+                heavy_writer = std::thread([this] { write_heavy_cache_loop(); });
+            } catch (const std::exception&) {
+                return;  // no thread: the cache is still written at teardown
+            }
+        }
+        heavy_wake.notify_one();
+    }
+
+    void write_heavy_cache_loop() {
+        SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL);
+        std::unique_lock lock(heavy_mutex);
+        while (!heavy_stop) {
+            if (!heavy_schedule.dirty()) {
+                heavy_wake.wait(lock);
+                continue;
+            }
+            const std::uint64_t now = GetTickCount64();
+            if (!heavy_schedule.due(now)) {
+                heavy_wake.wait_for(lock, std::chrono::milliseconds(heavy_schedule.due_ms() - now));
+                continue;
+            }
+            const std::uint64_t generation = heavy_schedule.generation();
+            lock.unlock();
+            save_heavy_pipeline_cache(context->vk, info.device, heavy_cache_handle, heavy_compiles.load(),
+                                      heavy_hits.load());
+            lock.lock();
+            heavy_schedule.written(generation, now);

[P2] Retry unsuccessful periodic saves while the device is live

The writer ignores the save result and marks the captured generation written. If staging or publication fails briefly and no further slow compile occurs, the writer goes idle with the cache still unsaved. With the exact methods at this head, a mocked first save failure followed by 30 s on the clock produced one attempt while live and a second only at normal teardown. A crash in that interval still loses the cache. Keep the generation dirty on a failed save and retry after a bounded delay so persistent failures do not spin.

**@⁠lixonik** on GitHub · 2026-11-25 19:27 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1914#discussion_r4699835841) On `runtime/shims/d3d12_vulkan_device.cpp` line 2133 (outdated): ```diff @@ -1989,6 +2072,103 @@ struct DeviceState { return pipeline_cache_handle; } + // The heavy pipeline cache (src/heavy_pipeline_cache.h) and the thread that writes it. + std::once_flag heavy_cache_once; + VkPipelineCache heavy_cache_handle = VK_NULL_HANDLE; + std::mutex heavy_mutex; + std::condition_variable heavy_wake; + leonida::heavy_pipeline_cache::WriteSchedule heavy_schedule; // under heavy_mutex + bool heavy_stop = false; // under heavy_mutex + std::thread heavy_writer; // started at the first slow build + std::atomic<std::uint64_t> heavy_compiles{0}, heavy_hits{0}; + std::atomic<bool> heavy_changed{false}; // a build went into the heavy cache since it was loaded + + VkPipelineCache heavy_cache() { + std::call_once(heavy_cache_once, [this] { + if (context->vk.vkCreatePipelineCache) + heavy_cache_handle = create_heavy_pipeline_cache(context->vk, info.device, pso_identity); + }); + return heavy_cache_handle; + } + + // A build past the offline cache took `took_ms`: a slow one schedules a write. + void note_heavy_build(ULONGLONG took_ms) { + heavy_changed = true; + if (took_ms < heavy_pipeline_cache_ms()) { + ++heavy_hits; + return; + } + ++heavy_compiles; + std::lock_guard lock(heavy_mutex); + if (heavy_stop) return; + heavy_schedule.note_heavy(GetTickCount64()); + if (!heavy_writer.joinable()) { + try { + heavy_writer = std::thread([this] { write_heavy_cache_loop(); }); + } catch (const std::exception&) { + return; // no thread: the cache is still written at teardown + } + } + heavy_wake.notify_one(); + } + + void write_heavy_cache_loop() { + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL); + std::unique_lock lock(heavy_mutex); + while (!heavy_stop) { + if (!heavy_schedule.dirty()) { + heavy_wake.wait(lock); + continue; + } + const std::uint64_t now = GetTickCount64(); + if (!heavy_schedule.due(now)) { + heavy_wake.wait_for(lock, std::chrono::milliseconds(heavy_schedule.due_ms() - now)); + continue; + } + const std::uint64_t generation = heavy_schedule.generation(); + lock.unlock(); + save_heavy_pipeline_cache(context->vk, info.device, heavy_cache_handle, heavy_compiles.load(), + heavy_hits.load()); + lock.lock(); + heavy_schedule.written(generation, now); ``` [P2] Retry unsuccessful periodic saves while the device is live The writer ignores the save result and marks the captured generation written. If staging or publication fails briefly and no further slow compile occurs, the writer goes idle with the cache still unsaved. With the exact methods at this head, a mocked first save failure followed by 30 s on the clock produced one attempt while live and a second only at normal teardown. A crash in that interval still loses the cache. Keep the generation dirty on a failed save and retry after a bounded delay so persistent failures do not spin.
Author
Owner

@⁠Snooozs on GitHub · 2026-11-25 20:01 UTC · original

One difference to the session saver, from the code at this head (save_heavy_pipeline_cache): it accepts VK_INCOMPLETE, and publish then replaces pipeline_cache.heavy.bin; the session saver (save_session_pipeline_cache) wants VK_SUCCESS and keeps the previous file. A compile that adds to the cache between the size query and the data query gives VK_INCOMPLETE, so the file can be the partial snapshot (valid as a seed, but without the entries that did not fit). Keeping the previous file and letting the next write do it costs nothing: the cache stays dirty.

Also a measurement about size, RTX 5060 Ti 16 GB, NVIDIA 621.01: the file was 1.09 GB, and with about 640 more programs 1.60 GB. The writes are whole, so each of them was that size, one every 10 to 20 s while compiles ran (wrote ... to pipeline_cache.heavy.bin in 0.4-0.7 s). With thegalaxydev's finding about large caches (#1608, 7171729435) several smaller caches, chosen by the module's hash, would keep each small and write only what changed. I have not built that.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠Snooozs** on GitHub · 2026-11-25 20:01 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1914#issuecomment-7173087037) One difference to the session saver, from the code at this head (`save_heavy_pipeline_cache`): it accepts `VK_INCOMPLETE`, and `publish` then replaces `pipeline_cache.heavy.bin`; the session saver (`save_session_pipeline_cache`) wants `VK_SUCCESS` and keeps the previous file. A compile that adds to the cache between the size query and the data query gives `VK_INCOMPLETE`, so the file can be the partial snapshot (valid as a seed, but without the entries that did not fit). Keeping the previous file and letting the next write do it costs nothing: the cache stays dirty. Also a measurement about size, RTX 5060 Ti 16 GB, NVIDIA 621.01: the file was 1.09 GB, and with about 640 more programs 1.60 GB. The writes are whole, so each of them was that size, one every 10 to 20 s while compiles ran (`wrote ... to pipeline_cache.heavy.bin in 0.4-0.7 s`). With thegalaxydev's finding about large caches (#1608, 7171729435) several smaller caches, chosen by the module's hash, would keep each small and write only what changed. I have not built that. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠kawaii-shakal on GitHub · 2026-11-25 22:19 UTC · original

These changes were made by Claude Code (AI-assisted) in aab76535, after the review:

  • @⁠lixonik [P2], retrying failed periodic saves: the writer no longer marks a generation written when the save fails.
    WriteSchedule::failed() keeps the cache dirty and retries 5 s later. The delay doubles with each failure in a row
    and is capped at 2 min, so a save that keeps failing does not spin. Once a save succeeds, the backoff is cleared.
    heavy_pipeline_cache_test has a new test_failed_write that covers the backoff, the cap, a compile during the
    backoff and the reset after a success.
  • @⁠Snooozs, VK_INCOMPLETE: save_heavy_pipeline_cache now requires VK_SUCCESS and written <= size, the same as
    the session saver. A truncated snapshot never replaces the previous file. With the retry above, the next try
    queries a fresh size.
  • Splitting the file into several smaller caches keyed by module hash, to limit the 1.1→1.6 GB rewrites: not done in
    this PR. The file holds only the offline cache's misses. If the size becomes a problem, I'd rather do that as a
    follow-up.

Tested: heavy_pipeline_cache_test, built with g++ 13 on Linux. The shim (d3d12_vulkan_device.cpp) is Windows-only
and was not built here, so it still needs a Windows CI or local run.


Generated by Claude Code

**@⁠kawaii-shakal** on GitHub · 2026-11-25 22:19 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1914#issuecomment-7176222007) These changes were made by Claude Code (AI-assisted) in aab76535, after the review: - @⁠lixonik [P2], retrying failed periodic saves: the writer no longer marks a generation written when the save fails. `WriteSchedule::failed()` keeps the cache dirty and retries 5 s later. The delay doubles with each failure in a row and is capped at 2 min, so a save that keeps failing does not spin. Once a save succeeds, the backoff is cleared. `heavy_pipeline_cache_test` has a new `test_failed_write` that covers the backoff, the cap, a compile during the backoff and the reset after a success. - @⁠Snooozs, VK_INCOMPLETE: `save_heavy_pipeline_cache` now requires `VK_SUCCESS` and `written <= size`, the same as the session saver. A truncated snapshot never replaces the previous file. With the retry above, the next try queries a fresh size. - Splitting the file into several smaller caches keyed by module hash, to limit the 1.1→1.6 GB rewrites: not done in this PR. The file holds only the offline cache's misses. If the size becomes a problem, I'd rather do that as a follow-up. Tested: `heavy_pipeline_cache_test`, built with g++ 13 on Linux. The shim (`d3d12_vulkan_device.cpp`) is Windows-only and was not built here, so it still needs a Windows CI or local run. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠OreoFR on GitHub · 2026-11-25 23:52 UTC · original

Real boots with this PR (earlier head, before aab76535) on an RTX 4070 Laptop 8 GB, NVIDIA 621.40, main + #2077 + the mesh-indirect branch: pipeline_cache.heavy.bin loads at start (~100 MB) and is rewritten during the run in about 0.1 s each time (e.g. "3 slow builds and 364 other builds past the offline cache so far"). Across runs it does its job: the mesh pipeline builds that missed the offline cache went from 135 in the first run to 13 in the next ones. No crash or corrupt cache file in ~15 runs, including runs that ended in a device loss.

**@⁠OreoFR** on GitHub · 2026-11-25 23:52 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1914#issuecomment-7178154022) Real boots with this PR (earlier head, before aab76535) on an RTX 4070 Laptop 8 GB, NVIDIA 621.40, main + #2077 + the mesh-indirect branch: `pipeline_cache.heavy.bin` loads at start (~100 MB) and is rewritten during the run in about 0.1 s each time (e.g. "3 slow builds and 364 other builds past the offline cache so far"). Across runs it does its job: the mesh pipeline builds that missed the offline cache went from 135 in the first run to 13 in the next ones. No crash or corrupt cache file in ~15 runs, including runs that ended in a device loss.
Author
Owner

@⁠kawaii-shakal on GitHub · 2026-11-26 00:27 UTC · original

Merged main (c50ed94b3) in a42bffdc3; the PR had a conflict with it.

main now has its own crash-safe store for compute pipelines: the per-pipeline journal (pipeline_cache.d/cs-<hash>.bin, src/pipeline_cache_journal.h), written right after each compile. So in the merge the compute build is main's build_compute_pipeline unchanged, and the heavy cache keeps graphics pipelines only (create_pipeline is used by the graphics variant build). Two effects:

  • No double bookkeeping for compute: one store per pipeline kind.
  • The heavy file gets much smaller, because the largest programs (the library compute shaders) are no longer in it. That covers most of @⁠Snooozs's point about 1.1-1.6 GB whole-file rewrites; splitting the graphics file by module hash stays a possible follow-up.

The docs section and the create_pipeline comment say this now.

Tested (Windows 11, MSVC RelWithDebInfo, RTX 5070 Ti, NVIDIA 617.42), including the aab76535 review fixes on Windows for the first time:

  • Full CTest: 449 of 451 pass. The two failures, xbox_present and d3d12_set_descriptor_heaps, fail the same way on a clean build of main c50ed94b3 and with LEONIDA_HEAVY_PIPELINE_CACHE_MS=0, so they are not from this PR. Both tests were changed in main recently, by #671 and #2141.
  • heavy_pipeline_cache, d3d12_mesh, d3d12_mesh_heavy_cache, pipeline_cache_journal, d3d12_compute_journal and the other cache, journal and mesh tests: 10 repeats, all pass.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠kawaii-shakal** on GitHub · 2026-11-26 00:27 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1914#issuecomment-7178783607) Merged main (c50ed94b3) in a42bffdc3; the PR had a conflict with it. main now has its own crash-safe store for compute pipelines: the per-pipeline journal (`pipeline_cache.d/cs-<hash>.bin`, `src/pipeline_cache_journal.h`), written right after each compile. So in the merge the compute build is main's `build_compute_pipeline` unchanged, and the heavy cache keeps **graphics pipelines only** (`create_pipeline` is used by the graphics variant build). Two effects: - No double bookkeeping for compute: one store per pipeline kind. - The heavy file gets much smaller, because the largest programs (the library compute shaders) are no longer in it. That covers most of @⁠Snooozs's point about 1.1-1.6 GB whole-file rewrites; splitting the graphics file by module hash stays a possible follow-up. The docs section and the `create_pipeline` comment say this now. **Tested** (Windows 11, MSVC RelWithDebInfo, RTX 5070 Ti, NVIDIA 617.42), including the `aab76535` review fixes on Windows for the first time: - Full CTest: 449 of 451 pass. The two failures, `xbox_present` and `d3d12_set_descriptor_heaps`, fail the same way on a clean build of main c50ed94b3 and with `LEONIDA_HEAVY_PIPELINE_CACHE_MS=0`, so they are not from this PR. Both tests were changed in main recently, by #671 and #2141. - `heavy_pipeline_cache`, `d3d12_mesh`, `d3d12_mesh_heavy_cache`, `pipeline_cache_journal`, `d3d12_compute_journal` and the other cache, journal and mesh tests: 10 repeats, all pass. AI-assisted (Claude Code, Claude Opus 5.5).
github manually merged commit 32a04b17f9 into main 2026-11-26 14:53:19 +00:00
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-26 14:41 UTC · original

Thank you, @⁠kawaii-shakal. This went into main through #2350 (RT-LINUX-AMD-WORLD), merged at your head a42bffdc3 with your commits and authorship kept. The only conflict was the session-cache paragraph in docs/d3d12_vulkan.md against #1886: main's cap and your heavy-cache text were both kept. GitHub shows this PR as merged for that reason, so nothing needs closing.

AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)

**@⁠aslan2142** on GitHub · 2026-11-26 14:41 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1914#issuecomment-7195193780) Thank you, @⁠kawaii-shakal. This went into `main` through #2350 (RT-LINUX-AMD-WORLD), merged at your head `a42bffdc3` with your commits and authorship kept. The only conflict was the session-cache paragraph in `docs/d3d12_vulkan.md` against #1886: main's cap and your heavy-cache text were both kept. GitHub shows this PR as merged for that reason, so nothing needs closing. AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)
This discussion has been locked. Commenting is limited to contributors.
No description provided.