compile gate: adaptive per kind of create, re-armed by a held submission (RT-COMPILE-GATE-ADAPTIVE) #2412

Open
github-bot wants to merge 6 commits from github-bot/gh-2412 into main AGit
Owner

@⁠OreoFR on GitHub · 2026-11-26 23:42 UTC · original
OreoFR:fix/compile-gate-bounded → main · +1182 −65 · 9 files · 6 commits · open

Claimed in the coordination issue as: RT-COMPILE-GATE-ADAPTIVE

Depends on: none. It conflicts textually with #2275 (RT-COMPILE-GATE-WARMUP-FREE, same SubmitMutex code). Whichever lands second takes both; I will rebase on #2275 if it goes first.

What and why

The compile gate (#2098, SubmitMutex in runtime/src/vulkan_device_fault.h) holds every queue submission while a pipeline create is in the driver, however long the create takes. It was measured on NVIDIA 630.20, where a submit that enters beside a long compute create is lost after about 10 s. On other drivers it mostly costs time:

  • RTX 4070 Laptop, NVIDIA 621.40: one demanded 2.3 MB library compute create sat 54+ s in the driver. No submission went through, the title's fence stopped, and its hang watchdog ended the run (+0x23cf683).
  • @⁠MoonEyes, RTX 4060, NVIDIA 610.88, watchdog kicked: 814,287 ms of 895 s (91 % of the run) waiting behind creates, mostly small warm-up programs. The gate never let go.

Also found: on main, graphics and mesh creates never went through the gate. Only vkCreateComputePipelines did; PipelineState::build called the driver directly. On 621.40 that is where the hazard actually showed:

  • with the gate off, a cold 541 KB mesh pipeline create took 55.7 s, a submit sat 54.2 s in the driver beside it, then VK_ERROR_DEVICE_LOST;
  • in another run, a submit sat 7.8 s beside a 1.78 MB mesh create, then the same loss.

What this changes

The gate becomes adaptive, with one verdict per kind of create (compute, graphics including mesh). Graphics creates now go through the gate too.

  • Bounded wait while a kind is undecided. A submission goes ahead once the gate waits of the last 10 s add up to LEONIDA_COMPILE_GATE_PROBE_MS (2,500 ms by default), or after LEONIDA_COMPILE_GATE_WAIT_MS (15 s) for one wait. That submission is a probe.
  • Verdict. Two quick probes, each under 250 ms and at least 1 s apart, with a create of that kind still in the driver when they return, turn the gate off for that kind for the rest of the run. A probe held 2 s or more marks the kind as holding: submissions then wait for its creates however long they take. The bounded go-ahead never enters beside a create of a holding kind.
  • Re-arm. A kind that is off is still timed. A submission that stays 2 s or more in the driver beside one of its creates turns that kind back on, logged once.
  • Device-loss report. On the first device loss, VulkanContext::mark_device_lost logs the gate state per kind and every create in the driver: kind, program, bytes, trigger, thread, time in the driver.
  • Switches.
    • LEONIDA_COMPILE_GATE unset: adaptive (new default).
    • =1: the old gate. It always waits with no limit, never probes, and compute builds hold the submit lock.
    • =0: off.
    • LEONIDA_COMPILE_GATE_WAIT_MS=0: waits with no limit.
    • runtime/README.md and docs/d3d12_vulkan.md describe them. The README row for LEONIDA_COMPILE_GATE also had the default wrong.
  • Tradeoff on a driver that holds (630.20). The first probe of a kind now enters the driver after about 2.5 s of waiting instead of never. If that create then stays another 10 s, that driver loses the device, at most once per run per kind: the probe returns a held verdict 2 s in. LEONIDA_COMPILE_GATE=1 keeps the old protection.

Tested

  • submit_mutex ctest passes with the gate unset, with =1, with =0 and with WAIT_MS=0. It has new cases for the bounded wait, the probe budget, the adaptive switch, per-kind verdicts, re-arm and the loss report. scripts/check_no_game_data.py is clean on all changed files.
  • Retail story load, RTX 4070 Laptop 8 GB, NVIDIA 621.40, shaders retranslated with main, runs of 450-600 s:
Build / gate Waiting behind creates Result
main gate (=1) 130 s, longest 21.7 s no loss in that run; stalls up to 14.5 s
bounded only, 15 s limit 90 s of 3-7 s waits back to back watchdog at 433 s, gate never adapted
adaptive, compute only (a3404f5a4) 2.6 s off at 279 s, no loss in 450 s (one other run: loss beside an ungated mesh create)
this PR (f7b249730) on main d1dff7949 5.2 s graphics off at 199 s (581 probes ≤ 112 ms), compute off at 250 s (1,969 probes ≤ 11 ms), no device loss
  • @⁠MoonEyes, RTX 4060, NVIDIA 610.88, on a3404f5a4: off at 53.6 s after 133 probes ≤ 12 ms, 4,800 ms of waiting instead of 814,287 ms, 900 s with no device loss.
  • Not seen in a game yet: a re-arm, and a held verdict for graphics. Both need a cold create that holds a submission, and the long mesh creates were cached by then. They are covered by the unit test only. More runs on other GPUs (RTX 5070, RTX 5080) are coming, and I will add them here.

GPUs tested: NVIDIA GeForce RTX 4070 Laptop 8 GB, driver 621.40, Windows 11; NVIDIA GeForce RTX 4060, driver 610.88, Windows (MoonEyes).

AI-assisted: yes (Claude Code, Claude Opus 5.5)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • 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: runtime only)

