[PR #1886] [MERGED] d3d12: the session pipeline cache is saved up to 4 GiB, checkpoints included (RT-SESSION-CACHE-LIMIT) #1896

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1886
Author: @DadaCap
Created: 11/25/2026
Status: ✅ Merged
Merged: 11/26/2026
Merged by: @aslan2142

Base: main ← Head: session-cache-limit


📝 Commits (3)

  • a031392 d3d12: the session pipeline cache is saved up to 4 GiB, checkpoints included (RT-SESSION-CACHE-LIMIT)
  • 10b01d2 Merge remote-tracking branch 'origin/main' into session-cache-limit
  • 66e96cc d3d12: the session cache limit counts what a session adds to an offline seed; exit wait sized from measurements

📊 Changes

4 files changed (+38 additions, -15 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+3 -2)
📝 runtime/shims/d3d12_vulkan_device.cpp (+15 -8)
📝 runtime/src/pipeline_cache_store.h (+12 -5)
📝 runtime/test/pipeline_cache_store_test.cpp (+8 -0)

📄 Description

RT-SESSION-CACHE-LIMIT, claimed and found in #1608.

What

The session pipeline cache's default save limit (LEONIDA_PIPELINE_CACHE_BYTES) goes from 256 MiB to 4 GiB, and a checkpoint uses the same limit instead of its own 512 MiB.

Why

Past the limit nothing is written, so every later build is lost and the next run repeats it. The world phase exceeds it on NVIDIA:

RTX 5080, NVIDIA 621.24, main + #1756 + #1849 + #1827, LEONIDA_DEVICE_TYPE=6, the two later runs with LEONIDA_SERIAL_BIG_COMPILES=0 session file
four runs with the default stuck at 267.7 MB; log pipeline cache is 350948938 bytes, over the 268435456-byte write limit
next run, limit and checkpoint cap raised (30 min) 867 MB
the run after (25 min) 1,285 MB

The effect on the next run: 353 of 362 builds that were slow (2 s or more) in one run came from the cache in the following one (5 rebuilt, probably in flight when the run was stopped; 4 not reached when I counted). The later run passed in about 80 s what had taken the earlier one its whole 30 minutes. Those two runs got to the fifth world frame, a point my runs never reached before.

Cost, measured on the same machine: loading 867 MB takes 0.35 s (driver_us), a checkpoint 0.35 s at 681 MB and 0.50 s at 1,102 MB, on the compile worker. Whether that disturbs a frame is not measured yet.

What the limit is for: the comment says it keeps a cache seeded from a multi-GB offline corpus from being rewritten at every exit. With 4 GiB a corpus file below that is rewritten, at teardown and with LEONIDA_STARTUP_CACHE_CHECKPOINTS=1 at each checkpoint. If that is a concern, a lower default (above about 1.5 GB) plus an exemption for a seeded cache would be an alternative; tell me and I'll change it.

Tests

pipeline_cache_store, d3d12_compile_teardown, d3d12_pipeline_workers and its eager variant pass on main 98c2f7777, RTX 5080, Windows 11, VS 18 RelWithDebInfo. No new test: the parsing is covered by pipeline_cache_store_test, and this changes a constant and removes a second cap. Textual overlap with #1756 in save_session_pipeline_cache (both touch the same function); I'll merge main when that lands. Not run: the whole ctest set, other GPUs.

AI-assisted (Claude Code).

🤖 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/1886 **Author:** [@DadaCap](https://github.com/DadaCap) **Created:** 11/25/2026 **Status:** ✅ Merged **Merged:** 11/26/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `session-cache-limit` --- ### 📝 Commits (3) - [`a031392`](https://github.com/ubiquitarianism/leonida/commit/a0313920cc71a2a8bc935ca255940c45b9d42bd4) d3d12: the session pipeline cache is saved up to 4 GiB, checkpoints included (RT-SESSION-CACHE-LIMIT) - [`10b01d2`](https://github.com/ubiquitarianism/leonida/commit/10b01d207e34818d6c12c05f1c1eead928a85445) Merge remote-tracking branch 'origin/main' into session-cache-limit - [`66e96cc`](https://github.com/ubiquitarianism/leonida/commit/66e96ccea6ad25043f681f0a6485267280bc8070) d3d12: the session cache limit counts what a session adds to an offline seed; exit wait sized from measurements ### 📊 Changes **4 files changed** (+38 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+3 -2) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+15 -8) 📝 `runtime/src/pipeline_cache_store.h` (+12 -5) 📝 `runtime/test/pipeline_cache_store_test.cpp` (+8 -0) </details> ### 📄 Description RT-SESSION-CACHE-LIMIT, claimed and found in [#1608](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7163972744). ## What The session pipeline cache's default save limit (`LEONIDA_PIPELINE_CACHE_BYTES`) goes from 256 MiB to 4 GiB, and a checkpoint uses the same limit instead of its own 512 MiB. ## Why Past the limit nothing is written, so every later build is lost and the next run repeats it. The world phase exceeds it on NVIDIA: | RTX 5080, NVIDIA 621.24, `main` + #1756 + #1849 + #1827, `LEONIDA_DEVICE_TYPE=6`, the two later runs with `LEONIDA_SERIAL_BIG_COMPILES=0` | session file | |---|---| | four runs with the default | stuck at 267.7 MB; log `pipeline cache is 350948938 bytes, over the 268435456-byte write limit` | | next run, limit and checkpoint cap raised (30 min) | 867 MB | | the run after (25 min) | 1,285 MB | The effect on the next run: 353 of 362 builds that were slow (2 s or more) in one run came from the cache in the following one (5 rebuilt, probably in flight when the run was stopped; 4 not reached when I counted). The later run passed in about 80 s what had taken the earlier one its whole 30 minutes. Those two runs got to the fifth world frame, a point my runs never reached before. **Cost, measured on the same machine:** loading 867 MB takes 0.35 s (`driver_us`), a checkpoint 0.35 s at 681 MB and 0.50 s at 1,102 MB, on the compile worker. Whether that disturbs a frame is not measured yet. **What the limit is for:** the comment says it keeps a cache seeded from a multi-GB offline corpus from being rewritten at every exit. With 4 GiB a corpus file below that is rewritten, at teardown and with `LEONIDA_STARTUP_CACHE_CHECKPOINTS=1` at each checkpoint. If that is a concern, a lower default (above about 1.5 GB) plus an exemption for a seeded cache would be an alternative; tell me and I'll change it. ## Tests `pipeline_cache_store`, `d3d12_compile_teardown`, `d3d12_pipeline_workers` and its eager variant pass on `main` 98c2f7777, RTX 5080, Windows 11, VS 18 RelWithDebInfo. No new test: the parsing is covered by `pipeline_cache_store_test`, and this changes a constant and removes a second cap. Textual overlap with #1756 in `save_session_pipeline_cache` (both touch the same function); I'll merge `main` when that lands. Not run: the whole `ctest` set, other GPUs. AI-assisted (Claude Code). 🤖 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>
4ld0 2026-11-26 21:19:20 +01:00
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#1896
No description provided.