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

Open
github-bot wants to merge 3 commits from github-bot/gh-2275 into main AGit
Owner

@⁠Tyrannys on GitHub · 2026-11-26 12:06 UTC · original
Tyrannys:claude/compile-gate-warmup-free → main · +991 −58 · 8 files · 3 commits · open

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

**@⁠Tyrannys** on GitHub · 2026-11-26 12:06 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2275) `Tyrannys:claude/compile-gate-warmup-free` → `main` · +991 −58 · 8 files · 3 commits · open Claimed in the coordination issue as: RT-COMPILE-GATE-WARMUP-FREE ([claim](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608)) 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)
With LEONIDA_ASYNC_PIPELINES=1 every demanded build, the compute warm-up and
the cache checkpoint ran on one general worker (plus a graphics-only one), so
one long driver compile held every pipeline a submission asked for behind it,
and their draws and dispatches were skipped meanwhile.

PipelineCompiler now runs LEONIDA_COMPILE_THREADS workers (half the logical
processors, 2 to 8). A worker takes the most urgent job it may:
- demanded builds first, in the order they came, then warm-ups by size, then
  the checkpoint, which waits until no worker compiles;
- large builds (compute over 128 KiB, graphics of 1 MiB or more) and warm-ups
  together take at most threads-1 workers, so one stays free for a small
  demanded build; at most LEONIDA_COMPILE_HEAVY_MAX large builds at once
  (default threads-1, 1 with LEONIDA_SERIAL_BIG_COMPILES=1), compute and
  graphics alike, each still within the memory gate;
- warm-ups run one at a time, and none starts while a demanded build runs:
  each holds the compile gate for its whole create, and a submission waits
  for every create in flight;
- one build of a PSO at a time, so after_running and the teardown rules hold.

LEONIDA_COMPILE_THREADS=1 keeps the layout before the pool. The design is
MoonEyes' (#2077), ported onto #2098's scheduler.

Tests: d3d12_compile_pool (CPU, jobs held at gates: settings, a long build
does not hold up a small demanded one, heavy count, free worker, warm-ups one
at a time and after demanded builds, order, one job per PSO, release/cancel/
stop_for_exit with jobs in flight), and d3d12_compile_teardown also with one
worker.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The startup cache checkpoint starts only when no compile worker is busy, but a
demanded build can start on another worker while the checkpoint queries the
cache size. has_compile_waiter() only looked at the queue, so the check after
the size query went on to read the cache blob while that build ran.
has_compile_waiter() now also answers true while a demanded build runs.

New gated test in d3d12_compile_pool_test: the checkpoint waits at a gate
standing in for the size query, a demanded build starts on the second worker,
and the second look must see it. It fails without the fix.