🤖 Generated with Claude Code

**@⁠OreoFR** on GitHub · 2026-11-26 23:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2412) `OreoFR:fix/compile-gate-bounded` → `main` · +1182 −65 · 9 files · 6 commits · open Claimed in the coordination issue as: [RT-COMPILE-GATE-ADAPTIVE](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) Depends on: none. It conflicts textually with #2275 (RT-COMPILE-GATE-WARMUP-FREE, same `SubmitMutex` code). Whichever lands second takes both; I will rebase on #2275 if it goes first. ### What and why The compile gate (#2098, `SubmitMutex` in `runtime/src/vulkan_device_fault.h`) holds every queue submission while a pipeline create is in the driver, however long the create takes. It was measured on NVIDIA 630.20, where a submit that enters beside a long compute create is lost after about 10 s. On other drivers it mostly costs time: - RTX 4070 Laptop, NVIDIA 621.40: one demanded 2.3 MB library compute create sat 54+ s in the driver. No submission went through, the title's fence stopped, and its hang watchdog ended the run (`+0x23cf683`). - @⁠MoonEyes, RTX 4060, NVIDIA 610.88, watchdog kicked: 814,287 ms of 895 s (91 % of the run) waiting behind creates, mostly small warm-up programs. The gate never let go. Also found: on `main`, **graphics and mesh creates never went through the gate**. Only `vkCreateComputePipelines` did; `PipelineState::build` called the driver directly. On 621.40 that is where the hazard actually showed: - with the gate off, a cold 541 KB mesh pipeline create took 55.7 s, a submit sat 54.2 s in the driver beside it, then `VK_ERROR_DEVICE_LOST`; - in another run, a submit sat 7.8 s beside a 1.78 MB mesh create, then the same loss. ### What this changes The gate becomes adaptive, with one verdict per kind of create (compute, graphics including mesh). Graphics creates now go through the gate too. - **Bounded wait while a kind is undecided.** A submission goes ahead once the gate waits of the last 10 s add up to `LEONIDA_COMPILE_GATE_PROBE_MS` (2,500 ms by default), or after `LEONIDA_COMPILE_GATE_WAIT_MS` (15 s) for one wait. That submission is a probe. - **Verdict.** Two quick probes, each under 250 ms and at least 1 s apart, with a create of that kind still in the driver when they return, turn the gate off for that kind for the rest of the run. A probe held 2 s or more marks the kind as holding: submissions then wait for its creates however long they take. The bounded go-ahead never enters beside a create of a holding kind. - **Re-arm.** A kind that is off is still timed. A submission that stays 2 s or more in the driver beside one of its creates turns that kind back on, logged once. - **Device-loss report.** On the first device loss, `VulkanContext::mark_device_lost` logs the gate state per kind and every create in the driver: kind, program, bytes, trigger, thread, time in the driver. - **Switches.** - `LEONIDA_COMPILE_GATE` unset: adaptive (new default). - `=1`: the old gate. It always waits with no limit, never probes, and compute builds hold the submit lock. - `=0`: off. - `LEONIDA_COMPILE_GATE_WAIT_MS=0`: waits with no limit. - `runtime/README.md` and `docs/d3d12_vulkan.md` describe them. The README row for `LEONIDA_COMPILE_GATE` also had the default wrong. - **Tradeoff on a driver that holds (630.20).** The first probe of a kind now enters the driver after about 2.5 s of waiting instead of never. If that create then stays another 10 s, that driver loses the device, at most once per run per kind: the probe returns a held verdict 2 s in. `LEONIDA_COMPILE_GATE=1` keeps the old protection. ### Tested - `submit_mutex` ctest passes with the gate unset, with `=1`, with `=0` and with `WAIT_MS=0`. It has new cases for the bounded wait, the probe budget, the adaptive switch, per-kind verdicts, re-arm and the loss report. `scripts/check_no_game_data.py` is clean on all changed files. - Retail story load, RTX 4070 Laptop 8 GB, NVIDIA 621.40, shaders retranslated with `main`, runs of 450-600 s: | Build / gate | Waiting behind creates | Result | |---|---|---| | `main` gate (=1) | 130 s, longest 21.7 s | no loss in that run; stalls up to 14.5 s | | bounded only, 15 s limit | 90 s of 3-7 s waits back to back | watchdog at 433 s, gate never adapted | | adaptive, compute only (`a3404f5a4`) | 2.6 s | off at 279 s, no loss in 450 s (one other run: loss beside an ungated mesh create) | | **this PR (`f7b249730`)** on `main` `d1dff7949` | **5.2 s** | graphics off at 199 s (581 probes ≤ 112 ms), compute off at 250 s (1,969 probes ≤ 11 ms), no device loss | - @⁠MoonEyes, RTX 4060, NVIDIA 610.88, on `a3404f5a4`: off at 53.6 s after 133 probes ≤ 12 ms, 4,800 ms of waiting instead of 814,287 ms, 900 s with no device loss. - **Not seen in a game yet:** a re-arm, and a held verdict for graphics. Both need a cold create that holds a submission, and the long mesh creates were cached by then. They are covered by the unit test only. More runs on other GPUs (RTX 5070, RTX 5080) are coming, and I will add them here. GPUs tested: NVIDIA GeForce RTX 4070 Laptop 8 GB, driver 621.40, Windows 11; NVIDIA GeForce RTX 4060, driver 610.88, Windows (MoonEyes). AI-assisted: yes (Claude Code, Claude Opus 5.5) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [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: runtime only) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The gate keeps vkQueueSubmit out of the driver while a pipeline create is
in it (on NVIDIA 630.20 a submission that entered during a long compute
create waited 10 s in the driver and lost the device). The waiter holds the
submit lock, so every queue stops behind it: on an RTX 4070 Laptop (NVIDIA
621.40) one compute create stayed in the driver for over 54 s during the
story load and the title's 30 s hang watchdog ended the process.

