d3d12: LEONIDA_ASYNC_MIN_BYTES, only large pipelines asynchronous (RT-ASYNC-LARGE-ONLY) #2440
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!2440
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2440"
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?
@OreoFR on GitHub · 2026-11-27 08:05 UTC · original
OreoFR:rt-async-large-only→main· +224 −4 · 9 files · 1 commits · merged 2026-11-27 10:47 UTCClaimed in the coordination issue as: RT-ASYNC-LARGE-ONLY
What and why
LEONIDA_ASYNC_PIPELINESis all or nothing (runtime/shims/d3d12_pipeline_compile.h). On an RTX 4070 Laptop (NVIDIA 621.40), retail, wave64-emulated pack:=1: the world phase is reached but the screen stays black. Every draw or dispatch whose pipeline is not built yet is skipped, including the small lighting and post programs. The Linux/Proton NVIDIA report indocs/running.mdsays the same.=0: a submission waits for each of the ~700 ray-tracing compute programs (2-26 MB of SPIR-V, 2-3 minutes each in the driver). We measured 17 builds in 30 minutes, so the world start would take hours.This adds
LEONIDA_ASYNC_MIN_BYTES=<n>, used withLEONIDA_ASYNC_PIPELINES=1:PipelineCompilesbuilds it at prepare, and a compile-helper build waits for its file.async_build. The decision lives inruntime/src/async_pipeline_size.h, which is pure stdlib.0, or text that isn't a decimal number (logged): every pipeline is asynchronous. The code path is the same as today.What changed in
d3d12_vulkan_device.cpp:graphics_.async_buildandpipeline_.async_buildtake the size into account.build_compute, the worker's publication inqueue_build, andrequest_early.Graphics follows the same threshold, measured by the total size of all its stages. The NVIDIA report's black stretch was graphics pipelines of 1-2.6 MB compiling one at a time, so a threshold above that leaves them blocking as with
=0, and one below makes them asynchronous.Not changed: a large asynchronous build still goes through the compile gate and
LargeModuleGate, so a mid-size build that a submission waits for can queue behind it there. The docs paragraph says so.Tested
async_pipeline_size_test(new): parsing (unset, empty, 0, max, overflow, suffixes, signs, spaces, hex) and the decision (off, on with no threshold, below/at/above 2 MiB, 1 byte, 2^64-1).d3d12_m4_compute --async-small-waits(new ctestd3d12_m4_compute_async_small_waits): async on, threshold over both modules, warm-up off, and every compile-worker job held by a job probe until the results are read. Both dispatches must run in place (all words match) and no build may reach the worker.LEONIDA_ASYNC_MIN_BYTES=0forced into the test, a build went to the compile worker.LEONIDA_ASYNC_MIN_BYTESunset,1,2097152and1073741824:d3d12_compile_teardown,d3d12_m4_compute,d3d12_m4_compute --async-small-waitsandd3d12_m4_compute --check-async-journal(withLEONIDA_ASYNC_PIPELINES=1). All pass.=2MiBlogs that it is ignored.ctest(RelWithDebInfo, Ninja, MSVC): 490 of 492 pass.xbox_presentandd3d12_set_descriptor_heapsalso fail on plainmaind1dff7949on this machine (both rebuilt frommainand rerun).tests/test_docs_*.pypass.scripts/check_no_game_data.pyis clean on every changed file.LEONIDA_ASYNC_PIPELINES=1 LEONIDA_ASYNC_MIN_BYTES=2097152; the result will be posted in #1608.GPUs tested: NVIDIA GeForce RTX 4070 Laptop 8 GB, driver 621.40, Windows 11.
AI-assisted: yes (Claude Code, Claude Opus 5.5)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: runtime only)🤖 Generated with Claude Code
@OreoFR on GitHub · 2026-11-27 08:23 UTC · original
First retail result with this PR (RTX 4070 Laptop 8 GB, NVIDIA 621.40, Windows 11). Build:
maind1dff7949+ #2412, #2418, #2260 (#2220, #2233), #2020, #2166, #1851, #2432 and this PR. Shaders: the current pack with DadaCap's one-lane-fold library. Settings:LEONIDA_ASYNC_PIPELINES=1+LEONIDA_ASYNC_MIN_BYTES=2097152,LEONIDA_VALUE_WAIT_TIMEOUT_MS=30000,LEONIDA_MAP_READBACK=1,LEONIDA_HOST_IMAGE_COPY=0,LEONIDA_DEVICE_TYPE=6,LEONIDA_SERIAL_BIG_COMPILES=0, the recorded prewarm, no Aftermath, default title windows, 24 GB page file.MEASURED (n=1). AI-assisted (Claude Code, Claude Opus 5.5).@OreoFR on GitHub · 2026-11-27 08:48 UTC · original
Repeat, same build and recipe: the opening scene renders again, from about 9 min in, and stays up to the end of the 20-minute run, with no device loss. Peak private bytes were 52 GB.
MEASURED (n=2). AI-assisted (Claude Code, Claude Opus 5.5).@OreoFR on GitHub · 2026-11-27 09:09 UTC · original
Threshold comparison, same build and recipe, 20 min each, world drawn in both:
LEONIDA_ASYNC_MIN_BYTESOn this 8 GB laptop, 1 MiB looks better: shorter stalls when a mid-size pipeline is built in place, and less host memory. The frame rate is the same, because that comes from per-submission costs (
textures150-270 ms,heaps), not from compiles.MEASURED (n=1 each). AI-assisted (Claude Code, Claude Opus 5.5).@timbot103 on GitHub · 2026-11-27 10:41 UTC · original
Independently checked head
76099a22fon Windows 11 Pro 26200, MSVC 2022 (19.44.35230.0, RelWithDebInfo, Ninja), Vulkan SDK1.4.363.0, WSLllvm-mc 21.1.8, no game files.Local build & dual-GPU verification:
async_pipeline_size_testandd3d12_m4_compute_testwith zero new warnings in the PR-modified files.async_pipeline_size_test: PASS (async_pipeline_size_test: ok).d3d12_m4_compute_test(both default and--async-small-waits) withLEONIDA_VK_VALIDATION=1:616.64, subgroup32..32): default 1924/1924 words matched (error 0);--async-small-waits1924/1924 words matched (error 0), 0 validation errors.25.10.30.02, subgroup32..64): default 1924/1924 words matched (error 0);--async-small-waits1924/1924 words matched (error 0), 0 validation errors.Code review notes:
parse_min_bytes(runtime/src/async_pipeline_size.h) handles exactUINT64_MAXoverflow guarding and cleanly rejects signs, whitespace, suffixes, hex, and non-ASCII bytes; function-local static init is thread-safe, graphics sums all stages' post-patch SPIR-V sizes, and every former global async check now reads the per-PSOasync_buildflag.d3d12_m4_compute_async_small_waitsverifiesworker_jobs == 0when the threshold is above both modules, without a positive control proving the held job probe intercepts a queued job when a module is at/above the threshold. SettingLEONIDA_ASYNC_MIN_BYTESbetween the two modules' sizes (or adding a--async-held-controlcase without the threshold expecting>= 1held job) would exercise both sides of the gate.Overall looks sound and clean. AI-assisted.
@aslan2142 on GitHub · 2026-11-27 10:47 UTC · original
Merging.
LEONIDA_ASYNC_MIN_BYTESlets small compute pipelines build on the calling thread instead of going to the compile worker. Nothing changes while the variable is unset.d3d12_m4_compute_async_small_waitsfails onmain(one build reached the compile worker) and passes with this change.main2859d0c9b+ #2418, #2440, #2432 and #2439, integrated RDNA2 GPU (RADV, Mesa 26.3.1):xdxr_build_check(a timeout under load) andxmem_no_write_watch, both flaky here.ctest: 115 of 116, the same timeout.Thanks @OreoFR.
AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)