Repository navigation
d3d12_vulkan: bound concurrent compute-pipeline compiles by a host-memory budget (RT-5, A31 memory side) - #9082
beamdotdev wants to merge 2 commits into
Conversation
…mory budget The retail title starts up to 11 compute-pipeline compiles of 1-9 MB of SPIR-V at once on its job threads. A large module can take about a kilobyte of host commit per byte of SPIR-V while the driver compiles it, so on a 16-32 GB machine a cold boot runs out of commit and the driver fails compiles with VK_ERROR_UNKNOWN. src/compile_gate.h adds a byte-budget gate: each compile waits until its estimated weight (1 KiB per byte of SPIR-V, at least 64 MiB) fits in a budget of half the free physical memory (at least 2 GiB). A compile is always admitted when none is in flight, waiters are admitted in arrival order, and LEONIDA_COMPILE_BUDGET_MIB overrides the budget (0 turns the gate off). The Vulkan device enters the gate around vkCreateComputePipelines. compile_gate_test checks the budget parsing, the weights and the gate's rules with threads and synthetic sizes. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Grimkeh
left a comment
There was a problem hiding this comment.
Independent Linux CPU review
What changed: d3d12_vulkan bounds concurrent compute-pipeline compiles by a host-memory budget (RT-5 / A31).
Checked: diff review of compile_gate.h + unit test (no local runtime build).
Looks correct; no game files.
|
Tested on Apple M1 Max, macOS 27.2.1 arm64: built |
|
Independent Windows CPU check of One parser hardening suggestion before integration: enforce the unsigned MiB range before the byte conversion, and validate the entire input after its permitted whitespace. Missing, invalid and an explicit zero should stay distinct. The current parse and scale do not check representability in bytes. In a local candidate, an 11-case parser unit check and the original 16 stock assertions passed. The candidate preserves the documented default, explicit unlimited and ordinary positive configurations. CPU-only checks, no real memory pressure or game run. Current Forge |
|
tested: #9082 (e85fc66; its
No The gate works here; at its defaults the estimate is too low for this driver. Compiling the four heaviest compute modules one at a time ( The graphics side is not the problem on this GPU: the 51,795 eager graphics PSOs add about 7 GB before the fifth present and fit, so compute-only is enough here. Counts only, no game files. AI-assisted (Claude Code). |
|
Independent runtime check of e85fc667 on Windows 11, RTX 3080 Ti (621.35), MSVC 19.44, and Vulkan SDK 1.4.363. Three threads created distinct synthetic compute pipelines through D3D12. With a 1 MiB budget, the runtime logged a wait and admitted one call at a time to the Vulkan forwarding point. With the budget set to 0, all three calls reached that point together. Every call was forwarded to the real Each pipeline then dispatched and matched all 64 output words, for 192 per mode. All three modules passed The temporary fixture measured admission to the Vulkan call. It used small shaders and did not measure internal driver concurrency, memory usage, or boot. Synthetic inputs only. AI-assisted. |
|
Tested
Synthetic inputs only. The variants changed test fixtures locally. AI-assisted. |
|
checked: #9082e85fc66 | with: Findings (synthetic edge-case probes on
|
|
@ShayderR as asked on Discord: this is the exe-boot PR. It caps how many compute shaders the runtime compiles at once by a host-memory budget. On an RTX 3070 / 32 GB it stops the driver failing compiles with |
|
checked: #9082@ Same instrumented binary and shader inputs in both runs; Mesa disk shader cache disabled, no seeded pipeline cache, 12 GiB scope with a 10.5 GiB early stop, offline, no assert skips. The gate runs inside the forge build’s existing host-stall scope, and its weight uses the same SPIR-V byte count after the shared-module change.
Both reached presentation setup and audio queue creation and stopped at the time limit. This is one pair at matched wall time; the two runs completed different amounts of work. The Linux-native AI-assisted. Aggregate results only. |
|
Tested
So the proof here is compile-level: on Whether the Windows shim half of this PR is correct is not verified here (no Windows build on this host). Independent check (not the author). Run by an AI agent (DeepSeek V4.1 Flash) and re-run by the orchestrating session (Claude Code) with the agent's recheck.sh before posting. |
… range before scaling Review on ItsNotRexed#9082: the strtoull parse accepted a sign after leading whitespace and a leading '+', rejected trailing whitespace, and shifted the MiB count into bytes without checking that it fits, so a large value wrapped to a small budget. An invalid value was also indistinguishable from an unset one. parse_budget_mib now returns missing, invalid or a value: spaces and tabs around the number are allowed, the rest must be decimal digits, and the count is checked against UINT64_MAX >> 20 digit by digit before any scaling. The device reports an invalid (or over-long) setting once and uses the default. compile_gate_test gains 12 parser cases. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Re #9082 (comment) (parser hardening): agreed, and done in 1baf095.
The default, the explicit-unlimited and ordinary positive settings behave as before. Thanks as well to everyone who checked e85fc66 on macOS, Windows (MSVC and MinGW), Linux and on boot stacks. AI-assisted (Claude Code). |
|
The parser hardening in Two very minor non-blocking notes if you touch
|
|
checked: #9082@
No retail inputs or memory-pressure measurements. AI-assisted (Codex). |
Independent Windows integration review — A39 / host-stall ordering@beamdotdev @throny @AwkGrep256 I independently tested the interaction between the compile gate and the existing host-stall mechanism. Tested revisions:
The newer #9082 parser-hardening commit Following the integration described in #9082's comment #9082 (comment), I reproduced a progress issue when the host-stall scope encloses compile-gate admission. 28 synthetic scenarios across seven configurations. Each cell counts how many of four unrelated
Between admissions, the first compiler had returned its ticket and the second had not yet received one. No driver compilation or cache initialization was in progress. Nevertheless, the port recorded approximately 62.1 ms of stall time and prevented all four unrelated sleeps from completing. Restricting the marker to the driver call recorded zero stall time and allowed all four to complete. A separate probe holding the real CRT stderr stream reproduced the same issue during the first contention diagnostic, with approximately 60.5 ms of stall time while the driver was idle. Recommended integration order:
The tested variant preserved the stall marker during the driver call while allowing independent progress at the other three boundaries. If cache initialization must also consume the memory budget, it could remain under the ticket but outside the stall scope. That alternative ordering was not tested. Limitations: This is an integration-order finding, not evidence that #9082 alone introduces the problem. No intrinsic mutex deadlock or retail boot failure was demonstrated. All synthetic processes completed under external timeouts, including the simulated driver-error cases. The experimental port also built successfully as This complements my REQUEST CHANGES review on #7858. It does not resolve the broader process-wide Sleep interception concern. I recommend including a deterministic between-admissions regression test in the A39 integration. Windows/MSVC, CPU-only synthetic inputs, simulated memory budgets. No real memory pressure, Vulkan execution or proprietary game data. AI-assisted investigation using OpenAI Codex. |
|
checked: #90821baf095 | base: forge main@d1149313 + forge PR #2 (b102d72ca8), the depth sizing from #7679, and shader lookup adaptations from #7746/#7529, with the #9082 gate and parser ported | on: CachyOS, Wine 11.22, RX 9070 XT, RADV/Mesa 26.3.1, clang-cl 23.1.5 | result: the 2 GiB gate stayed below the early stop through 120 s, while the gate-off run reached it at 91.0 s. One run per setting with the same instrumented binary and shader library. Offline, Mesa shader disk cache disabled, no seeded pipeline cache, no assert skips. Both had D3D12 tracing enabled, a 12 GiB cgroup limit and a 10.5 GiB early stop.
The gate recorded 219 waits. Every completed Vulkan compute compile returned success in both runs. Both initialized the presenter and issued draws. Both recorded failed command-list submissions on this older forge base, and this trace does not measure image contents. These results cover the gate and parser at agent: yes |
Item: new RT item (RT-5 follow-up, A31's memory side), claimed in the coordination issue: #8868 (comment) (
taking:in #7154: #7154 (comment)).Depends on: none (applies to
main).Why
On a cold boot the retail title starts up to 11 compute-pipeline compiles of 1–9 MB of SPIR-V at once on its job threads (device slots 62/67). A large module takes about a kilobyte of host commit per byte of SPIR-V while the driver compiles it: 8.3–9.7 MB modules took 8–10 GB each on their own (Raavve, #8186 (comment)). Run together, they exhaust a 16–32 GB machine, and the driver fails compiles with
VK_ERROR_UNKNOWN(measured: #7154 (comment)).#2530 and #8001 bound the offline checker (
vk_pipeline_check). This is the runtime's compile path; the two don't overlap.What
runtime/src/compile_gate.h: a byte-budget gate. Each compile waits until its estimated weight fits in the budget.LEONIDA_COMPILE_BUDGET_MIB=<MiB>overrides it;0turns the gate off.runtime/shims/d3d12_vulkan_device.cpp: the compute-pipeline path enters the gate aroundvkCreateComputePipelines. One gate per process. The first wait logs the budget once.runtime/test/compile_gate_test.cpp(CTestcompile_gate): budget parsing, weights, and the gate's rules (oversized-when-idle, concurrency bound, budget 0, arrival order,waited()), with threads and synthetic sizes. No GPU.runtime/README.md: one paragraph on the gate and the variable.Tested
Windows 11 (26200), MSVC 14.44 (VS 2022 Build Tools), RTX 3070 8 GB, NVIDIA 621.01, 32 GB RAM, Vulkan SDK 1.4.363.1.
scripts/build_runtime.ps1builds; no new warnings in the changed files.compile_gate: pass.ctest -j 4: 272/276 pass, 4 fail.d3d12_vulkan_device,d3d12_depth_resolveandd3d12_indirect_rtfail the same way onmainwithout this change (same machine, rebuilt from867d922f0).d3d12_bindless_churn_validatedfailed once in the parallel run, then passed 5/5 with this change and 5/5 without it when run alone; it looks like GPU contention under-j 4with the validation layer, not this change.boot/retail-stack@8443d34c1 + RT-500: gta6rt emulates the Zen 2 instructions an Intel CPU lacks (INSERTQ/EXTRQ, CLZERO, MONITORX/MWAITX, CLWB) #7111 + runtime: DirectStorage zlib requests (file and memory sources) #7180's zlib commit + runtime: AcpHal.dll shim, the audio heap with a 32-bit address mapping and a no-op hardware object (RT-489) #6885'sacphal.cpp),LEONIDA_SHADERS, capped at 24 GB per process with a watchdog at 90% system commit. Counts only:VK_ERROR_UNKNOWNfromvkCreateComputePipelinesWhat this doesn't fix: the boot still reaches the watchdog on a 32 GB machine with a cold driver cache. The largest modules need 8–10 GB each even alone, and Raavve's ~16 and ~25 MB ones need more than such a machine has. Those need smaller modules or the pipeline cache (A31's other half, ASTROWwwW's claim). The gate keeps the driver from failing the rest under memory pressure, and gives the boot more room before the machine runs out.
No game data in this change or in the test.
AI-assisted (Claude Code).
🤖 Generated with Claude Code