A submission now goes ahead after LEONIDA_COMPILE_GATE_WAIT_MS (15 s by
default; 0: no limit). The creates in the driver then hold no later
submission back; creates that enter afterwards are waited for again. On
630.20 that only gives up creates over 25 s (15 s here plus the driver's
10 s), which the watchdog ends anyway. With the watchdog kept kicked
(LEONIDA_TITLE_WATCHDOG=0 and LEONIDA_TITLE_WATCHDOG_KICK) the default stays
no limit. The log names each submission that goes ahead and how long it then
spent in the driver. The README row, which still described the gate as
opt-in, now says it is on by default.

Tested: submit_mutex (new gate_wait_limit case), MSVC, Windows 11.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With the bounded wait, the three submissions that went ahead on NVIDIA
621.40 came back from the driver in 11, 1 and 0 ms with the create still
there, but consecutive long creates made submissions wait the full 15 s
again and the title's watchdog still ended the run.

Every submission that enters the driver next to a create the gate went
past at the limit is now a probe. Two that come back in under 250 ms, at
least 1 s apart, with that create still in the driver turn the gate off for
the rest of the run; one that stays 2 s or more keeps it on. Both verdicts
are logged once. Two probes a second apart, because on 630.20 back-to-back
creates take and release the driver's lock and one submission could slip
in between; the second costs no extra wait. LEONIDA_COMPILE_GATE=1 gates
always without probing (and compute builds keep holding the submit lock),
=0 has no gate. The README row now says what =1 does again.

