mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:35:53 +01:00
[PR #2233] d3d12: a pool of compile workers for the pipeline compiler (RT-ASYNC-COMPILE-POOL) #2236
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#2236
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/2233
Author: @Tyrannys
Created: 11/26/2026
Status: 🔄 Open
Base:
main← Head:claude/rt-async-compile-pool📝 Commits (2)
a83f385d3d12: a pool of compile workers for the pipeline compiler (RT-ASYNC-COMPILE-POOL)2d56b68d3d12: the checkpoint's second look also sees a running demanded build📊 Changes
6 files changed (+710 additions, -44 deletions)
View changed files
📝
docs/d3d12_vulkan.md(+15 -0)📝
runtime/CMakeLists.txt(+12 -0)📝
runtime/README.md(+3 -1)📝
runtime/shims/d3d12_pipeline_compile.h(+174 -40)📝
runtime/shims/d3d12_vulkan_device.cpp(+7 -3)➕
runtime/test/d3d12_compile_pool_test.cpp(+499 -0)📄 Description
Claimed in the coordination issue as: RT-ASYNC-COMPILE-POOL (claim; released by MoonEyes after #2077 was closed)
What and why
With
LEONIDA_ASYNC_PIPELINES=1, every demanded build, the compute warm-up and the startup cache checkpoint run onPipelineCompiler's one general worker (plus #2098's graphics-only worker). One long driver compile therefore holds every pipeline a submission asked for behind it, and their draws and dispatches are skipped meanwhile. This ports MoonEyes' worker-pool design from #2077 onto #2098's scheduler (runtime/shims/d3d12_pipeline_compile.h), keeping its lifetime rules (after_running,cancel,running_here,release,stop_for_exit).PipelineCompilernow runsLEONIDA_COMPILE_THREADSworkers (default half the logical processors, 2 to 8). A worker takes the most urgent job it may:LEONIDA_COMPILE_HEAVY_MAXlarge builds at once (default threads-1; 1 withLEONIDA_SERIAL_BIG_COMPILES=1), compute and graphics alike. Each still takes its place at the memory gate (LEONIDA_BIG_COMPILE_BUDGET_MB). Graphics builds are counted by size even whenLEONIDA_SERIAL_BIG_COMPILES=0clearsgraphics_.large, so the async path follows the same knobs for both.runtime/src/vulkan_device_fault.h) makes every submission wait for each create in flight. With the gate on, their boot's submissions waited 142 s in all behind warm-ups of about 800 KB (5-13.5 s each). WithLEONIDA_COMPILE_GATE=0the same boot reached game state 3 at 130 s and ran 240 s with no fault. Running several warm-ups at once would lengthen those waits; so while the title asks for builds, only those builds are started.after_runningand the teardown rules hold as they were.vkGetPipelineCacheDatasize query.has_compile_waiter(), which the checkpoint asks before the query and again after it, now also answers true while a demanded build runs, not only while one is queued, so the checkpoint stops before the blob read. No warm-up can start in that window: the running checkpoint is the one speculative job allowed.LEONIDA_COMPILE_THREADS=1is the layout before the pool: one general worker and the graphics-only one (LEONIDA_GRAPHICS_COMPILE_WORKER), with the old job order.Not changed here, and still open: a submission still waits at the compile gate for every create in flight, including a warm-up already running. The pool shortens how long a demanded build waits behind another build. It does not stop the gate holding the title's thread, which is what ends brandostrong's synchronous runs at the 30 s watchdog. MoonEyes' two ideas (warm-ups not holding the gate; a cap on the wait) touch the gate itself and belong in a separate item.
Synchronous mode (
LEONIDA_ASYNC_PIPELINES=0, the default) and MoonEyes' finding of 10:31 in #1608 (large compute builds one after another, although the driver compiles about 3.7 times faster on 6 threads): there a build a dispatch asks for runs inside the submission, throughPipelineCompiles::build(runtime/src/vulkan_replay.h) and its memory budget, not on these workers. Only the compute warm-up and the checkpoint go throughPipelineCompilerin that mode, and warm-ups stay one at a time. So this pull request does not change that case; letting more large builds run at once there is a change toPipelineCompiles(or to the warm-up's one-at-a-time rule, which the compile-gate finding above argues against while the title submits) and belongs in its own item.A note on azsekazvamdimitar's report (#1608, 06:42) that graphics jobs of 1 MiB or more are always serial in
PipelineCompiles. On currentmain,graphics_.largeis false withLEONIDA_SERIAL_BIG_COMPILES=0, and otherwise the large ones share the memory budget. The serial builds they saw in the asynchronous path came from the single graphics worker, which this pool replaces.Tested
New CPU test
d3d12_compile_pool(no device). Its jobs wait at gates the test opens, so each rule is checked while the jobs it is about are still running. It covers:release,cancelandstop_for_exitwith jobs running and queued.It passed 8 runs out of 8. Each rule was broken by hand in turn (7 mutants, before the checkpoint fix: checkpoint-when-idle, one job per PSO, the free worker, the heavy count, one warm-up, warm-ups behind demanded builds, waking idle workers), and the test failed for every one.
d3d12_compile_teardownruns with the pool, and as newd3d12_compile_teardown_one_workerwithLEONIDA_COMPILE_THREADS=1. Both pass, as dod3d12_big_compute(all 7 settings),d3d12_m4_compute,big_compile_gate,compile_helper,replay_pipeline_compiles*,pipeline_workersandd3d12_pipeline_workers*.Full runtime CTest,
-j 4(a boot was running on this machine). Everything passes except four:xs_proxy_mockandd3d12_multithreadfailed under that load and pass when rerun alone;xbox_present(presentVkResult -11) andd3d12_set_descriptor_heaps(line 353) fail the same way onupstream/maina73a57e13without this change.python -I tests/test_docs_env_vars.py,test_ctest_registration.py,test_docs_repo_paths.py,test_text_write_line_endings.py,scripts/check_no_game_data.pyon the changed files: pass.Test-merged with the open PRs on the same code: #2198, #2220 and #2208 merge cleanly. #1756 conflicts in
d3d12_vulkan_device.cpp, but it already conflicts withmainby itself. It also moves the checkpoint to priority 1, so whichever lands second must keep "checkpoint only when idle" keyed on the checkpoint, not onSIZE_MAX.No real boot was run with this change; the boot session will test it.
GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.01, Windows 11
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly.docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.