Reported by lixonik in review of #2233.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A queue submission waited at the compile gate for every pipeline create in
the driver, warm-ups included. On a cold boot (HasiKe, RTX 2070 SUPER, #2233)
the title crawled at about one submission a second behind 290 s of serial
warm-ups; with the gate off it ran at about 100 frames a second.

A compile worker now marks its speculative jobs (warm-ups, prewarms, the
checkpoint) with the thread-local compile_job_speculative, and DriverTurn
passes that to SubmitMutex::CompileTurn. A submission waits only for the
demanded creates in the driver. A warm-up still never enters while a
submission is in the driver or waiting at the gate, and at most
LEONIDA_COMPILE_GATE_WARMUP_MAX (default 1) warm-ups are in the driver at
once, so the creates beside a submission stay bounded.
LEONIDA_COMPILE_GATE_WARMUPS=1 restores the old behaviour;
LEONIDA_COMPILE_GATE=0 still turns the gate off.

Tests: submit_mutex_test gets warmups_do_not_hold_the_gate (a submission
passes a warm-up, still waits for a demanded create, the warm-up cap, no
warm-up during a submission, the old policy, the settings);
d3d12_compile_pool_test checks which jobs run as speculative.

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

@⁠Tyrannys on GitHub · 2026-11-26 12:22 UTC · original

One boot with this PR and the compile gate on: RTX 4070 SUPER (12 GB), NVIDIA 621.01, Windows 11, 64 GB. Counts only.

Tree: main a73a57e13 + #1851 #1905 #1957 #1886 #1894 #1914 #1882 #2195 #2113 #1592 #2097 + #2233 #2179 #2228, #2260 at 6f2b52e56, and this PR (all clean merges). Recipe: async pipelines, prewarm from the previous run's order log (846 graphics pipelines planned), a local skip list of the 1,009 ray-hit shading programs, LEONIDA_RT_AS=off, LEONIDA_DEVICE_FAULT=0, the watchdog kicked, LEONIDA_ARENA_MB=1536, LEONIDA_TITLE_WINDOWS_MB=1024, warm offline, heavy and journal caches. LEONIDA_COMPILE_GATE unset (on), LEONIDA_COMPILE_GATE_WARMUP_MAX default.

F3 (gate on, before #2233/#2275, my #1608 runs) F6 (gate off) F7 (gate on + this PR)
game state 3 at 260 s 110 s 95 s
submissions during the load (60-100 s) - - 27-36/s, 13-18 frames/s
gate waits by a submission - - 41, 909 ms in all, longest 117 ms
end title crash at 1,093 s title crash at 1,544 s device lost at 270 s (vkQueueWaitIdle), then exit 0xC0000005 at 291 s
  • With the gate on, the load is now as fast as with it off. Submissions waited less than 1 s in all, against 142 s in MoonEyes' gate-on run.
  • The device loss came about 25 s after world entry. At that moment the HUD showed VRAM over the budget (12.2 GB used against 10.6 GB), as in every world run on this 12 GB card. LEONIDA_DEVICE_FAULT was 0, so there is no fault report. With one run, I can't tell whether a submission running beside a warm-up create played a part. None of my gate-off runs lost the device. The next run here repeats F7 with LEONIDA_DEVICE_FAULT=1.
  • 320 builds ran on the dispatch workers. Compute warm-ups over 128 KiB were left to first use from t=76 s (LEONIDA_COMPUTE_WARMUP_LIVE_MAX_BYTES=131072).

AI-assisted (Claude Code).

**@⁠Tyrannys** on GitHub · 2026-11-26 12:22 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2275#issuecomment-7191909636) One boot with this PR and the compile gate **on**: RTX 4070 SUPER (12 GB), NVIDIA 621.01, Windows 11, 64 GB. Counts only. **Tree:** `main` a73a57e13 + #1851 #1905 #1957 #1886 #1894 #1914 #1882 #2195 #2113 #1592 #2097 + #2233 #2179 #2228, #2260 at 6f2b52e56, and this PR (all clean merges). **Recipe:** async pipelines, prewarm from the previous run's order log (846 graphics pipelines planned), a local skip list of the 1,009 ray-hit shading programs, `LEONIDA_RT_AS=off`, `LEONIDA_DEVICE_FAULT=0`, the watchdog kicked, `LEONIDA_ARENA_MB=1536`, `LEONIDA_TITLE_WINDOWS_MB=1024`, warm offline, heavy and journal caches. `LEONIDA_COMPILE_GATE` unset (on), `LEONIDA_COMPILE_GATE_WARMUP_MAX` default. | | F3 (gate on, before #2233/#2275, my #1608 runs) | F6 (gate off) | F7 (gate on + this PR) | |---|---|---|---| | game state 3 at | 260 s | 110 s | **95 s** | | submissions during the load (60-100 s) | - | - | 27-36/s, 13-18 frames/s | | gate waits by a submission | - | - | 41, 909 ms in all, longest 117 ms | | end | title crash at 1,093 s | title crash at 1,544 s | **device lost at 270 s** (`vkQueueWaitIdle`), then exit 0xC0000005 at 291 s | - With the gate on, the load is now as fast as with it off. Submissions waited less than 1 s in all, against 142 s in MoonEyes' gate-on run. - The device loss came about 25 s after world entry. At that moment the HUD showed VRAM over the budget (12.2 GB used against 10.6 GB), as in every world run on this 12 GB card. `LEONIDA_DEVICE_FAULT` was 0, so there is no fault report. With one run, I can't tell whether a submission running beside a warm-up create played a part. None of my gate-off runs lost the device. The next run here repeats F7 with `LEONIDA_DEVICE_FAULT=1`. - 320 builds ran on the dispatch workers. Compute warm-ups over 128 KiB were left to first use from t=76 s (`LEONIDA_COMPUTE_WARMUP_LIVE_MAX_BYTES=131072`). AI-assisted (Claude Code).
Author
Owner

@⁠Tyrannys on GitHub · 2026-11-26 12:32 UTC · original

Second run with this PR, the same recipe and the gate on, with LEONIDA_DEVICE_FAULT=1 (F7b). It never reached the world.

  • Up to ~200 s it matched F7. Then the submissions stalled behind pipeline creates the title had asked for (dispatch-worker builds of library compute programs of 130-150 KB, not warm-ups). The last gate summary, at 518 s, says: "56 submissions waited for pipeline creates (310559 ms in all, longest 33414 ms); 67 creates waited behind a submission (169458 ms in all, longest 9845 ms)". The device-stall watcher logged "could not sample the submit lock (its holder waits at the compile gate) for 15 s" 8 times.
  • Indirect graphics at the end: recorded 5,517, emitted 2,048. That is the load, not the world (world runs here reach 65,536 emitted). No device loss. I stopped it at 542 s.
  • So with the gate on, demanded builds can still hold submissions for tens of seconds at a time on this machine. Of 2 runs with the gate on, one lost the device at 270 s (F7) and one stalled (F7b). With the gate off, 4 of 4 recent runs on the same caches reached the world (F3g, F4a, F4b, F6). I'm going back to LEONIDA_COMPILE_GATE=0 here.

AI-assisted (Claude Code).

**@⁠Tyrannys** on GitHub · 2026-11-26 12:32 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2275#issuecomment-7192126329) Second run with this PR, the same recipe and the gate on, with `LEONIDA_DEVICE_FAULT=1` (F7b). It never reached the world. - Up to ~200 s it matched F7. Then the submissions stalled behind pipeline creates the title had asked for (dispatch-worker builds of library compute programs of 130-150 KB, not warm-ups). The last gate summary, at 518 s, says: "56 submissions waited for pipeline creates (310559 ms in all, longest 33414 ms); 67 creates waited behind a submission (169458 ms in all, longest 9845 ms)". The device-stall watcher logged "could not sample the submit lock (its holder waits at the compile gate) for 15 s" 8 times. - Indirect graphics at the end: recorded 5,517, emitted 2,048. That is the load, not the world (world runs here reach 65,536 emitted). No device loss. I stopped it at 542 s. - So with the gate on, demanded builds can still hold submissions for tens of seconds at a time on this machine. Of 2 runs with the gate on, one lost the device at 270 s (F7) and one stalled (F7b). With the gate off, 4 of 4 recent runs on the same caches reached the world (F3g, F4a, F4b, F6). I'm going back to `LEONIDA_COMPILE_GATE=0` here. AI-assisted (Claude Code).
Author
Owner

@⁠HasiKe on GitHub · 2026-11-26 12:33 UTC · original

@⁠Tyrannys, here is the cold boot you asked for, with the gate on, on the RTX 2070 SUPER. AI-assisted (Claude Code).

Tree: main a73a57e13 + #2195 + #2233 + this PR (e4713a440, a clean merge). There is also a local diagnostic patch of mine, LEONIDA_SKIP_GRAPHICS, which was not set in these runs. d3d12_compile_pool_test and the other compile/submit tests pass.

Setup: NVIDIA 616.56, Windows 11 Pro 26300, my own 1.0.2.1 package. One binary for both runs, A/B via LEONIDA_COMPILE_GATE_WARMUPS=1. Both boots were cold: no session or seed cache, an empty journal and their own empty __GL_SHADER_DISK_CACHE_PATH. Settings: LEONIDA_ASYNC_PIPELINES=1, gate on (LEONIDA_COMPILE_GATE unset), LEONIDA_DEVICE_FAULT=2, the watchdog kicked, LEONIDA_CONSOLE_FIX_US=0, 4096 MB title windows and arena, the keyboard pad, 300 s each.

this PR (warm-ups free) LEONIDA_COMPILE_GATE_WARMUPS=1 (old)
warm-ups built 1,131, 284.4 s in all (12 over 2 s, max 5.5 s) 1,156, 290.3 s in all (10 over 2 s, max 6.9 s)
demanded builds 6 6
submissions waiting at the gate, at the last summary 1, 159 ms (a demanded dispatch-worker create at 28 s) 841, 264.6 s in all, the longest 6.9 s (t=294 s)
creates that waited behind a submission 0 1, 0 ms
submissions in 300 s 74,012 745
submissions/s and frames/s, steady 280-300/s, 140-150 frames/s from 45 s on 1.4-5/s, 0.8-2.6 frames/s
device loss none none

So, on this card:

  • The warm-ups compile just as long in both runs, about 285-290 s.
  • With this PR, though, the title is no longer behind them. It reaches the same 140-150 frames/s that a warm-cache boot gets here, about 45 s after launch.
  • In the old run, the gate summary accounts for the crawl directly: 264 s of submit waiting in 294 s of boot. My earlier reading, that the warm-ups at the gate caused it, now has its measurement.
  • The warm-up cap of one did not cost the title anything visible: the next demanded build waited 0 ms behind one.

Neither boot reached the world. My input script only enters it at 314 s. So this says nothing about the world-load hang. That hang is a separate problem, a VS-as-mesh-shader draw that never finishes on the GPU (#1608, follow-up), and it also happens with the gate off.

The cold boot on this machine goes from unusable to normal speed, so this PR looks like a clear win to me.

**@⁠HasiKe** on GitHub · 2026-11-26 12:33 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2275#issuecomment-7192146160) @⁠Tyrannys, here is the cold boot you asked for, with the gate on, on the RTX 2070 SUPER. AI-assisted (Claude Code). **Tree:** `main` `a73a57e13` + #2195 + #2233 + this PR (`e4713a440`, a clean merge). There is also a local diagnostic patch of mine, `LEONIDA_SKIP_GRAPHICS`, which was not set in these runs. `d3d12_compile_pool_test` and the other compile/submit tests pass. **Setup:** NVIDIA 616.56, Windows 11 Pro 26300, my own 1.0.2.1 package. One binary for both runs, A/B via `LEONIDA_COMPILE_GATE_WARMUPS=1`. Both boots were cold: no session or seed cache, an empty journal and their own empty `__GL_SHADER_DISK_CACHE_PATH`. Settings: `LEONIDA_ASYNC_PIPELINES=1`, gate on (`LEONIDA_COMPILE_GATE` unset), `LEONIDA_DEVICE_FAULT=2`, the watchdog kicked, `LEONIDA_CONSOLE_FIX_US=0`, 4096 MB title windows and arena, the keyboard pad, 300 s each. | | this PR (warm-ups free) | `LEONIDA_COMPILE_GATE_WARMUPS=1` (old) | |---|---|---| | warm-ups built | 1,131, 284.4 s in all (12 over 2 s, max 5.5 s) | 1,156, 290.3 s in all (10 over 2 s, max 6.9 s) | | demanded builds | 6 | 6 | | submissions waiting at the gate, at the last summary | 1, 159 ms (a demanded `dispatch-worker` create at 28 s) | **841, 264.6 s in all, the longest 6.9 s** (t=294 s) | | creates that waited behind a submission | 0 | 1, 0 ms | | submissions in 300 s | **74,012** | 745 | | submissions/s and frames/s, steady | 280-300/s, 140-150 frames/s from 45 s on | 1.4-5/s, 0.8-2.6 frames/s | | device loss | none | none | So, on this card: - The warm-ups compile just as long in both runs, about 285-290 s. - With this PR, though, the title is no longer behind them. It reaches the same 140-150 frames/s that a warm-cache boot gets here, about 45 s after launch. - In the old run, the gate summary accounts for the crawl directly: 264 s of submit waiting in 294 s of boot. My earlier reading, that the warm-ups at the gate caused it, now has its measurement. - The warm-up cap of one did not cost the title anything visible: the next demanded build waited 0 ms behind one. Neither boot reached the world. My input script only enters it at 314 s. So this says nothing about the world-load hang. That hang is a separate problem, a VS-as-mesh-shader draw that never finishes on the GPU ([#1608, follow-up](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608)), and it also happens with the gate off. The cold boot on this machine goes from unusable to normal speed, so this PR looks like a clear win to me.
Author
Owner

@⁠qhukz13 on GitHub · 2026-11-26 14:29 UTC · original

I checked e4713a440 merged onto main 73516a290 (no conflicts) on Windows 10 / MSVC 14.44, GTX 1050 Ti host. d3d12_compile_pool_test and submit_mutex_test pass 2/2, plain and with LEONIDA_VK_VALIDATION=1, three repeats each.

The production switch has no test. Only one line passes "this create is speculative" to the gate in the runtime: d3d12_pipeline_compile.h:168, gate_.emplace(submits, compile_job_speculative);. I replaced it with gate_.emplace(submits);, which is exactly main's behaviour: every warm-up holds the gate again. Then I rebuilt gta6rt, d3d12_compile_pool_test and submit_mutex_test:

  • everything builds;
  • both tests still pass, 2/2.

submit_mutex_test drives SubmitMutex::CompileTurn(m, true) directly. d3d12_compile_pool_test checks that compile_job_speculative is set for a warm-up and for the checkpoint. Nothing constructs a DriverTurn (git grep DriverTurn runtime/test/ finds only a comment at d3d12_compile_pool_test.cpp:356). So the one line that turns the feature on in the game is untested. A small test would close it:

  • a DriverTurn with a pipeline, made while compile_job_speculative is true;
  • a SubmitTurn on the same gate must then not wait;
  • and it must wait once the flag is false.

Docs that no longer match:

  • runtime/README.md:418 (LEONIDA_COMPILE_GATE) still says unset means the workers compile while other queues submit, and 1 opts into holding the lock. compile_gate_enabled() (vulkan_device_fault.h:434-440) has the gate on unless the variable is 0, which is what the next row says. Was this row already stale on main?
  • docs/d3d12_vulkan.md around 2617-2619 and 2635-2636 still says, in the present tense, that a compute warm-up holds the gate for its whole create and every submission waits behind it. The new paragraph between them says the opposite by default.
  • The new row and the comment at d3d12_pipeline_compile.h:145 say a prewarm and the checkpoint also pass as speculative. No prewarm exists on main (that is #2260). save_session_pipeline_cache does no pipeline create and never enters DriverTurn. So only compute warm-ups are actually affected today.

The risk is stated well. A submission can now be in the driver beside one warm-up create. That is the NVIDIA 630.20 case the gate was added for. It is capped at one at a time (LEONIDA_COMPILE_GATE_WARMUP_MAX, and PipelineCompiler::next_locked already starts one warm-up at a time), and LEONIDA_COMPILE_GATE_WARMUPS=1 restores the old behaviour. I have no world boot on this card yet, so I can't add a measurement.

The code reading behind these points was done with a second agent and checked line by line before writing this.

AI-assisted (Claude Code, with Antigravity / Gemini 4 Neon).

**@⁠qhukz13** on GitHub · 2026-11-26 14:29 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2275#issuecomment-7194897141) I checked `e4713a440` merged onto main `73516a290` (no conflicts) on Windows 10 / MSVC 14.44, GTX 1050 Ti host. `d3d12_compile_pool_test` and `submit_mutex_test` pass 2/2, plain and with `LEONIDA_VK_VALIDATION=1`, three repeats each. **The production switch has no test.** Only one line passes "this create is speculative" to the gate in the runtime: `d3d12_pipeline_compile.h:168`, `gate_.emplace(submits, compile_job_speculative);`. I replaced it with `gate_.emplace(submits);`, which is exactly main's behaviour: every warm-up holds the gate again. Then I rebuilt `gta6rt`, `d3d12_compile_pool_test` and `submit_mutex_test`: - everything builds; - **both tests still pass, 2/2.** `submit_mutex_test` drives `SubmitMutex::CompileTurn(m, true)` directly. `d3d12_compile_pool_test` checks that `compile_job_speculative` is set for a warm-up and for the checkpoint. Nothing constructs a `DriverTurn` (`git grep DriverTurn runtime/test/` finds only a comment at `d3d12_compile_pool_test.cpp:356`). So the one line that turns the feature on in the game is untested. A small test would close it: - a `DriverTurn` with a pipeline, made while `compile_job_speculative` is true; - a `SubmitTurn` on the same gate must then not wait; - and it must wait once the flag is false. **Docs that no longer match:** - `runtime/README.md:418` (`LEONIDA_COMPILE_GATE`) still says unset means the workers compile while other queues submit, and `1` opts into holding the lock. `compile_gate_enabled()` (`vulkan_device_fault.h:434-440`) has the gate on unless the variable is `0`, which is what the next row says. Was this row already stale on main? - `docs/d3d12_vulkan.md` around 2617-2619 and 2635-2636 still says, in the present tense, that a compute warm-up holds the gate for its whole create and every submission waits behind it. The new paragraph between them says the opposite by default. - The new row and the comment at `d3d12_pipeline_compile.h:145` say a prewarm and the checkpoint also pass as speculative. No prewarm exists on main (that is #2260). `save_session_pipeline_cache` does no pipeline create and never enters `DriverTurn`. So only compute warm-ups are actually affected today. **The risk is stated well.** A submission can now be in the driver beside one warm-up create. That is the NVIDIA 630.20 case the gate was added for. It is capped at one at a time (`LEONIDA_COMPILE_GATE_WARMUP_MAX`, and `PipelineCompiler::next_locked` already starts one warm-up at a time), and `LEONIDA_COMPILE_GATE_WARMUPS=1` restores the old behaviour. I have no world boot on this card yet, so I can't add a measurement. The code reading behind these points was done with a second agent and checked line by line before writing this. AI-assisted (Claude Code, with Antigravity / Gemini 4 Neon).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2275/head:github-bot/gh-2275'
git switch 'github-bot/gh-2275'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2275'
git switch 'github-bot/gh-2275'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2275'
git switch 'github-bot/gh-2275'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2275'
git switch 'main'
git merge --squash 'github-bot/gh-2275'
git switch 'main'
git merge --ff-only 'github-bot/gh-2275'
git switch 'main'
git merge 'github-bot/gh-2275'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.