Repository navigation
vk_pipeline_check: a hard per-process memory cap on Windows, so a runaway driver compile can't exhaust the system's memory - #8371
Conversation
…ct), so a runaway driver compile fails the checker instead of exhausting the system's commit
|
Tested 1ec48c5 on Windows 11 (MSVC 14.44, Vulkan SDK 1.4.363.0, 32 GB RAM) with Intel UHD 730 (101.7085) and RTX 4060 (621.14), against its merge base 47428cc where it matters. Synthetic input only: the 248 translated test fixtures from
Not covered: a real runaway module (no game files here), so the cap was never reached during a pipeline compile. AI-assisted run. |
|
AI-assisted defensive review of |
|
Tested
Two notes:
Conflict with #8001. Merging this with #8001 conflicts in Not covered: a real runaway module, because I have no translated shaders from the game. AI-assisted. |
… be set up is an error before Vulkan (review of ItsNotRexed#8371)
|
Thanks both. Pushed @GonZiin: agreed, fixed. An explicit @jeangoes: thanks for the RTX 4060 / UHD 730 runs. I added your finding to Re-tested on Windows 11, MSVC 14.51, RTX 3080 (621.14): |
… cap below 256 MiB is a usage error, and a failed vkCreateDevice under a cap names it (review of ItsNotRexed#8371)
|
@user9517 thanks, both notes taken. Pushed in the latest commit:
#8001: noted. Whichever of the two lands second gets the mechanical fix in the Re-tested on Windows 11, MSVC 14.51, RTX 3080 (621.14): |
Raxstreams
left a comment
There was a problem hiding this comment.
Independent check of 5b8efed5656091929a0b619d90bba439d4c58464, synthetic inputs only.
Windows 11 25H2, MSVC 19.44, RTX 3080 Ti (617.14): large_module_gate, process_memory_cap, and vk_pipeline_check_cli passed (3/3). The CLI test's simulated cap setup failure returns 2 before reading the index for an explicit cap. A single SPIR-V compute pipeline passed under --isolate at 256 and 1024 MiB, with the child reporting the budget derived from the cap. A missing Vulkan ICD manifest made the child report setup failure (exit 1), while the existing simulated-abort hook produced a module failure with child status 3. The build host was already in a Windows job, so I used the checked-in failure hook for the cap-assignment failure case.
Linux result (Ubuntu 24.04 on WSL2, GCC 13.3, llvmpipe): the option claims to enforce a cap even though the Linux implementation of apply_process_memory_cap returns success without applying one. With the same minimal shader, the default run succeeded and budgeted from 16.0 GB of available memory. --memory-cap-mb 256 also returned 0, printed “256 MiB per checker process”, and budgeted from the requested value. --memory-cap-mb 64 was rejected before reading the index. This contradicts the off-Windows behavior described in docs/pipeline_check.md and could make a caller think its explicit limit was installed. Could the option's validation, success line and budget override be restricted to Windows, or could an explicit nonzero cap report that it is unsupported off Windows?
AI-assisted (Codex).
|
Windows follow-up on the #8001 conflict. I trial-merged On RTX 4070 Ti SUPER (617.14, Windows 11 28000.3501), the combined checker compiled the same small synthetic compute pipeline with |
|
Independent Linux check of 5b8efed. Bazzite 45 x86-64, RTX 3070 / NVIDIA 620.73.04, Python 3.15.2, GCC 16.2.1; built this head's checker against the pinned Vulkan headers. Synthetic inputs only.
These checks pass on Linux. They exercise CLI/error propagation and the portable paths only: process_memory_cap.h deliberately does not install a hard cap off Windows. I did not validate Windows job-object enforcement, a runaway driver compilation, or game-corpus behavior. No merge approval implied. AI-assisted with Codex. |
New BUILD item, claimed in the coordination issue: #8186 (comment)
What and why
vk_pipeline_check's large-module budget (large_module_gate.h, refined by #6429 / #8001) estimates a module's memory before it enters the driver. It can't stop one module that allocates far past the estimate, and on Windows such a module takes the whole machine down with it, not just the checker.Measured on Windows 11, RTX 3080 (NVIDIA 621.14), 32 GB RAM, during
make_game.py's pipelines stage on my own 1.0.2.1 copy (wave64-emulated corpus): oneRTShadowTrace32TemporalHQ_Tiledcompute module, retried alone by the stage, took the checker to about 69 GB of private bytes. Windows reached its commit limit, other running programs andWerFault.exefailed with0xC000012D(STATUS_COMMITMENT_LIMIT), and the display driver reset.This puts the checker into a job object with
JOB_OBJECT_LIMIT_PROCESS_MEMORY, so past the cap the driver's allocations fail inside the checker. The driver then returns an error (as NVIDIA does here) or the checker dies, which the existing crash path already handles (--inflight-file,--isolate, the stage's retry alone).Changes
runtime/test/process_memory_cap.h(new):default_process_memory_cap()(the physical memory size on Windows, 0 elsewhere) andapply_process_memory_cap(bytes, error), which creates the job, sets the limit and assigns the current process. No-op off Windows: a Linux container orsystemd-run -p MemoryMax=...already caps the process, and the budget reads that limit.runtime/test/vk_pipeline_check.cpp:--memory-cap-mb N(default: physical memory;0= off), applied right after argument parsing, before any Vulkan call, and passed to--isolatechildren (which are in the same job anyway; the limit applies per process). A failure to set the job is a warning, not an error. The cap is printed on stderr at start.runtime/test/process_memory_cap_test.cpp+runtime/CMakeLists.txt: testprocess_memory_cap. On Windows it caps its own process at 256 MiB and checks that a 512 MiB commit fails while 32 MiB still succeeds, and that a nested 128 MiB cap (an--isolatechild inside the parent's job) applies too; elsewhere it checks the functions are no-ops. No Vulkan device.docs/pipeline_check.md: a section on the cap with the measurement below.make_game.pyneeds no change: the pipelines stage runs the checker without the option, so it gets the default cap.Tested
Windows 11 (build 26200), MSVC 14.51 (VS 18 Build Tools), RelWithDebInfo, RTX 3080 with NVIDIA 621.14.
ctest -R "process_memory_cap|large_module_gate|vk_pipeline_check_cli": 3/3 pass.The module from the incident, alone:
vk_pipeline_check <work>/shaders/spirv cache.bin --start 20880 --count 1 --jobs 1 --memory-cap-mb 16384, sampling the checker's private bytes and the system's free commit every 0.5 s:0xC000012D, display driver resetNVVM compilation failed: 3;cs pipelines: 0 ok, 1 failed; the checker exited normally; at least 9.9 GB of system commit stayed freeDocs tests:
test_docs_repo_pathspasses with the new file.test_docs_cli_flags,test_docs_design_rowsandtest_docs_linksfail identically on unchangedmain(embedded_shaders.md,README.md,dev-tools.md), unrelated to this change.scripts/check_no_game_data.pyon the changed files: clean.Counts and error classes only; no game data. AI-assisted (Claude Code).