Tested: submit_mutex (new gate_adapts case; also under
LEONIDA_COMPILE_GATE=1 and =0), MSVC, Windows 11.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The adaptive gate never probed in two runs because no single wait reached
the 15 s limit: on NVIDIA 621.40, 80 waits of 3-7 s back to back (90 s in
all) kept the title's main loop from reporting for 30 s and its watchdog
ended the run; on an RTX 4060 with the watchdog kept kicked the limit was
0, so nothing could probe, and 459 waits of up to 2.9 s took 155 s by
t=202 s.

Until a verdict is in, a submission now also goes ahead once the waits at
the gate in the last 10 s, its own included, add up to
LEONIDA_COMPILE_GATE_PROBE_MS (2500 ms). A budget over a window rather
than a shorter per-wait limit, because it also counts many short waits and
a single wait reaches it as soon as a 2.5 s limit would; before the
verdict the gate stops the queues for at most about a quarter of any 10 s.
On a driver that holds submissions (630.20) the first probe enters after
2.5 s instead of 15 s and loses the device if the create stays 10 s more;
the held verdict (still 2 s, inside those 10 s) ends the early probes and
leaves only the per-wait limit, so that is one probe per run.

The limit and the budget no longer depend on the title's watchdog. Only
LEONIDA_COMPILE_GATE_WAIT_MS=0 (the budget then defaults to 0) or
LEONIDA_COMPILE_GATE=1 (no limit by default, never probes) waits however
long the creates take.

Tested: submit_mutex (new gate_probe_budget case; also under
LEONIDA_COMPILE_GATE=1 and =0, with the watchdog variables set, and with
LEONIDA_COMPILE_GATE_WAIT_MS=0), MSVC, Windows 11.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
On NVIDIA 621.40 every probe beside a compute create came back in 0-12 ms,
but a run whose gate those probes had turned off lost the device 9 s later
with a submission held 7.8 s beside a mesh pipeline create, and with the
gate off a vkQueueSubmit sat 54 s in the driver beside a 56 s mesh create
before the device was lost. Graphics creates never passed the gate.

- Graphics creates (mesh included) now pass the gate (PipelineState::build
  through DriverTurn), and CompileTurn carries the create's kind, name,
  trigger and size. The adaptive gate keeps a verdict per kind; a probe
  counts for each kind that had a create in the driver from before the
  submission entered until it came back, a held one against all of them.
- A kind that is off is still timed: a submission that stays 2 s or more
  beside one of its creates turns that kind back on for the rest of the run.
- No submission goes ahead, at the limit or the probe budget, while a create
  of a kind that holds submissions is in the driver, and such creates are
  waited for even if one went past them before the verdict.
- A create never waits behind the submission of the thread that holds the
  submit lock.
- VulkanContext::mark_device_lost logs the creates in the driver (kind,
  program, size, thread, how long, whether submissions wait for them) and
  each kind's gate.

Tested: submit_mutex (new gate_per_kind case; held-verdict cases adjusted;
also under LEONIDA_COMPILE_GATE=1 and =0), MSVC, Windows 11.

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

@⁠nicoco23 on GitHub · 2026-11-27 00:32 UTC · original · reviewed

Static review of the 4 commits on e5a7c89 (not built or run yet; my RTX 5070 run comes tonight). AI-assisted.

Looks solid overall: per-kind verdicts, two quick probes 1 s apart, the 2.5 s / 10 s probe budget and the 15 s cap bound the stall well, the "own" case avoids the self-wait, and report_creates_on_loss is very useful.

One point I'd like your view on:

  • Every SubmitTurn counts as a probe, not only vkQueueSubmit: presents (vulkan_present.h), vkQueueWaitIdle and vkQueueBindSparse too. A present or wait-idle that takes 2 s during heavy loading can mark a kind as "holds" (or re-arm it) without the driver holding a submission behind a create. The other way round, quick presents can count as quick probes and turn a kind off on a driver that would hold a vkQueueSubmit (the 630.20 case).
  • Since f7b249730 a "holds" kind is waited for with no limit (held_blocking() drops the limit and the budget, and is_blocking() ignores overdue_through_). So a false "holds" brings back the unbounded gate for the rest of the run. The header comment still says a false alarm "only keeps the bounded gate, never less protection".

