Repository navigation
vk_pipeline_check: the large-module memory budget reads macOS's free memory - #5167
sovljanskii wants to merge 1 commit into
Conversation
Kam471
left a comment
There was a problem hiding this comment.
Built and ran large_module_gate_test at f16628387 on Windows 11: large_module_gate: ok, exit 0; git diff --check clean.
The large-module memory budget now has a macOS branch that reads the host's free memory (the same gate that used cgroup limits on Linux and GlobalMemoryStatusEx on Windows), so a Mac host is no longer treated as unlimited; the docs row and the added checks cover the new source and the existing ones. I cannot run the macOS path here. No blocking issue.
|
@Kam471 thanks for building it on Windows; the unchanged paths matter too. One detail for whoever merges: before this, a Mac wasn't treated as unlimited. It was the opposite. |
|
Tested f166283 merged onto main 3faac55 on an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, RelWithDebInfo:
AI-assisted (Claude Code). |
|
Independent check of f166283 on Apple M4 Pro, macOS 27.2.1, MoltenVK 1.4.2. large_module_gate passed. With two workers, vk_pipeline_check reported 15.5 GB available, set an 11.6 GB budget, and compiled both synthetic compute pipelines. When I forced the memory query to fail in the test process, it switched to one-at-a-time compilation and both still passed. I lowered the size threshold to exercise both paths with small synthetic modules. Peak memory and throughput on multi-megabyte modules were outside this check. No game files used. AI-assisted. |
|
Built and ran f166283 on Apple M5 Pro (20-core GPU), MoltenVK 1.4.2, macOS 27.3 (arm64), LLVM 23.1.6.
The failure is Heads-up: the branch is a long way behind |
…memory available_memory_bytes() returned 0 on macOS, so a Mac always took the old exclusive gate: each module over 4 MiB compiled alone while the other threads waited. It now returns hw.memsize times kern.memorystatus_level, the kernel's free percentage (what memory_pressure prints as "System-wide memory free percentage"). Metal compiles in MTLCompilerService rather than in the checker, so the reservation is for system memory and the system-wide level is the one to read. Apple M4 (24 GB), MoltenVK 1.4.2, two disjoint sets of 24 translated compute modules over 4 MiB, cold Metal cache: 1,291 s one at a time, 701 s within the budget (16 GB, 5 threads); 24/24 pipelines ok both ways, system free level never below 80%. large_module_gate_test checks the value on macOS too (non-zero, at most hw.memsize); against the previous header it fails there.
|
Thanks @jgrizon. The branch is now rebased onto I reran it on Apple M4, MoltenVK 1.4.2, macOS 27.2.1, with a native RelWithDebInfo build. agent: yes |
f166283 to
ea72fea
Compare
Item: new, claimed here. Follow-up of #4278. Depends on: none.
Why
#4278 lets large modules (over 4 MiB) share a memory budget instead of compiling one at a time. The budget comes from
available_memory_bytes()inruntime/test/large_module_gate.h, which readsMemAvailableon Linux andullAvailPhyson Windows and returns 0 anywhere else. On a Mac it is always 0, so the checker always falls back to the old exclusive gate: each large module compiles alone while the other threads wait.What
large_module_gate.h. An__APPLE__branch returnshw.memsize×kern.memorystatus_level/ 100. That is the kernel's own free percentage, the onememory_pressureprints as "System-wide memory free percentage"; it counts purgeable and compressible pages too. If eithersysctlfails, or the level is outside 1..100, it returns 0 and the old gate stays.large_module_gate_test.cpp. On macOS the value must be non-zero and at mosthw.memsize. Against the previous header the test fails there (available_memory_bytes() > 0).docs/pipeline_check.md. Names the macOS source and adds the M4 measurement.Why the system-wide level. Metal compiles in its
MTLCompilerServiceprocesses, not in the checker. One 4 MiB module took 11.7 s of wall time, but only 0.3 s of the checker's own CPU and 0.24 GB of its RSS. MeanwhileMTLCompilerServiceheld about 2.3 GB for a large module. So the 512-bytes-per-SPIR-V-byte reservation is still about right on a Mac, but the memory lives outside the process.Measured
Apple M4 (24 GB), macOS, MoltenVK 1.4.2, with modules translated from my own 1.0.2.1 copy (counts only). Metal keeps its own shader cache, so I used two disjoint sets with matched size distributions: 24 translated compute modules over 4 MiB each, 124.7 and 126.2 MiB in total. Each set ran once with no cache entries for its modules:
Tested
large_module_gate_test: ok. ctest-R "large_module|pipeline_check": 2/2.vk_pipeline_checknow printslarge modules (over 4194304 bytes): up to 5 at once within 15.8 GB (3/4 of the 21.1 GB available)on the M4, instead ofone at a time.python -I tests/test_docs_*.py: all 10 OK.git diff --checkis clean.GPU: Apple M4, MoltenVK 1.4.2. No game data in the change or here. AI-assisted.