mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:35:53 +01:00
[PR #2077] [CLOSED] d3d12: a pool of workers for the pipeline compiler (RT-ASYNC-COMPILE-POOL) #2083
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#2083
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/2077
Author: @MoonEyes
Created: 11/25/2026
Status: ❌ Closed
Base:
main← Head:feat/async-compile-pool📝 Commits (7)
4aa21d1runtime: large compiles wait for memory in arrival order, demand before speculative (RT-BIG-COMPUTE-BUDGET)aa8018bd3d12: large pipelines compile side by side within a memory budget (RT-BIG-COMPUTE-BUDGET)7f81254local base: #1889 (RT-BIG-COMPUTE-BUDGET, not part of this change)93c4654d3d12: a pool of workers for the pipeline compiler (RT-ASYNC-COMPILE-POOL)2465003Merge remote-tracking branch 'origin/main' into feat/async-compile-pooleacb44fdocs: the compile pool keeps a worker for a demanded build that is not heavy, not for any small one044d9baMerge remote-tracking branch 'origin/main' into feat/async-compile-pool📊 Changes
17 files changed (+3708 additions, -278 deletions)
View changed files
📝
docs/d3d12_vulkan.md(+53 -9)📝
docs/pipeline_check.md(+1 -1)📝
runtime/CMakeLists.txt(+70 -2)📝
runtime/README.md(+4 -1)📝
runtime/shims/d3d12_pipeline_compile.h(+181 -33)📝
runtime/shims/d3d12_vulkan_device.cpp(+84 -17)➕
runtime/src/large_module_gate.h(+275 -0)📝
runtime/src/vulkan_backend.h(+15 -1)📝
runtime/src/vulkan_replay.h(+60 -14)➕
runtime/test/big_compile_gate_test.cpp(+426 -0)➕
runtime/test/big_compute_module.h(+298 -0)➕
runtime/test/d3d12_big_compute_test.cpp(+1007 -0)➕
runtime/test/d3d12_compile_pool_test.cpp(+352 -0)📝
runtime/test/d3d12_compile_teardown_test.cpp(+25 -11)📝
runtime/test/large_module_gate.h(+2 -179)➕
runtime/test/pipeline_compiler_pool_test.cpp(+561 -0)📝
runtime/test/replay_pipeline_compiles_test.cpp(+294 -10)📄 Description
Claimed in the coordination issue as: RT-ASYNC-COMPILE-POOL (#1608, comment 7169077699)
Depends on: #1889 (the memory gate for large pipelines), #1756 (conflicts: both change has_compile_waiter; whichever lands second rebases). This branch is #1889 plus the pool commit and a doc fix, with main merged in; review the commits after #1889's head (
aa8018b7f).What and why
rt::d3d12::PipelineCompiler(runtime/shims/d3d12_pipeline_compile.h) runs everyLEONIDA_ASYNC_PIPELINES=1build, the compute warm-up and the cache checkpoint on one below-normal thread. One long driver compile holds every pipeline a submission asked for behind it, and their draws and dispatches are skipped meanwhile.In-game observations (reported by OreoFR on the project Discord, quoted with his permission)
Numbers as OreoFR reported them; I did not measure them and they are not reproduced here.
replay_skips=0) the device holds after the world starts: 6,191 indirect draws recorded at 176 s, then 11,211 later in the same run.Hypothesis, which OreoFR is checking and which is not confirmed: a dispatch skipped because its pipeline is not ready may leave a later compute looping, waiting for a value that never comes.
This pool reduces skips and compile walls. It does not reduce the per-frame cost in steady state.
Change
LEONIDA_COMPILE_THREADSworkers: unset, half the logical processors, at least 2 and at most 8.1is the one thread there was, with the same order of jobs.LEONIDA_COMPILE_HEAVY_MAX(default 1,0for no limit of its own). This is on top of the memory gate, which admits what fits the free memory and would let the three ScreenProbes modules in together.after_running,delete thisand the lifetime rules of #1723 as they are.has_compile_waiter()now counts a build that is running on another worker.It continues the idea of #1577 by madhyn (closed by its author) on the current lifetime model, with the priority-aware gate that #1577 was missing.
Beyond the claim
The claim (#1608, comment 7169077699) said "half the logical processors, at most 8". This sets a minimum of 2, so that 2 or 3 logical processors still leave a worker for demanded builds;
LEONIDA_COMPILE_THREADS=1gives the one thread.LEONIDA_COMPILE_HEAVY_MAX(one build of 1 MiB of SPIR-V or more at a time) was not in the claim: it was added after OreoFR's report of NVVM failing when the three ScreenProbes modules compile together.Limits
pipeline_cache.session.binis more often skipped at device teardown (~Device does not write it while a build is active); the exit write of #1950 waits 1 s, then writes the pipelines finished so far.stop_for_exitmay detach N threads instead of one when its wait runs out.LEONIDA_COMPILE_THREADS=1on this branch stands for main in the measurements; main itself was not measured.Credit: OreoFR for the in-game measurements, DadaCap for the mesh branch used in the traced runs, madhyn for the idea of #1577.
Tested
pipeline_compiler_pool(new, no GPU): the rules with made-up jobs. 17 mutants, each removing or weakening one rule (reserved worker, one job per PSO, checkpoint at rest, the very large limit, the wake-up, the settings), all fail it.d3d12_compile_pool(new, GPU; default, 1 and 4 workers): a large module's build held in flight; with several workers 64 small pipelines are built and their dispatches store the right values meanwhile, with one worker none is.d3d12_compile_teardownwith the default, 1 and 4 workers: itsGatenow holds every worker.d3d12_big_compute_warmupis #1889's test (TheGeogeo), changed here because it assumed one warm-up thread and failed with the pool (once in ctest, then 3 of 6 runs): the warm-up threads are now the compiler's threads, taken from the job probe; "module 0 enters first" is checked only with one worker; and the "place is taken" check counts large creations only, since the warm-up's small ones may start on the other workers. The order check (the submission's four large builds between two of the warm-up's) is unchanged. If #1889 changes this test, this commit rebases on it.ctest -R "compile|pipeline|big_compute|d3d12_compute|session", with maine18b59a5bmerged in: 31 of 31 (before the pool, on #1889 alone with-R "compile|pipeline|big_compute|d3d12_compute", 24 of 25:big_compile_gatetimed out on a loaded machine and passes alone).tests/test_docs_*.py: 50 passed.d3d12_compile_pool_test measure 4194304 200 <seed>(one 4 MiB module the driver takes 92 to 173 s over, then 200 modules of 12 KiB, two alternating runs each, on a machine that was building other things): the 200 are ready after 1.3 and 6.9 s with 6 workers, after 99 and 152 s with one thread. Peak commit 714 and 720 MiB against 645 and 681.GPUs tested: NVIDIA GeForce RTX 4060, driver 610.88, Windows 11
AI-assisted: yes (Claude Code wrote the code, the tests and this text; the game measurements are OreoFR's).
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.