compile gate: auto default, calibrated per driver at device creation (RT-COMPILE-GATE-AUTO) #2462

Manually merged
github merged 3 commits from github-bot/gh-2462 into main 2026-11-27 13:09:07 +00:00 AGit
Owner

@⁠OreoFR on GitHub · 2026-11-27 12:26 UTC · original
OreoFR:rt-compile-gate-auto → main · +1359 −56 · 10 files · 3 commits · merged 2026-11-27 13:08 UTC

Claimed in the coordination issue as: RT-COMPILE-GATE-AUTO. The claim describes an allow-list of driver branches; this PR measures the driver instead.

Depends on: nothing (#2412 is merged)

What and why

The follow-up @⁠aslan2142 asked for on #2412 (merge comment). It turns on the adaptive compile gate where the driver does not hold a submission behind a pipeline create, and keeps the classic gate where it does.

The new default is LEONIDA_COMPILE_GATE unset or auto. At device creation, before the VulkanContext and its SubmitMutex exist, the runtime calibrates the gate once (decide_auto_compile_gate, runtime/shims/d3d12_vulkan_device.cpp; runtime/src/compile_gate_calibration.h):

  • A worker thread creates a synthetic compute pipeline, with no pipeline cache. The SPIR-V is written in code by compile_gate_policy::slow_compute_spirv: a chain of fract(sin(..)) steps with branches, and specialization constant 0 seeded anew on each run, so no cache can answer it. No game data.
  • Meanwhile this thread submits an empty command buffer to the device's queue and waits for its fence, over and over, until the create returns.
  • The verdict (compile_gate_policy::judge, a pure function):
  • The verdict is cached per vendor, device, driver version and pipeline cache UUID in compile_gate_calibration.txt, beside the pipeline cache. So the calibration runs once per driver. Failures are not cached. LEONIDA_COMPILE_GATE_RECALIBRATE=1 measures again.
  • The decision is logged once, as [rt] compile-gate: auto: adaptive (calibrated on NVIDIA 621.40 in 0.7 s: 115 submissions came back in <= 0.5 ms beside a 722 ms create; cached in ...\compile_gate_calibration.txt; LEONIDA_COMPILE_GATE=classic|adaptive overrides). Otherwise it says auto: classic (...) with the reason, or (cached calibration of ...).
  • Only gta6rt's title process calibrates (compile_gate_policy::calibration_allowed, set in main.cpp). --precompile-pipelines, --compile-server and the test processes keep the classic gate. A forced value never waits for the calibration.

What forcing still does:

  • classic (new), adaptive, 1 and 0 force a mode, as before.
  • An unknown value is classic, as on main, and is now logged.
  • Until the decision, auto is classic, so nothing can be gated differently from main before it.

How the gate's mode is read:

  • SubmitMutex::compile_gate_mode() now reads an atomic, set once by decide_auto_gate.
  • gate_defaults() keeps one set per mode, so the adaptive limit and budget apply when auto picks adaptive.

Why a calibration can ask what an in-game probe cannot: the adaptive gate learns by letting a submission into the driver beside one of the title's creates, which can take 30-60 s. On a driver that holds submissions (630.20), that probe loses the device once it waits 10 s more. The calibration's create takes about a second and its submissions are empty. On such a driver, one is held for about a second and comes back with the create, which cannot reach the 10 s TDR.

Evidence the verdict should agree with, from #2412 comment 7217585003, now in docs/d3d12_vulkan.md:

  • 621.40, RTX 4070 Laptop: in a synthetic probe, a submission never waited past 80 ms. Retail adaptive runs had no gate hang after #2418. The calibration says adaptive here (below).
  • 610.88, RTX 4060 (MoonEyes): the adaptive gate turned off, with no regression reported.
  • 621.x (sodovaya): fewer crashes with adaptive.
  • 621.x, RTX 5070: one freeze at about 231 s, on head b2cccb9 without #2418. @⁠nicoco23, could you recheck on this branch? With LEONIDA_COMPILE_GATE unset, the log should show [rt] compile-gate: auto: adaptive (calibrated on NVIDIA 621.xx ...). A freeze report with the thread dump would help most.
  • 630.20: not run yet. The expected verdict is classic, from the 10 s hold measured beside a long compute create. A report from a 630.20 user is the most useful next test.

README rows: LEONIDA_COMPILE_GATE (default auto), the new LEONIDA_COMPILE_GATE_RECALIBRATE, and the wait and probe rows now say "with the adaptive gate".

What changes for users: on main, LEONIDA_COMPILE_GATE unset means the classic gate. With this PR, unset means auto: calibrate once per driver, then adaptive or classic. Behaviour with any explicit value is unchanged. The real test is therefore a run with the variable unset, on several drivers.

Tested

  • compile_gate_policy_test (new, pure stdlib, no GPU) passes. It covers:
  • vk_compile_gate_calibration_test (new, GPU; 77 without a device) expects a verdict within 20 s, and adaptive on NVIDIA 621.40. MEASURED, on this RTX 4070 Laptop (621.40):
  • submit_mutex_test passes with LEONIDA_COMPILE_GATE unset, auto, classic, adaptive, 1, 0 and an unknown value. vulkan_device_fault_test passes. MEASURED
  • gta6rt, gta6rt_tls_host and the tests build with MSVC 14.44.
  • The clang front end in clang-tidy (LLVM 19.1.5, -std=c++20 -Wall -Wextra, header filter on the new headers) reports no errors or warnings in the two new tests, submit_mutex_test.cpp or vulkan_device_fault_test.cpp. GCC was not checked.
  • tests/test_docs_*.py pass. check_no_game_data.py is clean on every changed file.
  • Not run: the title. The path in decide_auto_compile_gate (cache read and write, the log line) runs only in the title process, so it is READ IN CODE only. The calibration it calls is the one the GPU test runs.

GPUs tested: NVIDIA GeForce RTX 4070 Laptop 8 GB, driver 621.40, Windows 11 (calibration: adaptive). NVIDIA GeForce RTX 4060, driver 610.88 (MoonEyes): merges cleanly, builds, the new tests and submit_mutex_test pass, calibration adaptive (163 submissions <= 0.7 ms beside a 957 ms create, 1.07 s); his in-game run follows.

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-27 12:26 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2462) `OreoFR:rt-compile-gate-auto` → `main` · +1359 −56 · 10 files · 3 commits · merged 2026-11-27 13:08 UTC Claimed in the coordination issue as: [RT-COMPILE-GATE-AUTO](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608). The claim describes an allow-list of driver branches; this PR **measures** the driver instead. Depends on: nothing (#2412 is merged) ### What and why The follow-up @⁠aslan2142 asked for on #2412 ([merge comment](https://git.gtahub.st/github/ubiquitarianism--leonida/pulls/2412)). It turns on the adaptive compile gate where the driver does not hold a submission behind a pipeline create, and keeps the classic gate where it does. The new default is `LEONIDA_COMPILE_GATE` unset or `auto`. At device creation, before the `VulkanContext` and its `SubmitMutex` exist, the runtime calibrates the gate once (`decide_auto_compile_gate`, `runtime/shims/d3d12_vulkan_device.cpp`; `runtime/src/compile_gate_calibration.h`): - A worker thread creates a synthetic compute pipeline, with no pipeline cache. The SPIR-V is written in code by `compile_gate_policy::slow_compute_spirv`: a chain of `fract(sin(..))` steps with branches, and specialization constant 0 seeded anew on each run, so no cache can answer it. No game data. - Meanwhile this thread submits an empty command buffer to the device's queue and waits for its fence, over and over, until the create returns. - The verdict (`compile_gate_policy::judge`, a pure function): - The verdict is cached per vendor, device, driver version and pipeline cache UUID in `compile_gate_calibration.txt`, beside the pipeline cache. So the calibration runs once per driver. Failures are not cached. `LEONIDA_COMPILE_GATE_RECALIBRATE=1` measures again. - The decision is logged once, as `[rt] compile-gate: auto: adaptive (calibrated on NVIDIA 621.40 in 0.7 s: 115 submissions came back in <= 0.5 ms beside a 722 ms create; cached in ...\compile_gate_calibration.txt; LEONIDA_COMPILE_GATE=classic|adaptive overrides)`. Otherwise it says `auto: classic (...)` with the reason, or `(cached calibration of ...)`. - Only gta6rt's title process calibrates (`compile_gate_policy::calibration_allowed`, set in `main.cpp`). `--precompile-pipelines`, `--compile-server` and the test processes keep the classic gate. A forced value never waits for the calibration. What forcing still does: - `classic` (new), `adaptive`, `1` and `0` force a mode, as before. - An unknown value is classic, as on `main`, and is now logged. - Until the decision, `auto` is classic, so nothing can be gated differently from `main` before it. How the gate's mode is read: - `SubmitMutex::compile_gate_mode()` now reads an atomic, set once by `decide_auto_gate`. - `gate_defaults()` keeps one set per mode, so the adaptive limit and budget apply when `auto` picks adaptive. Why a calibration can ask what an in-game probe cannot: the adaptive gate learns by letting a submission into the driver beside one of the title's creates, which can take 30-60 s. On a driver that holds submissions (630.20), that probe loses the device once it waits 10 s more. The calibration's create takes about a second and its submissions are empty. On such a driver, one is held for about a second and comes back with the create, which cannot reach the 10 s TDR. Evidence the verdict should agree with, from [#2412 comment 7217585003](https://git.gtahub.st/github/ubiquitarianism--leonida/pulls/2412), now in `docs/d3d12_vulkan.md`: - 621.40, RTX 4070 Laptop: in a synthetic probe, a submission never waited past 80 ms. Retail adaptive runs had no gate hang after #2418. The calibration says adaptive here (below). - 610.88, RTX 4060 (MoonEyes): the adaptive gate turned off, with no regression reported. - 621.x (sodovaya): fewer crashes with adaptive. - 621.x, RTX 5070: one freeze at about 231 s, on head b2cccb9 without #2418. @⁠nicoco23, could you recheck on this branch? With `LEONIDA_COMPILE_GATE` unset, the log should show `[rt] compile-gate: auto: adaptive (calibrated on NVIDIA 621.xx ...)`. A freeze report with the thread dump would help most. - 630.20: not run yet. The expected verdict is classic, from the 10 s hold measured beside a long compute create. A report from a 630.20 user is the most useful next test. README rows: `LEONIDA_COMPILE_GATE` (default `auto`), the new `LEONIDA_COMPILE_GATE_RECALIBRATE`, and the wait and probe rows now say "with the adaptive gate". **What changes for users:** on `main`, `LEONIDA_COMPILE_GATE` unset means the classic gate. With this PR, unset means `auto`: calibrate once per driver, then adaptive or classic. Behaviour with any explicit value is unchanged. The real test is therefore a run with the variable unset, on several drivers. ### Tested - `compile_gate_policy_test` (new, pure stdlib, no GPU) passes. It covers: - `vk_compile_gate_calibration_test` (new, GPU; 77 without a device) expects a verdict within 20 s, and adaptive on NVIDIA 621.40. `MEASURED`, on this RTX 4070 Laptop (621.40): - `submit_mutex_test` passes with `LEONIDA_COMPILE_GATE` unset, `auto`, `classic`, `adaptive`, `1`, `0` and an unknown value. `vulkan_device_fault_test` passes. `MEASURED` - `gta6rt`, `gta6rt_tls_host` and the tests build with MSVC 14.44. - The clang front end in clang-tidy (LLVM 19.1.5, `-std=c++20 -Wall -Wextra`, header filter on the new headers) reports no errors or warnings in the two new tests, `submit_mutex_test.cpp` or `vulkan_device_fault_test.cpp`. GCC was not checked. - `tests/test_docs_*.py` pass. `check_no_game_data.py` is clean on every changed file. - Not run: the title. The path in `decide_auto_compile_gate` (cache read and write, the log line) runs only in the title process, so it is `READ IN CODE` only. The calibration it calls is the one the GPU test runs. GPUs tested: NVIDIA GeForce RTX 4070 Laptop 8 GB, driver 621.40, Windows 11 (calibration: adaptive). NVIDIA GeForce RTX 4060, driver 610.88 (MoonEyes): merges cleanly, builds, the new tests and `submit_mutex_test` pass, calibration adaptive (163 submissions <= 0.7 ms beside a 957 ms create, 1.07 s); his in-game run follows. 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)
With LEONIDA_COMPILE_GATE unset or `auto`, the device measures the driver once
before the VulkanContext exists: a worker creates a synthetic compute pipeline
(SPIR-V written in code, new specialization seed each run, no pipeline cache)
while the queue gets empty submissions waited on a fence. Quick submissions with
the create still in the driver give the adaptive gate; a held one, a create too
fast to tell, an unexplained slow submission or any failure give classic. The
verdict is cached per vendor/device/driver/pipelineCacheUUID in
compile_gate_calibration.txt beside the pipeline cache;
LEONIDA_COMPILE_GATE_RECALIBRATE=1 measures again. Only the title process
calibrates; build hosts and tests keep classic. `classic`, `adaptive`, `1`, `0`
still force a mode.

Tests: compile_gate_policy_test (no GPU: settings, NVIDIA version decode,
verdicts, cache file, SPIR-V shape) and vk_compile_gate_calibration_test (GPU:
a verdict within 20 s, adaptive on NVIDIA 621.40).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 12:27:23 +00:00
Review of #2462:
- An unclear calibration (a slow submission the create does not explain) is no
  longer written to compile_gate_calibration.txt, and an unclear line an
  earlier build wrote is not read as a cached verdict: the next launch measures
  again instead of staying classic until the driver changes
  (compile_gate_policy::cache_verdict, tested in compile_gate_policy_test).
- After a fence wait that fails, the fence and command pool are destroyed only
  once the pending submission's fence signals (up to 60 s); on a lost device or
  if it still has not, they are left alive. The verdict stays classic.

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

@⁠OreoFR on GitHub · 2026-11-27 12:39 UTC · original

In-game check of the title path, which the PR body listed as not run. main + this PR only, RTX 4070 Laptop, NVIDIA 621.40, LEONIDA_COMPILE_GATE unset, first run on this driver:

[rt] compile-gate: calibration trial 1: 600 statements, create 462 ms, 73 submissions, adaptive
[rt] compile-gate: auto: adaptive (calibrated on NVIDIA 621.40 in 0.5 s: 69 submissions came back in <= 11.3 ms beside a 462 ms create; cached in …\compile_gate_calibration.txt; …)

The game then booted normally into the world phase, with no device loss and no gate hang. Startup cost: 0.5 s. MEASURED (n=1). The cached-verdict path, on a second run, is still to check. AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠OreoFR** on GitHub · 2026-11-27 12:39 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2462#issuecomment-7218516870) In-game check of the title path, which the PR body listed as not run. `main` + this PR only, RTX 4070 Laptop, NVIDIA 621.40, `LEONIDA_COMPILE_GATE` unset, first run on this driver: ``` [rt] compile-gate: calibration trial 1: 600 statements, create 462 ms, 73 submissions, adaptive [rt] compile-gate: auto: adaptive (calibrated on NVIDIA 621.40 in 0.5 s: 69 submissions came back in <= 11.3 ms beside a 462 ms create; cached in …\compile_gate_calibration.txt; …) ``` The game then booted normally into the world phase, with no device loss and no gate hang. Startup cost: 0.5 s. `MEASURED (n=1)`. The cached-verdict path, on a second run, is still to check. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠OreoFR on GitHub · 2026-11-27 12:40 UTC · original

Second run on the same driver: the cached verdict is reused, with no calibration and no startup delay:

[rt] compile-gate: auto: adaptive (cached calibration of NVIDIA 621.40: 69 submissions came back in <= 11.3 ms beside a 462 ms create; in …\compile_gate_calibration.txt, LEONIDA_COMPILE_GATE_RECALIBRATE=1 measures again; …)

Both title paths (first run and cache) are now checked in game. AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠OreoFR** on GitHub · 2026-11-27 12:40 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2462#issuecomment-7218527606) Second run on the same driver: the cached verdict is reused, with no calibration and no startup delay: ``` [rt] compile-gate: auto: adaptive (cached calibration of NVIDIA 621.40: 69 submissions came back in <= 11.3 ms beside a 462 ms create; in …\compile_gate_calibration.txt, LEONIDA_COMPILE_GATE_RECALIBRATE=1 measures again; …) ``` Both title paths (first run and cache) are now checked in game. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-27 12:41 UTC · original

Measuring the driver instead of maintaining a branch allow-list is much cleaner — and vk_compile_gate_calibration_test passes cleanly on Linux AMD RADV (RDNA2 iGPU: trial 1, 1,000 statements, 391 ms create, 61 submissions <= 1.5 ms → adaptive in 393 ms), compile_gate_policy_test builds with 0 warnings under GCC -Wall -Wextra, and slow_compute_spirv(1000) passes spirv-val (vulkan1.0 and vulkan1.2).

Two small issues on 1d7c662b4 to fix before merge:

  • runtime/shims/d3d12_vulkan_device.cpp:218-236 (decide_auto_compile_gate): Outcome::unclear still has result.ok == true, so a transient background GPU spike during the first launch writes outcome=unclear to compile_gate_calibration.txt and permanently locks subsequent runs onto classic until a driver update or manual LEONIDA_COMPILE_GATE_RECALIBRATE=1. Skipping cache write on Outcome::unclear (just like !result.ok) lets the next launch get a clean measurement.
  • runtime/src/compile_gate_calibration.h:198-210: if vk.wait_fences(..., kFenceTimeoutNs) returns VK_TIMEOUT, fail() immediately calls cleanup() (vkDestroyFence / vkDestroyCommandPool) while the submitted command buffer and fence may still be pending on queue (Vulkan UB). After worker.join(), waiting on fence (or vkQueueWaitIdle) before destroying them when submit_result == VK_TIMEOUT makes cleanup spec-valid.

AI-assisted review (Antigravity, Gemini 4 Neon).

**@⁠aslan2142** on GitHub · 2026-11-27 12:41 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2462#issuecomment-7218567497) Measuring the driver instead of maintaining a branch allow-list is much cleaner — and `vk_compile_gate_calibration_test` passes cleanly on Linux AMD RADV (RDNA2 iGPU: trial 1, 1,000 statements, 391 ms create, 61 submissions `<= 1.5 ms` → `adaptive` in 393 ms), `compile_gate_policy_test` builds with 0 warnings under GCC `-Wall -Wextra`, and `slow_compute_spirv(1000)` passes `spirv-val` (vulkan1.0 and vulkan1.2). Two small issues on `1d7c662b4` to fix before merge: - **`runtime/shims/d3d12_vulkan_device.cpp:218-236` (`decide_auto_compile_gate`)**: `Outcome::unclear` still has `result.ok == true`, so a transient background GPU spike during the first launch writes `outcome=unclear` to `compile_gate_calibration.txt` and permanently locks subsequent runs onto `classic` until a driver update or manual `LEONIDA_COMPILE_GATE_RECALIBRATE=1`. Skipping cache write on `Outcome::unclear` (just like `!result.ok`) lets the next launch get a clean measurement. - **`runtime/src/compile_gate_calibration.h:198-210`**: if `vk.wait_fences(..., kFenceTimeoutNs)` returns `VK_TIMEOUT`, `fail()` immediately calls `cleanup()` (`vkDestroyFence` / `vkDestroyCommandPool`) while the submitted command buffer and fence may still be pending on `queue` (Vulkan UB). After `worker.join()`, waiting on `fence` (or `vkQueueWaitIdle`) before destroying them when `submit_result == VK_TIMEOUT` makes cleanup spec-valid. AI-assisted review (Antigravity, Gemini 4 Neon).
Author
Owner

@⁠MoonEyes on GitHub · 2026-11-27 12:49 UTC · original

RUN w62 | 2026-11-27 | MoonEyes | AI-assisted: Claude Code (Claude Opus 5.5)
BASE:        PR head 1d7c662b4 (based on f75b2b425; merges cleanly with main 3d6050b96) | shaders: locally retranslated, not the documented default
MACHINE:     RTX 4060 8 GB, desktop, only GPU, display attached | NVIDIA 610.88 | Windows 11 Pro 26300 | 32 GB
RECIPE:      none documented for this PR; my usual local recipe + DEVIATIONS: LEONIDA_COMPILE_GATE unset (auto), a few other local variables | precompile: warm pipeline cache
OS/DRIVER:   Windows GPU timeout at the default (2 s)
TARGET:      compile-gate verdict on 610.88 | PREDICTED (written before the run): adaptive, no device loss in 600 s
MEASURED:    auto: adaptive, calibrated in 1.6 s, 264 submissions back in <= 1.5 ms beside a 1543 ms create | duration 604 s | game stopped presenting around 300 s
END:         time limit, read from the log
CACHES:      pipeline cache warm; calibration cold (written by this run) | RUN 1 of 2, same recipe
INSTRUMENTS: a few local diagnostic variables, none about the gate
VERDICT:     prediction held

Second run, same recipe, 120 s, calibration cached: the log line reads auto: adaptive (cached calibration of NVIDIA 610.88 ...) and no calibration trial ran again.

What I checked on this branch:

  • Merge: clean with current main (git merge-tree, no conflict). MEASURED.
  • Build: gta6rt and the tests build with MSVC. MEASURED.
  • compile_gate_policy_test: passes. submit_mutex_test: passes. MEASURED.
  • vk_compile_gate_calibration_test on the RTX 4060 (610.88): adaptive at the first trial, 163 submissions of at most 0.7 ms beside a 957 ms create, 1071 ms in all. MEASURED.
  • In the game (one run): the runtime logged compile-gate: auto: adaptive (calibrated on NVIDIA 610.88 in 1.6 s: 264 submissions came back in <= 1.5 ms beside a 1543 ms create; ...). During 600 s, 581 submissions waited for pipeline creates, 10.3 s in all, longest 1.9 s, 7 went ahead at the limit. No device loss. MEASURED.
  • The calibration file was written next to the pipeline cache and was read back on the next run. MEASURED.

Notes:

  • This agrees with the earlier note that the gate was turned off on this card with no regression, but with auto the gate is adaptive here, not off. The adaptive gate still made short waits (up to 1.9 s) once the title started creating compute pipelines; whether that matters for the 2 s Windows timeout is a hypothesis, not tested (I ran no classic comparison).
  • My game stops presenting around 300 s in this and in my other recent runs; I do not attribute it to the gate.
  • One machine, one 600 s run and one 120 s run. Indicative only.

AI-assisted (Claude Code, Claude Opus 5.5)

**@⁠MoonEyes** on GitHub · 2026-11-27 12:49 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2462#issuecomment-7218713854) ``` RUN w62 | 2026-11-27 | MoonEyes | AI-assisted: Claude Code (Claude Opus 5.5) BASE: PR head 1d7c662b4 (based on f75b2b425; merges cleanly with main 3d6050b96) | shaders: locally retranslated, not the documented default MACHINE: RTX 4060 8 GB, desktop, only GPU, display attached | NVIDIA 610.88 | Windows 11 Pro 26300 | 32 GB RECIPE: none documented for this PR; my usual local recipe + DEVIATIONS: LEONIDA_COMPILE_GATE unset (auto), a few other local variables | precompile: warm pipeline cache OS/DRIVER: Windows GPU timeout at the default (2 s) TARGET: compile-gate verdict on 610.88 | PREDICTED (written before the run): adaptive, no device loss in 600 s MEASURED: auto: adaptive, calibrated in 1.6 s, 264 submissions back in <= 1.5 ms beside a 1543 ms create | duration 604 s | game stopped presenting around 300 s END: time limit, read from the log CACHES: pipeline cache warm; calibration cold (written by this run) | RUN 1 of 2, same recipe INSTRUMENTS: a few local diagnostic variables, none about the gate VERDICT: prediction held ``` Second run, same recipe, 120 s, calibration cached: the log line reads `auto: adaptive (cached calibration of NVIDIA 610.88 ...)` and no calibration trial ran again. What I checked on this branch: - Merge: clean with current main (git merge-tree, no conflict). MEASURED. - Build: gta6rt and the tests build with MSVC. MEASURED. - `compile_gate_policy_test`: passes. `submit_mutex_test`: passes. MEASURED. - `vk_compile_gate_calibration_test` on the RTX 4060 (610.88): adaptive at the first trial, 163 submissions of at most 0.7 ms beside a 957 ms create, 1071 ms in all. MEASURED. - In the game (one run): the runtime logged `compile-gate: auto: adaptive (calibrated on NVIDIA 610.88 in 1.6 s: 264 submissions came back in <= 1.5 ms beside a 1543 ms create; ...)`. During 600 s, 581 submissions waited for pipeline creates, 10.3 s in all, longest 1.9 s, 7 went ahead at the limit. No device loss. MEASURED. - The calibration file was written next to the pipeline cache and was read back on the next run. MEASURED. Notes: - This agrees with the earlier note that the gate was turned off on this card with no regression, but with auto the gate is adaptive here, not off. The adaptive gate still made short waits (up to 1.9 s) once the title started creating compute pipelines; whether that matters for the 2 s Windows timeout is a hypothesis, not tested (I ran no `classic` comparison). - My game stops presenting around 300 s in this and in my other recent runs; I do not attribute it to the gate. - One machine, one 600 s run and one 120 s run. Indicative only. AI-assisted (Claude Code, Claude Opus 5.5)
Author
Owner

@⁠OreoFR on GitHub · 2026-11-27 12:49 UTC · original

Thanks @⁠aslan2142, both points are fixed in e31f50bbc. It is on top of a merge of current main (6af3b1dac), which merged cleanly.

  • Unclear verdicts cached: fixed.
    • decide_auto_compile_gate writes the cache only when compile_gate_policy::cache_verdict(outcome) is true. That is every outcome except unclear.
    • An unclear run still gives classic for this launch. The log ends with not cached: the next launch measures again.
    • find_entry also ignores an unclear line written by the previous head, so a file that already has one measures again.
    • compile_gate_policy_test covers this: cache_verdict per outcome, and an unclear line next to a valid one for another key.
    • A too_fast result at the largest size is still cached, because it does not change from one launch to the next.
  • Fence destroyed while pending: fixed.
    • A trial now tracks whether a submission is in flight.
    • After worker.join(), if the submit or wait failed, it waits on the fence again, for up to 60 s, before cleanup() destroys the fence and command pool.
    • On VK_ERROR_DEVICE_LOST, or if the fence still has not signalled, the fence and pool are left alive. The verdict is classic, as before.

Re-run on Windows 11, MSVC 14.44, RTX 4070 Laptop, NVIDIA 621.40, MEASURED:

  • compile_gate_policy_test passes.
  • vk_compile_gate_calibration_test, 3 runs: adaptive each time, 95-109 submissions of at most 0.5 ms beside 600-686 ms creates.
  • submit_mutex_test and vulkan_device_fault_test pass.
  • clang front end (LLVM 19, -Wall -Wextra): clean.
  • test_docs_*.py pass, and check_no_game_data.py is clean.
  • The docs paragraph and the README row now say that unclear verdicts are not cached.

The timeout path itself was not exercised: it needs a fence that does not signal within 10 s.

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

**@⁠OreoFR** on GitHub · 2026-11-27 12:49 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2462#issuecomment-7218715638) Thanks @⁠aslan2142, both points are fixed in e31f50bbc. It is on top of a merge of current `main` (6af3b1dac), which merged cleanly. - **Unclear verdicts cached:** fixed. - `decide_auto_compile_gate` writes the cache only when `compile_gate_policy::cache_verdict(outcome)` is true. That is every outcome except `unclear`. - An unclear run still gives classic for this launch. The log ends with `not cached: the next launch measures again`. - `find_entry` also ignores an `unclear` line written by the previous head, so a file that already has one measures again. - `compile_gate_policy_test` covers this: `cache_verdict` per outcome, and an unclear line next to a valid one for another key. - A `too_fast` result at the largest size is still cached, because it does not change from one launch to the next. - **Fence destroyed while pending:** fixed. - A trial now tracks whether a submission is in flight. - After `worker.join()`, if the submit or wait failed, it waits on the fence again, for up to 60 s, before `cleanup()` destroys the fence and command pool. - On `VK_ERROR_DEVICE_LOST`, or if the fence still has not signalled, the fence and pool are left alive. The verdict is classic, as before. Re-run on Windows 11, MSVC 14.44, RTX 4070 Laptop, NVIDIA 621.40, `MEASURED`: - `compile_gate_policy_test` passes. - `vk_compile_gate_calibration_test`, 3 runs: adaptive each time, 95-109 submissions of at most 0.5 ms beside 600-686 ms creates. - `submit_mutex_test` and `vulkan_device_fault_test` pass. - clang front end (LLVM 19, `-Wall -Wextra`): clean. - `test_docs_*.py` pass, and `check_no_game_data.py` is clean. - The docs paragraph and the README row now say that unclear verdicts are not cached. The timeout path itself was not exercised: it needs a fence that does not signal within 10 s. AI-assisted (Claude Code, Claude Opus 5.5).
github manually merged commit 17d3af0b65 into main 2026-11-27 13:09:07 +00:00
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-27 13:07 UTC · original

Both review items look cleanly fixed in e31f50bbc (cache_verdict excluding Outcome::unclear on both write and read, and draining a pending fence before destroying fence/pool).

Verified locally on main (f5c3ea2e0) + e31f50bbc:

  • scripts/check_no_game_data.py clean; test_docs_env_vars (5/5), test_docs_repo_paths (3/3), test_ctest_registration (6/6), test_ci_registration (18/18) pass.
  • compile_gate_policy_test builds with 0 warnings under GCC -Wall -Wextra and passes.
  • Full clang-cl + xwin + Wine runtime test suite on Linux AMD RDNA2 iGPU (RADV, 498 tests): compile_gate_policy and vk_compile_gate_calibration pass; 0 regressions vs main-e5a7c8942 (433 pass, 40 skip, 23 pre-existing Wine-iGPU failures, 2 disabled).

Merging.

AI-assisted review (Antigravity, Gemini 4 Neon).

**@⁠aslan2142** on GitHub · 2026-11-27 13:07 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2462#issuecomment-7219094349) Both review items look cleanly fixed in `e31f50bbc` (`cache_verdict` excluding `Outcome::unclear` on both write and read, and draining a pending fence before destroying `fence`/`pool`). Verified locally on `main` (`f5c3ea2e0`) + `e31f50bbc`: - `scripts/check_no_game_data.py` clean; `test_docs_env_vars` (5/5), `test_docs_repo_paths` (3/3), `test_ctest_registration` (6/6), `test_ci_registration` (18/18) pass. - `compile_gate_policy_test` builds with 0 warnings under GCC `-Wall -Wextra` and passes. - Full clang-cl + xwin + Wine runtime test suite on Linux AMD RDNA2 iGPU (RADV, 498 tests): `compile_gate_policy` and `vk_compile_gate_calibration` pass; 0 regressions vs `main-e5a7c8942` (433 pass, 40 skip, 23 pre-existing Wine-iGPU failures, 2 disabled). Merging. AI-assisted review (Antigravity, Gemini 4 Neon).
This discussion has been locked. Commenting is limited to contributors.
No description provided.