Skip to content

vk_pipeline_check: large modules share a memory budget instead of compiling alone - #4278

Merged
shayderrr merged 1 commit into
ItsNotRexed:mainfrom
radv-tinker:pr/pipeline-check-memory-budget
Nov 23, 2026
Merged

shayderrr merged 1 commit into
ItsNotRexed:mainfrom
radv-tinker:pr/pipeline-check-memory-budget

Conversation

@radv-tinker

Copy link
Copy Markdown
Contributor

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 touch make_game.py.

Why

vk_pipeline_check compiled 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:

  • Large modules enter the driver while their estimates (512 bytes of RAM per SPIR-V byte; measured ~330) fit 3/4 of the memory available at start, up to --jobs.
  • One is always admitted when none is in, so a module larger than the budget still compiles, alone among the large ones.
  • Small modules are never held back.
  • Available memory on Linux is MemAvailable, capped by the cgroup v2 memory.max room of the process and every parent (containers, systemd-run -p MemoryMax=). On Windows it is ullAvailPhys. If it can't be read, the old exclusive gate is kept.
  • --large-parallel N: 0 (default) uses the budget, 1 restores the old behaviour, N caps the count without a budget. It is forwarded to --isolate children.
  • After each large module, 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 with MALLOC_ARENA_MAX=1.
  • --inflight-file still names every module in flight when a large one enters or leaves. With several large modules in flight, make_game.py already 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 modules Threads Wall time Peak RAM
alone (--large-parallel 1, old default) 6 297 s 7.1 GB
budget (new default) 6 83 s 8.3 GB
budget (new default) 12 56 s 15.1 GB

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.
  • ctest on Linux: 40 passed, 2 skipped (game data or layers not present), 0 failed.
  • vk_pipeline_check_cli passes. The Windows cross-build of vk_pipeline_check.exe links.
  • The full pipelines stage with the new gate: 26,000+ of 26,503 modules in 15 min, none failed (before: ~19,750 in several hours). The largest module (26 MB of SPIR-V) was still compiling alone on RADV after 25 min; it is alone under the old gate too.

No game data in the change or here. AI-assisted.

…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.
@traeb0n

traeb0n commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 1c604af on NVIDIA GeForce RTX 5070, driver 621.01, Windows 11 Pro 26300, i7-14700K / 64 GB, MSVC 14.44 RelWithDebInfo (scripts/build_runtime.ps1, llvm-mc 23.1.6 so the translated-shader targets build), Vulkan SDK 1.4.363, LEONIDA_VK_VALIDATION=1 for ctest: pass, including the Windows side of the budget (ullAvailPhys).

  • Build: exit 0, 0 compiler warnings. Full ctest -E loader -j 4: 150/150. large_module_gate (8.9 s) and vk_pipeline_check_cli pass when run alone.
  • vk_pipeline_check over the 214 modules run_gpu_tests.py translates (<work>/spirv), --jobs 8 --large-module-bytes 1, so every module goes through the large-module gate:
--large-parallel gate line printed pipelines wall (2nd run)
1 large modules checked exclusively: 214 cs 104, ps 93, vs 10, ms 6, gs 1: all ok, 0 failed 0.2 s
0 (default) up to 8 at once within 38.8 GB (3/4 of the 51.8 GB available), checked within the memory budget: 214 same, all ok 0.1 s
4 up to 4 at once, checked within the memory budget: 214 same, all ok 0.1 s

The available figure is plausible: Windows reported 47.7 GB free of 63.7 GB just before. ullAvailPhys also counts standby pages, so it reads a little higher. With the default 4 MiB threshold, no test module counts as large, and the run is unchanged (all ok).

  • These modules are tiny, and the NVIDIA driver cache was warm after the first run (5.4 s cold, then 0.1 to 0.3 s), so the timings show the gate doesn't cost anything. They don't show a speedup. That needs the ray-tracing corpus modules, which I don't have.

Baseline on main 03b09a0, same machine and settings: 150/150 ctest, 0 compiler warnings.

No game files. AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants