Repository navigation
Conversation
…re speculative (RT-BIG-COMPUTE-BUDGET) LargeModuleGate moves to runtime/src (a forwarding header keeps vk_pipeline_check and its test as they are) and gets a second constructor, whose budget is read whenever a place is given or returned. Its modules get in in the order they came, a speculative one only while no demand waits and within a quarter of the budget. large_compile_budget_bytes() is three quarters of the smaller of the free RAM and the room under the commit limit. CPU test: the bound, one always, order, priority, every wake-up, the budget of the moment and the setting.
…T-BIG-COMPUTE-BUDGET) Compute modules over 128 KiB and graphics pipelines of 1 MiB of SPIR-V or more wait at one gate for the process until their estimates fit the memory that is free, instead of one at a time. PipelineCompiles::build gives a submission as many lanes for them as can be in at once, largest first, and fills the rest with small ones. A thread that waits for its place holds no PSO's lock, and one that has a place waits for none. The warm-up's compiles are speculative. LEONIDA_SERIAL_BIG_COMPILES=1 keeps one at a time, 0 has no limit, LEONIDA_BIG_COMPILE_BUDGET_MB fixes the budget.
…his change) Local merge of pull/1889/head (aa8018b) so that the async compile pool can build on its memory gate. This commit is not part of the pull request: the pull request depends on ProjectLeonida#1889. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…POOL) PipelineCompiler ran every LEONIDA_ASYNC_PIPELINES=1 build, the compute warm-up and the cache checkpoint on one below-normal thread, so one long driver compile held every pipeline a submission asked for behind it, and their draws and dispatches were skipped meanwhile. - LEONIDA_COMPILE_THREADS workers: unset, half the logical processors, at least 2 and at most 8; 1 is the one thread there was, with the same order of jobs. - At most N-1 workers in heavy builds (the warm-up's, and demanded builds of large modules), so one is left for a small build a submission asked for. - One very large build (1 MiB of SPIR-V or more) at a time, demanded or not: LEONIDA_COMPILE_HEAVY_MAX. - One job of a PSO at a time, which keeps after_running and the lifetime rules as they are. - A checkpoint starts only when no worker is in a build; has_compile_waiter counts a build that is running. - Large builds wait at the memory gate of ProjectLeonida#1889 inside their job, as before. Tests: pipeline_compiler_pool (the rules, with made-up jobs, no GPU), d3d12_compile_pool (a GPU, the large build held in flight) and d3d12_compile_teardown, the last two with the default, 1 and 4 workers. d3d12_big_compute's warm-up case no longer assumes one warm-up thread. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…t heavy, not for any small one Light builds are not limited, so graphics pipelines below the large size can still take every worker at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Numbers from my side for why the pool matters on NVIDIA (RTX 4070 Laptop 8 GB, 621.40, retail, traced with
So pool + #1914 + one shared cache dir covers it: the first boot compiles side by side, and the boots after it pay nothing. This branch (044d9ba) on the same machine: Counts and program names only. AI-assisted (Claude Code). |
|
Three game runs with this PR (head 044d9ba), asked for on Discord. One run each. Build: main
What the two losses share: a READ_INVALID (type 1, precision 4096, pages
AI-assisted (Claude Code, Claude Opus 5.5). |
|
Addition to my table above: a later sync run (m79, |
|
In-game A/B on one binary, from my own box (RTX 4060 desktop, 12 logical processors, driver 610.88, Windows 11). Same executable (this branch at 044d9ba), two 300 s boots with
So on this machine the two runs present the same number of frames, and the pool run reaches game=3 session=3 (the landing screen) about 50 s sooner (states are sampled every 5 s). Almost every compile in these runs is the warm-up's (1,093 of 1,099 in the pool run, 900 of 906 in the 1-thread run; 5 from draws and 1 from a dispatch in each), so this boot barely exercises the reserved lane for demanded builds. Limits: one run of each, one machine. The 1-thread run went first, and a ctest run of another checkout was going during its first 190 s or so, not during the pool run, so part of the 50 s may be that load. An earlier pool run of the same executable, made before the 1-thread run and while a build was running, reached the same state at 145 s, so run order alone does not explain the gap; that run presented 2,340 frames, so frame counts move by about 12% between runs. The driver's shader cache was already warm from earlier boots. The graphics pipeline library (#1592) is not built here (0 fspx_gfx): the game's mesh pipeline streams (12,244 per run) are accepted but none shows up among the traced compiles, and every build of 2 s or more is a compute pipeline. Counts only, no logs. AI-assisted: yes (Claude Code ran the boots and read the digests; I reviewed it) |
|
Closing this one. #2098 changed the same scheduler another way: a graphics worker, the compile helper and the compile gate. This branch is built on the single thread from before and conflicts with main in 12 places of My later runs did not show the 50 s gain again: run-to-run noise on my machine (RTX 4060) is about 50 s. As I read the compile gate, more builds at once also means a submission waits for the longest of them. If demanded builds still queue on main with the helper on, I will claim a small follow-up on top of #2098. Thanks to everyone who tested this. AI-assisted: yes (Claude Code, Claude Fable 5.2, read both trees and wrote this) |
…COMPILE-POOL) With LEONIDA_ASYNC_PIPELINES=1 every demanded build, the compute warm-up and the cache checkpoint ran on one general worker (plus a graphics-only one), so one long driver compile held every pipeline a submission asked for behind it, and their draws and dispatches were skipped meanwhile. PipelineCompiler now runs LEONIDA_COMPILE_THREADS workers (half the logical processors, 2 to 8). A worker takes the most urgent job it may: - demanded builds first, in the order they came, then warm-ups by size, then the checkpoint, which waits until no worker compiles; - large builds (compute over 128 KiB, graphics of 1 MiB or more) and warm-ups together take at most threads-1 workers, so one stays free for a small demanded build; at most LEONIDA_COMPILE_HEAVY_MAX large builds at once (default threads-1, 1 with LEONIDA_SERIAL_BIG_COMPILES=1), compute and graphics alike, each still within the memory gate; - warm-ups run one at a time, and none starts while a demanded build runs: each holds the compile gate for its whole create, and a submission waits for every create in flight; - one build of a PSO at a time, so after_running and the teardown rules hold. LEONIDA_COMPILE_THREADS=1 keeps the layout before the pool. The design is MoonEyes' (#2077), ported onto #2098's scheduler. Tests: d3d12_compile_pool (CPU, jobs held at gates: settings, a long build does not hold up a small demanded one, heavy count, free worker, warm-ups one at a time and after demanded builds, order, one job per PSO, release/cancel/ stop_for_exit with jobs in flight), and d3d12_compile_teardown also with one worker. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 (aa8018b).
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 Integrate post-story-load memory, queue and Vulkan fixes (RT-POST-STORY-RUNTIME) #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 d3d12: write the session pipeline cache when the run ends with the device alive (RT-SESSION-CACHE-AT-EXIT) #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 d3d12: large pipelines compile side by side within a memory budget (RT-BIG-COMPUTE-BUDGET) #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 d3d12: large pipelines compile side by side within a memory budget (RT-BIG-COMPUTE-BUDGET) #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 d3d12: large pipelines compile side by side within a memory budget (RT-BIG-COMPUTE-BUDGET) #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