Suggestion: count only vkQueueSubmit (and maybe vkQueueBindSparse) as probes, e.g. a flag on SubmitTurn for presents and idle waits. And/or keep a (longer) bound for a "holds" kind instead of none. At least align the comment.

**@⁠nicoco23** on GitHub · 2026-11-27 00:32 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2412#pullrequestreview-6081980200) · **reviewed** Static review of the 4 commits on e5a7c89 (not built or run yet; my RTX 5070 run comes tonight). AI-assisted. Looks solid overall: per-kind verdicts, two quick probes 1 s apart, the 2.5 s / 10 s probe budget and the 15 s cap bound the stall well, the "own" case avoids the self-wait, and report_creates_on_loss is very useful. One point I'd like your view on: - Every SubmitTurn counts as a probe, not only vkQueueSubmit: presents (vulkan_present.h), vkQueueWaitIdle and vkQueueBindSparse too. A present or wait-idle that takes 2 s during heavy loading can mark a kind as "holds" (or re-arm it) without the driver holding a submission behind a create. The other way round, quick presents can count as quick probes and turn a kind off on a driver that would hold a vkQueueSubmit (the 630.20 case). - Since f7b249730 a "holds" kind is waited for with no limit (held_blocking() drops the limit and the budget, and is_blocking() ignores overdue_through_). So a false "holds" brings back the unbounded gate for the rest of the run. The header comment still says a false alarm "only keeps the bounded gate, never less protection". Suggestion: count only vkQueueSubmit (and maybe vkQueueBindSparse) as probes, e.g. a flag on SubmitTurn for presents and idle waits. And/or keep a (longer) bound for a "holds" kind instead of none. At least align the comment.
A submission that stays 2 s or more in the driver turned its create kind's gate on (or back on). It
now counts only if it came back within 500 ms after a create of that kind, there when it entered,
left the driver: a submission held behind a create comes back when the create does. On the 4070
Laptop (621.40, 8 GB nearly full) a 36 s submission came back 18 s before the compute create beside
it; counted as held, it re-armed the gate, which then kept the next submission 78 s behind compute
creates. One that is slow with its creates still there is logged (the first 8) and judged nothing.

Tests: the held-probe tests release the create 100 ms before the submission comes back; a new one
checks that a slow submission with the create still there gives no held verdict.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review of #2412 (nicoco23, ecox982745):
- A later create leaving hid the earlier one a held probe needs: last_leave_seq_ kept one leave per
  kind, so when A (there when the submission entered) and then B (entered after it) left just before
  the submission came back, B replaced A and the probe was not counted. The recent leaves are now a
  ring of 64, and any leave of the kind, of a create the submission entered beside, within 500 ms
  before it came back counts.
- Presents and idle or semaphore waits passed the gate as probes: they can take seconds on their own
  while the GPU is busy, so a slow present could mark a kind as holding, and quick ones could turn a
  kind off. SubmitTurn takes `probe` (true by default); the presents, vkQueueWaitIdle,
  vkDeviceWaitIdle and vkWaitSemaphores turns pass false. vkQueueSubmit and vkQueueBindSparse probe.
- A kind that holds submissions was waited for with no limit, so a false verdict brought back the
  unbounded gate for the rest of the run. It is now waited for up to LEONIDA_COMPILE_GATE_HELD_WAIT_MS
  (60 s; 0: no limit), after which the creates in the driver are gone past and not waited for again.
  The header comment that said a false alarm "only keeps the bounded gate" is rewritten.

Tests: submit_mutex_test gains both finish orders of A and B, B alone with A still there, a 2.1 s
present that judges nothing, and a holding kind gone past at a 400 ms held limit. All pass (MSVC,
Windows 11). The docs tests pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠OreoFR on GitHub · 2026-11-27 01:28 UTC · original

Pushed e5d1a1468: a held probe now needs the create beside it to have just left. A submission counts as held behind a kind only if it comes back within 500 ms after a create of that kind (one that was in the driver when it entered) leaves. Otherwise it is logged as "not counted as held" and decides nothing.

