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

Merged
kawaii-shakal merged 5 commits from upstream-pr/1914 into main 2026-11-26 14:41:03 +00:00
kawaii-shakal commented 2026-11-25 15:41:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-25T15:41:03Z.


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://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7167207402

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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5494497385 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1914). Originally posted by [kawaii-shakal](https://github.com/kawaii-shakal) on 2026-11-25T15:41:03Z. --- > **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://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7167207402 ### 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)
Tyrannys commented 2026-11-25 19:11:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-25T19:11:24Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7171941355 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1914#issuecomment-7171941355). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-25T19:11:24Z. --- 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).
lixonik commented 2026-11-25 19:27:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-25T19:27:58Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6063712709 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1914#pullrequestreview-6063712709). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-25T19:27:58Z. **Review:** COMMENTED --- 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 commented 2026-11-25 19:27:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-25T19:27:58Z.

Code review location: runtime/shims/d3d12_vulkan_device.cpp; line 2133

@@ -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.

<!-- greyfinch-sync:ubiquitarianism/leonida:review-comment:4699835841 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1914#discussion_r4699835841). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-25T19:27:58Z. **Code review location:** `runtime/shims/d3d12_vulkan_device.cpp`; line 2133 ~~~~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.
Snooozs commented 2026-11-25 20:01:45 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Snooozs on 2026-11-25T20:01:45Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7173087037 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1914#issuecomment-7173087037). Originally posted by [Snooozs](https://github.com/Snooozs) on 2026-11-25T20:01:45Z. --- 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).
kawaii-shakal commented 2026-11-25 22:19:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-25T22:19:34Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7176222007 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1914#issuecomment-7176222007). Originally posted by [kawaii-shakal](https://github.com/kawaii-shakal) on 2026-11-25T22:19:34Z. --- 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)_
OreoFR commented 2026-11-25 23:52:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-25T23:52:21Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7178154022 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1914#issuecomment-7178154022). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-25T23:52:21Z. --- 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.
kawaii-shakal commented 2026-11-26 00:27:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-26T00:27:50Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7178783607 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1914#issuecomment-7178783607). Originally posted by [kawaii-shakal](https://github.com/kawaii-shakal) on 2026-11-26T00:27:50Z. --- 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).
aslan2142 commented 2026-11-26 14:41:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-26T14:41:59Z.


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)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7195193780 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1914#issuecomment-7195193780). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-26T14:41:59Z. --- 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)
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!1914
No description provided.