[PR #2275] d3d12: warm-up creates no longer hold the compile gate (RT-COMPILE-GATE-WARMUP-FREE) #2279

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2275
Author: @Tyrannys
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: claude/compile-gate-warmup-free


📝 Commits (3)

  • a83f385 d3d12: a pool of compile workers for the pipeline compiler (RT-ASYNC-COMPILE-POOL)
  • 2d56b68 d3d12: the checkpoint's second look also sees a running demanded build
  • e4713a4 d3d12: warm-up creates no longer hold the compile gate (RT-COMPILE-GATE-WARMUP-FREE)

📊 Changes

8 files changed (+991 additions, -58 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+26 -0)
📝 runtime/CMakeLists.txt (+12 -0)
📝 runtime/README.md (+5 -1)
📝 runtime/shims/d3d12_pipeline_compile.h (+183 -42)
📝 runtime/shims/d3d12_vulkan_device.cpp (+7 -3)
📝 runtime/src/vulkan_device_fault.h (+60 -9)
➕ runtime/test/d3d12_compile_pool_test.cpp (+536 -0)
📝 runtime/test/submit_mutex_test.cpp (+162 -3)

📄 Description

Claimed in the coordination issue as: RT-COMPILE-GATE-WARMUP-FREE (claim)

Depends on: #2233

This branch is #2233's branch plus one commit (e4713a440). Until #2233 lands, the diff against main shows its changes too.

What and why

The compile gate (SubmitMutex::CompileTurn, runtime/src/vulkan_device_fault.h) keeps a queue submission out of the driver while any pipeline create is in it. That covers warm-ups too, which nobody is waiting for. HasiKe's cold boots on an RTX 2070 SUPER (#2233) show the cost:

  • With the gate on, the title demanded about 6 builds in 300 s. About 290 s of serial warm-ups ran meanwhile, and the title crawled at about 1 submission a second.
  • With LEONIDA_COMPILE_GATE=0 it ran at about 100 frames a second.

MoonEyes measured the same in #1608 (07:32): 142 s of submission waits behind warm-ups, and game state 3 reached with the gate off. The gate must stay for demanded creates (the device losses it was added for), so this narrows it to them:

  • Submissions wait only for demanded creates. A create made by a compile worker's speculative job passes the gate as speculative (a warm-up, a prewarm from #2260, or the checkpoint). The worker sets the thread-local compile_job_speculative for the length of such a job, and DriverTurn passes it to CompileTurn. enter_submit waits only for the demanded creates in the driver. A warm-up's pipeline is simply not ready yet: a draw or dispatch that needs it builds it or waits for it, as before.
  • The creates beside a submission stay bounded:
    • A warm-up still never enters the driver while a submission is in it or waiting at the gate. A submission that is already waiting therefore keeps new warm-ups out.
    • At most LEONIDA_COMPILE_GATE_WARMUP_MAX warm-ups (default 1) are in the driver at once.
    • With #2233's pool there is at most one warm-up anyway, and none starts while a demanded build is queued or running. So while the title submits, the driver sees the demanded builds plus at most one warm-up.
  • Switches:
    • LEONIDA_COMPILE_GATE_WARMUPS=1 makes warm-ups hold the gate again, the behaviour before.
    • LEONIDA_COMPILE_GATE=0 still turns the whole gate off, unchanged.
  • Demanded builds on the title's thread (synchronous mode) and on the pool are unchanged: they hold the gate as before.

Risk, and why it is opt-out rather than opt-in: a submission can now be in the driver while one warm-up create runs. That is the case the gate was first added for (NVIDIA 630.20, a submission behind a long warm-up create lost the device). HasiKe has since corrected their own report: their TDR with the gate off at 249.7 s matches fiestorra's world-load GPU hang, which happens with no pipeline build at all, and says nothing about parallel creates. So no current measurement shows a create beside a submission losing the device. This pull request keeps that overlap to one warm-up at a time. HasiKe offered to run it on their card; the result decides whether the default stays.

Tested

  • submit_mutex_test (CPU), new case warmups_do_not_hold_the_gate:

    • a submission passes while a warm-up is in the driver (under 50 ms);
    • with a warm-up and a demanded create in the driver, the submission waits for the demanded one and not for the warm-up;
    • with max 1 and 2, four warm-ups never have more than max in the driver at once, and a demanded create does not wait for them;
    • a warm-up does not enter while a submission is in the driver;
    • with warm-ups held (LEONIDA_COMPILE_GATE_WARMUPS=1), a submission waits for a warm-up as before;
    • the settings parse.

    The earlier gate cases (a submission waits for a create, a create waits behind a waiting submission, creates share the gate) still pass.

  • d3d12_compile_pool_test, new case: a warm-up's and the checkpoint's jobs run with compile_job_speculative set, a demanded job without, also on a worker that ran a warm-up before (one worker and three).

  • Each gate rule was broken by hand in turn (4 mutants: warm-ups hold submissions, the policy ignored, no cap, a warm-up entering during a submission), and submit_mutex_test failed for every one.

  • With the change, these pass (15 of 15): submit_mutex, d3d12_compile_pool, d3d12_compile_teardown (pool and one worker), big_compile_gate, d3d12_big_compute (all 7 settings), d3d12_m4_compute, d3d12_pipeline_workers and d3d12_pipeline_workers_eager. A boot was running on this machine, so the full suite was not run.

  • python -I tests/test_docs_env_vars.py, tests/test_docs_repo_paths.py, scripts/check_no_game_data.py on the changed files: pass.

Not tested here: a real boot. A cold boot on HasiKe's card, and ours, with the gate on is the measurement that matters (submissions a second while warm-ups run, and whether the device stays).

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. (Stacked on #2233; main merges cleanly.)
  • 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/2275 **Author:** [@Tyrannys](https://github.com/Tyrannys) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `claude/compile-gate-warmup-free` --- ### 📝 Commits (3) - [`a83f385`](https://github.com/ubiquitarianism/leonida/commit/a83f38508f535a2de95a15f91071139de2c26fee) d3d12: a pool of compile workers for the pipeline compiler (RT-ASYNC-COMPILE-POOL) - [`2d56b68`](https://github.com/ubiquitarianism/leonida/commit/2d56b685ac69d0447cb5bb560e132ad354d8779d) d3d12: the checkpoint's second look also sees a running demanded build - [`e4713a4`](https://github.com/ubiquitarianism/leonida/commit/e4713a4408e7a64e1fcc0d0119d3731f82995c40) d3d12: warm-up creates no longer hold the compile gate (RT-COMPILE-GATE-WARMUP-FREE) ### 📊 Changes **8 files changed** (+991 additions, -58 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+26 -0) 📝 `runtime/CMakeLists.txt` (+12 -0) 📝 `runtime/README.md` (+5 -1) 📝 `runtime/shims/d3d12_pipeline_compile.h` (+183 -42) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+7 -3) 📝 `runtime/src/vulkan_device_fault.h` (+60 -9) ➕ `runtime/test/d3d12_compile_pool_test.cpp` (+536 -0) 📝 `runtime/test/submit_mutex_test.cpp` (+162 -3) </details> ### 📄 Description Claimed in the coordination issue as: RT-COMPILE-GATE-WARMUP-FREE ([claim](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7191251129)) Depends on: #2233 This branch is #2233's branch plus one commit (e4713a440). Until #2233 lands, the diff against `main` shows its changes too. ### What and why The compile gate (`SubmitMutex::CompileTurn`, `runtime/src/vulkan_device_fault.h`) keeps a queue submission out of the driver while any pipeline create is in it. That covers warm-ups too, which nobody is waiting for. HasiKe's cold boots on an RTX 2070 SUPER (#2233) show the cost: - With the gate on, the title demanded about 6 builds in 300 s. About 290 s of serial warm-ups ran meanwhile, and the title crawled at about 1 submission a second. - With `LEONIDA_COMPILE_GATE=0` it ran at about 100 frames a second. MoonEyes measured the same in #1608 (07:32): 142 s of submission waits behind warm-ups, and game state 3 reached with the gate off. The gate must stay for demanded creates (the device losses it was added for), so this narrows it to them: - **Submissions wait only for demanded creates.** A create made by a compile worker's speculative job passes the gate as speculative (a warm-up, a prewarm from #2260, or the checkpoint). The worker sets the thread-local `compile_job_speculative` for the length of such a job, and `DriverTurn` passes it to `CompileTurn`. `enter_submit` waits only for the demanded creates in the driver. A warm-up's pipeline is simply not ready yet: a draw or dispatch that needs it builds it or waits for it, as before. - **The creates beside a submission stay bounded:** - A warm-up still never enters the driver while a submission is in it or waiting at the gate. A submission that is already waiting therefore keeps new warm-ups out. - At most `LEONIDA_COMPILE_GATE_WARMUP_MAX` warm-ups (default 1) are in the driver at once. - With #2233's pool there is at most one warm-up anyway, and none starts while a demanded build is queued or running. So while the title submits, the driver sees the demanded builds plus at most one warm-up. - **Switches:** - `LEONIDA_COMPILE_GATE_WARMUPS=1` makes warm-ups hold the gate again, the behaviour before. - `LEONIDA_COMPILE_GATE=0` still turns the whole gate off, unchanged. - Demanded builds on the title's thread (synchronous mode) and on the pool are unchanged: they hold the gate as before. Risk, and why it is opt-out rather than opt-in: a submission can now be in the driver while one warm-up create runs. That is the case the gate was first added for (NVIDIA 630.20, a submission behind a long warm-up create lost the device). HasiKe has since corrected their own report: their TDR with the gate off at 249.7 s matches fiestorra's world-load GPU hang, which happens with no pipeline build at all, and says nothing about parallel creates. So no current measurement shows a create beside a submission losing the device. This pull request keeps that overlap to one warm-up at a time. HasiKe offered to run it on their card; the result decides whether the default stays. ### Tested - `submit_mutex_test` (CPU), new case `warmups_do_not_hold_the_gate`: - a submission passes while a warm-up is in the driver (under 50 ms); - with a warm-up and a demanded create in the driver, the submission waits for the demanded one and not for the warm-up; - with `max` 1 and 2, four warm-ups never have more than `max` in the driver at once, and a demanded create does not wait for them; - a warm-up does not enter while a submission is in the driver; - with warm-ups held (`LEONIDA_COMPILE_GATE_WARMUPS=1`), a submission waits for a warm-up as before; - the settings parse. The earlier gate cases (a submission waits for a create, a create waits behind a waiting submission, creates share the gate) still pass. - `d3d12_compile_pool_test`, new case: a warm-up's and the checkpoint's jobs run with `compile_job_speculative` set, a demanded job without, also on a worker that ran a warm-up before (one worker and three). - Each gate rule was broken by hand in turn (4 mutants: warm-ups hold submissions, the policy ignored, no cap, a warm-up entering during a submission), and `submit_mutex_test` failed for every one. - With the change, these pass (15 of 15): `submit_mutex`, `d3d12_compile_pool`, `d3d12_compile_teardown` (pool and one worker), `big_compile_gate`, `d3d12_big_compute` (all 7 settings), `d3d12_m4_compute`, `d3d12_pipeline_workers` and `d3d12_pipeline_workers_eager`. A boot was running on this machine, so the full suite was not run. - `python -I tests/test_docs_env_vars.py`, `tests/test_docs_repo_paths.py`, `scripts/check_no_game_data.py` on the changed files: pass. Not tested here: a real boot. A cold boot on HasiKe's card, and ours, with the gate on is the measurement that matters (submissions a second while warm-ups run, and whether the device stays). 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. (Stacked on #2233; `main` merges cleanly.) - [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#2279
No description provided.