Why (RTX 4070 Laptop 8 GB, NVIDIA 621.40, main + this PR, documented recipe without the window size):

  • One submission stayed 35.7 s in the driver beside a 58.4 s compute create, but came back 18 s before that create finished. So it wasn't held by the create. The old rule counted it as held and turned the compute gate back on. The gate then kept the next submissions behind compute creates for 18 s and then 78 s ("waits until that create leaves"). Same pattern in a second run: a 2.1 s submission re-armed the gate, then waits of 19.6 s and 13 s followed. MEASURED (n=2).
  • In both runs device-local memory was ~7.7 GB of 8 GB. My guess is that the slow submissions come from memory pressure, not from the creates. ASSUMED; an arena-size A/B is next.
  • A synthetic probe on the same machine (2 MB graphics pipelines of 8-10 s each; 1-3 creating threads; with and without VK_NV_device_diagnostics_config; with and without a shared pipeline cache; small creates on the submitting thread) never held a vkQueueSubmit past 80 ms, in process or out of process. MEASURED (n=1 per case).

Tests: submit_mutex_test passes. The held-probe tests now release the create 100 ms before the submission comes back, and a new case checks that a slow submission with its create still there gives no held verdict. One retail run with the fix: no gate wait over 2.5 s up to a device loss at 306 s (Timeout, no warps in the dump), so the loss doesn't come from the gate. MEASURED (n=1).

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

**@⁠OreoFR** on GitHub · 2026-11-27 01:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2412#issuecomment-7207313035) Pushed e5d1a1468: **a held probe now needs the create beside it to have just left.** A submission counts as held behind a kind only if it comes back within 500 ms after a create of that kind (one that was in the driver when it entered) leaves. Otherwise it is logged as "not counted as held" and decides nothing. Why (RTX 4070 Laptop 8 GB, NVIDIA 621.40, `main` + this PR, documented recipe without the window size): - One submission stayed 35.7 s in the driver beside a 58.4 s compute create, but came back **18 s before** that create finished. So it wasn't held by the create. The old rule counted it as held and turned the compute gate back on. The gate then kept the next submissions behind compute creates for 18 s and then **78 s** ("waits until that create leaves"). Same pattern in a second run: a 2.1 s submission re-armed the gate, then waits of 19.6 s and 13 s followed. `MEASURED (n=2)`. - In both runs device-local memory was ~7.7 GB of 8 GB. My guess is that the slow submissions come from memory pressure, not from the creates. `ASSUMED`; an arena-size A/B is next. - A synthetic probe on the same machine (2 MB graphics pipelines of 8-10 s each; 1-3 creating threads; with and without `VK_NV_device_diagnostics_config`; with and without a shared pipeline cache; small creates on the submitting thread) never held a `vkQueueSubmit` past 80 ms, in process or out of process. `MEASURED (n=1 per case)`. Tests: `submit_mutex_test` passes. The held-probe tests now release the create 100 ms before the submission comes back, and a new case checks that a slow submission with its create still there gives no held verdict. One retail run with the fix: no gate wait over 2.5 s up to a device loss at 306 s (Timeout, no warps in the dump), so the loss doesn't come from the gate. `MEASURED (n=1)`. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠ecox982745 on GitHub · 2026-11-27 01:47 UTC · original

At e5d1a14681, a newer compute pipeline finishing can hide the departure that should re-arm the compute gate. The stock submit_mutex_test passed. I tested four additional event orders against the unchanged SubmitMutex header on Windows with MSVC. These are CPU-only tests using separate worker threads, the submit lock, and the real CompileTurn and SubmitTurn objects. No Vulkan driver calls were involved.

Two quick probes first put the compute gate in its off state. Create A was already active when the measured submission began. Create B, when present, began after the submission began. Each row ran three times.

Creates finishing within 500 ms before submission return Expected gate Observed
A alone Re-armed Re-armed 3/3
B alone, with A still active at return Off Off 3/3
B, then A Re-armed Re-armed 3/3
A, then B Re-armed Off 3/3

For example, A finished at 2,080 ms, B at 2,111 ms, and the submission returned at 2,159 ms. A met the 500 ms rule by 421 ms of margin. B replaced A in last_leave_seq_[compute], so the comparison with ahead.last_create discarded the evidence from A.

A regression covering both finish orders would catch this. Tracking the most recent eligible completion for each active probe would preserve A's timestamp while keeping the B-only case off. AI-assisted verification.

