diff options
| author | Aslan2142 <jan.trencansky@protonmail.com> | 2026-11-27 13:02:22 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-27 13:02:22 +0100 |
| commit | f75b2b4258cf25e360bd6d59f554ca4ebdf30bf4 (patch) | |
| tree | aed044faed97a033c8dc4a3b37b1c09fcb1f9162 /docs | |
| parent | a3bafd05d02b1628796a24d851693adb0d9bd136 (diff) | |
| parent | ebdc9916278981721453db22a533659a4e971efa (diff) | |
Merge pull request #2412 from OreoFR/fix/compile-gate-bounded
compile gate: adaptive per kind of create, re-armed by a held submission (RT-COMPILE-GATE-ADAPTIVE)
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/d3d12_vulkan.md | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/docs/d3d12_vulkan.md b/docs/d3d12_vulkan.md index 7bd8dd255..a368c77b4 100644 --- a/docs/d3d12_vulkan.md +++ b/docs/d3d12_vulkan.md | |||
| @@ -2899,6 +2899,73 @@ submitting thread; at the maintainers' decision it was replaced by this one when | |||
| 2899 | title submits (a submission in the last second, `src/pipeline_wait.h`); the pipeline is built at its first use | 2899 | title submits (a submission in the last second, `src/pipeline_wait.h`); the pipeline is built at its first use |
| 2900 | instead. Opt-in: unset or 0, every warm-up runs, as on `main`, and `LargeModuleGate` (#1889) orders them behind a | 2900 | instead. Opt-in: unset or 0, every warm-up runs, as on `main`, and `LargeModuleGate` (#1889) orders them behind a |
| 2901 | submission's compiles. Smaller warm-ups, and every warm-up before the first submission, run as before. | 2901 | submission's compiles. Smaller warm-ups, and every warm-up before the first submission, run as before. |
| 2902 | - **A bounded, adaptive compile gate, opt-in** (`SubmitMutex::enter_submit`, `src/vulkan_device_fault.h`, | ||
| 2903 | `LEONIDA_COMPILE_GATE=adaptive`). Unset, the gate stays the classic one: compute creates only, each waited for | ||
| 2904 | however long it takes, no probes, as before. The adaptive gate is opt-in because of what it costs on a driver that | ||
| 2905 | does hold submissions behind a create (630.20, below): no run of it there has been reported yet. The gate keeps a | ||
| 2906 | `vkQueueSubmit` out of the driver while a create is in it, since on NVIDIA 630.20 one that entered during a long | ||
| 2907 | `vkCreateComputePipelines` waited 10 s and lost the device. The waiting submission holds the submit lock, so all | ||
| 2908 | queues stop: on an RTX 4070 Laptop (NVIDIA 621.40) one compute create of a 2.3 MB module stayed in the driver for | ||
| 2909 | more than 54 s during the story load, the submission waited for all of it and the title's 30 s hang watchdog ended | ||
| 2910 | the process; with `LEONIDA_COMPILE_GATE=0` the same build went past that point. With the adaptive gate a | ||
| 2911 | submission waits at most `LEONIDA_COMPILE_GATE_WAIT_MS` (15 s by default there) and then goes ahead; the creates in | ||
| 2912 | the driver at that moment hold no later submission back, and creates that enter after it are waited for again. On | ||
| 2913 | 630.20 that loses only creates over 25 s (15 s here, then the driver's 10 s), which the watchdog ends anyway. | ||
| 2914 | On the same laptop the three submissions that went ahead came back from the driver in 11, 1 and 0 ms with the | ||
| 2915 | create still there, and no device was lost; but consecutive long creates made submissions wait the full 15 s again | ||
| 2916 | and again, and the title's watchdog still ended the run. So the adaptive gate adapts: every submission that | ||
| 2917 | enters the driver next to a create it no longer waits for is a probe. Two that come back in under 250 ms, at least | ||
| 2918 | 1 s apart, with that create still in the driver turn the gate off for the rest of the run (a driver that holds a | ||
| 2919 | submission behind a create holds it as long as the create stays, and 630.20 held one for the full 10 s). Two, and a | ||
| 2920 | second apart, because back-to-back creates take and release that driver's lock, so one submission can slip in | ||
| 2921 | between; the second costs no extra wait, since after one has gone ahead the next enter at once while the create is | ||
| 2922 | still there. One probe that stays 2 s or more keeps the gate on for the rest of the run (presents and idle waits do | ||
| 2923 | not probe, below). Both verdicts are logged once. `LEONIDA_COMPILE_GATE=1` gates always and never probes. | ||
| 2924 | In the next run on that laptop the story load passed, but no wait reached 15 s, so no probe came: 80 submissions | ||
| 2925 | waited 3-7 s each (90 s in all, the longest 6.7 s), back to back, and the title's watchdog ended the run at 433 s. | ||
| 2926 | So until a verdict is in, a submission also goes ahead once the submissions' waits at the gate in the last 10 s, its | ||
| 2927 | own included, add up to `LEONIDA_COMPILE_GATE_PROBE_MS` (2500 ms). A budget over a | ||
| 2928 | window rather than a shorter limit per wait, because it also counts many short waits, and one wait reaches it as | ||
| 2929 | soon as a 2.5 s limit would. Before the verdict the gate then stops the queues for at most about a quarter of any | ||
| 2930 | 10 s, after a quick verdict not at all. On a driver that does hold submissions (630.20) the first probe now enters | ||
| 2931 | the driver after 2.5 s of waiting instead of 15 s, and loses the device if the create stays there 10 s more (the | ||
| 2932 | classic gate waits that create out). One probe per kind and run: it holds the submit lock while it is in the | ||
| 2933 | driver, so no other submission enters until it comes back, and it then gives the held verdict (2 s or more, back | ||
| 2934 | within 500 ms of the create leaving), after which no submission goes ahead beside a create of that kind before the | ||
| 2935 | held limit. The held threshold stays 2 s, well inside the 10 s such a driver gives before the loss. The limit and the | ||
| 2936 | budget apply with the title's watchdog kept kicked too (`LEONIDA_TITLE_WATCHDOG=0` and | ||
| 2937 | `LEONIDA_TITLE_WATCHDOG_KICK`): nothing ends the run then, but the stops still cost the frames, and an RTX 4060 run | ||
| 2938 | that way had 459 waits, 155 s in all and the longest 2.9 s, by t=202 s. Only `LEONIDA_COMPILE_GATE_WAIT_MS=0` (with | ||
| 2939 | no `LEONIDA_COMPILE_GATE_PROBE_MS`) or `LEONIDA_COMPILE_GATE=1` (with no `LEONIDA_COMPILE_GATE_WAIT_MS`) waits | ||
| 2940 | however long the creates take and never adapts. | ||
| 2941 | Tested by `submit_mutex` (no GPU); the probe budget is not yet measured in the title. | ||
| 2942 | The verdict is kept per kind of create, compute and graphics (mesh pipelines included), and graphics creates | ||
| 2943 | pass this gate and `LEONIDA_COMPILE_GATE=1` too (the classic gate, as before, only compute builds). On 621.40 every probe beside a compute create came back in | ||
| 2944 | 0-12 ms (and on an RTX 4060 with 610.88, 133 of them), but a run whose gate those probes had turned off lost the | ||
| 2945 | device 9 s later with a submission held 7.8 s beside a mesh create, and with `LEONIDA_COMPILE_GATE=0` a | ||
| 2946 | `vkQueueSubmit` sat 54 s in the driver beside a 56 s mesh create (541 KB) and the device was lost. A probe counts | ||
| 2947 | for each kind that had a create in the driver from before the submission entered until it came back; a held one | ||
| 2948 | counts against all of them, since which create held it cannot be told. A kind that is off is still timed: a | ||
| 2949 | submission that stays 2 s or more beside one of its creates turns that kind back on for the rest of the run. A | ||
| 2950 | held probe (pending or off) counts only if the submission came back within 500 ms after a create of that kind, | ||
| 2951 | there when it entered, left the driver: a submission held behind a create comes back when the create does. On the | ||
| 2952 | 4070 Laptop (621.40, 8 GB nearly full) a 36 s submission came back 18 s before the 58 s compute create beside it; | ||
| 2953 | counted as held, it re-armed the gate, which then kept the next submission 78 s behind compute creates. A | ||
| 2954 | synthetic probe on the same machine (one to three threads creating 2 MB graphics pipelines of 8-10 s each, with | ||
| 2955 | and without `VK_NV_device_diagnostics_config` and a shared pipeline cache) never held a submission past 80 ms. | ||
| 2956 | The recent leaves are kept in a ring, so a create that entered after the submission and left after the one it | ||
| 2957 | entered beside does not hide that one. Only submissions (`vkQueueSubmit`, `vkQueueBindSparse`) probe: presents and | ||
| 2958 | idle or semaphore waits pass the gate the same way but can take seconds on their own, so they judge nothing, and | ||
| 2959 | they never go ahead at the probe budget, only at the limit. While a create of a kind that holds submissions is in | ||
| 2960 | the driver, no submission goes ahead at the limit or the budget, and such a create is waited for even when one went | ||
| 2961 | past it before the verdict, up to the held limit (`LEONIDA_COMPILE_GATE_HELD_WAIT_MS`, 60 s; 0 waits however long, | ||
| 2962 | and a held limit under the plain one applies on its own): then the creates in the driver are gone past and the | ||
| 2963 | next submissions no longer wait for them. This is checked on every pass of the wait: once such a create leaves | ||
| 2964 | while creates of a kind with no verdict stay, the plain limit and budget apply again. A false | ||
| 2965 | "holds" verdict so costs at most that per create, not the rest of the run. On a device loss the log names every | ||
| 2966 | create in the driver (kind, program, SPIR-V size, thread, how long it had been there, whether submissions waited | ||
| 2967 | for it) and each kind's gate. Long graphics creates would leave the title's process only through the compile | ||
| 2968 | helper, which builds compute pipelines alone today. | ||
| 2902 | 2969 | ||
| 2903 | **Open:** whether the game uses `D3D12_PIPELINE_STATE_STREAM_DESC` for mesh/RT and which subobject types appear. | 2970 | **Open:** whether the game uses `D3D12_PIPELINE_STATE_STREAM_DESC` for mesh/RT and which subobject types appear. |
| 2904 | The trace will enumerate them. | 2971 | The trace will enumerate them. |