Repository navigation
vk_pipeline_check: large modules share a memory budget instead of compiling alone - #4278
Merged
shayderrr merged 1 commit intoNov 23, 2026
Conversation
…piling alone Modules over --large-module-bytes compiled one at a time with every other thread waiting. On the translated corpus that is 695 modules (the ray-tracing compute shaders, ~14k RDNA2 instructions each, ~4.9 MB of SPIR-V), about 12 s and 2 GB each on RADV GFX1201, so the pipelines stage spent hours mostly single-threaded. large_module_gate.h lets large modules in while 512 bytes per SPIR-V byte fits 3/4 of the memory available at start (Linux: MemAvailable and the cgroup v2 memory.max room up the tree; Windows: ullAvailPhys), one always admitted when none is in, small modules never held back. Unknown memory keeps the old exclusive gate, as does --large-parallel 1. malloc_trim(0) after each large module returns what glibc kept in per-thread arenas. 40 modules (27 large), Mesa shader cache off, RX 9070 XT / Mesa 25.3.6: 297 s -> 83 s on 6 threads (7.1 -> 8.3 GB peak), 56 s on 12 threads (15.1 GB). Tested: large_module_gate_test (Linux, and the clang-cl build under Proton), ctest on Linux (40 passed, 2 skipped), vk_pipeline_check over 40 real modules in three modes, and the pipelines stage over the corpus with the gate: 26,000+ of 26,503 modules in 15 min, none failed. The largest module (26 MB of SPIR-V) was still compiling alone on RADV after 25 min, as it would under the old gate. AI-assisted.
Contributor
|
Tested 1c604af on NVIDIA GeForce RTX 5070, driver 621.01, Windows 11 Pro 26300, i7-14700K / 64 GB, MSVC 14.44 RelWithDebInfo (
The available figure is plausible: Windows reported 47.7 GB free of 63.7 GB just before.
Baseline on No game files. AI-assisted (Claude Code). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Item: new, claimed here.
Depends on: none. Complements #3623 (batching and crash attribution in
make_game.py) and #2530 (Windows commit cap). It doesn't touchmake_game.py.Why
vk_pipeline_checkcompiled every module over--large-module-bytes(4 MiB) alone, with every other thread waiting. On the translated corpus that is 695 modules, the ray-tracing compute shaders. The console originals are already ~14k RDNA2 instructions each (median ~590 for the rest), and the translator emits fewer SPIR-V bytes per instruction for them than for the rest, so the size isn't translator bloat. On RADV each one takes ~12 s and ~2 GB. The pipelines stage spent hours mostly single-threaded.What
runtime/test/large_module_gate.h:--jobs.MemAvailable, capped by the cgroup v2memory.maxroom of the process and every parent (containers,systemd-run -p MemoryMax=). On Windows it isullAvailPhys. If it can't be read, the old exclusive gate is kept.--large-parallel N:0(default) uses the budget,1restores the old behaviour,Ncaps the count without a budget. It is forwarded to--isolatechildren.malloc_trim(0)on glibc. The process grew past one module's peak even one at a time because glibc keeps freed memory in per-thread arenas: 16 modules on 6 threads used 6.2 GB, against 2.1 GB withMALLOC_ARENA_MAX=1.--inflight-filestill names every module in flight when a large one enters or leaves. With several large modules in flight,make_game.pyalready checks each alone.Measured
RX 9070 XT, RADV GFX1201, Mesa 25.3.6, Fedora 43, Mesa shader cache off. 40 consecutive modules, 27 of them over 4 MiB:
--large-parallel 1, old default)All 40 pipelines OK in every mode.
Tested
large_module_gate_test(new, no GPU): budget and count, an oversized module admitted alone, ticket release, 8 threads never exceeding the budget, cgroup limits read up the tree. Passes on Linux and as the clang-cl/xwin build under Proton.cteston Linux: 40 passed, 2 skipped (game data or layers not present), 0 failed.vk_pipeline_check_clipasses. The Windows cross-build ofvk_pipeline_check.exelinks.No game data in the change or here. AI-assisted.