**@⁠ecox982745** on GitHub · 2026-11-27 01:47 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2412#issuecomment-7207583497) At `e5d1a14681`, a newer compute pipeline finishing can hide the departure that should re-arm the compute gate. The stock `submit_mutex_test` passed. I tested four additional event orders against the unchanged `SubmitMutex` header on Windows with MSVC. These are CPU-only tests using separate worker threads, the submit lock, and the real `CompileTurn` and `SubmitTurn` objects. No Vulkan driver calls were involved. Two quick probes first put the compute gate in its off state. Create **A** was already active when the measured submission began. Create **B**, when present, began *after* the submission began. Each row ran three times. | Creates finishing within 500 ms before submission return | Expected gate | Observed | | --- | --- | --- | | A alone | Re-armed | Re-armed 3/3 | | B alone, with A still active at return | Off | Off 3/3 | | B, then A | Re-armed | Re-armed 3/3 | | A, then B | Re-armed | **Off 3/3** | For example, A finished at 2,080 ms, B at 2,111 ms, and the submission returned at 2,159 ms. A met the 500 ms rule by 421 ms of margin. B replaced A in `last_leave_seq_[compute]`, so the comparison with `ahead.last_create` discarded the evidence from A. A regression covering both finish orders would catch this. Tracking the most recent *eligible* completion for each active probe would preserve A's timestamp while keeping the B-only case off. AI-assisted verification.
Author
Owner

@⁠OreoFR on GitHub · 2026-11-27 01:54 UTC · original

Thanks both, all three points were right. Pushed b2cccb953:

  • @⁠ecox982745: a later create's leave no longer hides an earlier one. Leaves now go in a ring of 64, and any leave of that kind within 500 ms before the submission comes back counts, as long as the create was in the driver when the submission entered. Your four orders are in submit_mutex_test: A alone, B alone with A still there, B then A, and A then B. Re-armed, off, re-armed, re-armed.
  • @⁠nicoco23, probes: only vkQueueSubmit and vkQueueBindSparse probe now. SubmitTurn takes probe (true by default). Presents, vkQueueWaitIdle, vkDeviceWaitIdle and vkWaitSemaphores pass false: they still wait at the gate, but their time in the driver decides nothing. Test: a 2.1 s present with the create leaving just before leaves the kind pending.
  • @⁠nicoco23, the unbounded wait: a kind that holds is now waited for up to LEONIDA_COMPILE_GATE_HELD_WAIT_MS (60 s, 0 = no limit). After that, the creates in the driver are gone past and the next submissions don't wait for them. A false "holds" verdict now costs at most that per create, not the rest of the run. Test: 400 ms held limit, the submission waited 414 ms and the next one 0 ms. The header comment and the docs are rewritten to match.

submit_mutex_test passes (13 cases, MSVC, Windows 11), and so do the 13 tests/test_docs_*.py. No retail run yet on b2cccb953; one will follow.

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

**@⁠OreoFR** on GitHub · 2026-11-27 01:54 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2412#issuecomment-7207666729) Thanks both, all three points were right. Pushed b2cccb953: - @⁠ecox982745: a later create's leave no longer hides an earlier one. Leaves now go in a ring of 64, and any leave of that kind within 500 ms before the submission comes back counts, as long as the create was in the driver when the submission entered. Your four orders are in `submit_mutex_test`: A alone, B alone with A still there, B then A, and A then B. Re-armed, off, re-armed, re-armed. - @⁠nicoco23, probes: only `vkQueueSubmit` and `vkQueueBindSparse` probe now. `SubmitTurn` takes `probe` (true by default). Presents, `vkQueueWaitIdle`, `vkDeviceWaitIdle` and `vkWaitSemaphores` pass `false`: they still wait at the gate, but their time in the driver decides nothing. Test: a 2.1 s present with the create leaving just before leaves the kind pending. - @⁠nicoco23, the unbounded wait: a kind that holds is now waited for up to `LEONIDA_COMPILE_GATE_HELD_WAIT_MS` (60 s, `0` = no limit). After that, the creates in the driver are gone past and the next submissions don't wait for them. A false "holds" verdict now costs at most that per create, not the rest of the run. Test: 400 ms held limit, the submission waited 414 ms and the next one 0 ms. The header comment and the docs are rewritten to match. `submit_mutex_test` passes (13 cases, MSVC, Windows 11), and so do the 13 `tests/test_docs_*.py`. No retail run yet on b2cccb953; one will follow. AI-assisted (Claude Code, Claude Opus 5.5).
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/2412/head:github-bot/gh-2412'
git switch 'github-bot/gh-2412'

Merge

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