Files
metal2vulkan/docs
Anees Iqbal 6e5dc3b087 memory: a small heap's pooled blocks are at most a sixteenth of it, and none is made before a placement needs it
What: a pooled block's size is per memory type now, from its heap (memory::pooled_block_bytes):
64 MiB in every heap of 1 GiB or more, as before, and in a smaller heap the largest power of two
within a sixteenth of it, at least 1 MiB (8 MiB in a 246 MiB heap), never past the largest
allocation. A pool of such a small heap (Memory::small) gets no room kept at creation calls
(keep_room), no block made ahead (memory/ready.rs: makes_ahead and keep_ahead skip it), and the
placement that finds no room makes its block itself. A placement past half of its memory type's
block takes a block of its own. Large heaps behave as before: no first encoding makes a 64 MiB
block it did not make before.

Why: without unified memory the WriteCombined class ranks DEVICE_LOCAL|HOST_VISIBLE first, which
on an NVIDIA GPU without Resizable BAR is the 246 MiB heap of its 256 MiB BAR. keep_room kept room
for half a 64 MiB block in that pool at each device's first command queue, whatever the program
placed there. Measured with tests::many_devices at 655ed906fb (NVIDIA 620.70.06): BAR1 used grew
67 MiB a device for the first three devices (RTX 2080: 5, 72, 138, 205 MiB; RTX 3090 in 16
processes: 3, 70, 137, 204 MiB), and the heap then held no fourth block (later devices' pools
show no block of type 5), 3 MiB a device after that. A consumer saw the kernel refuse later
devices' BAR mappings on the 2080 (vkCreateDevice: VK_ERROR_INITIALIZATION_FAILED).

Tests: tests::memory::a_pooled_block_is_at_most_a_sixteenth_of_a_small_heap (the rule and its
bound over heap sizes; fails at the base, which has no rule); tests::small_heap (every heap made
small by a stand-in: a device's first command queue makes no block and starts no making, and a
write-combined buffer makes its pool's first block, of the heap's block size). Verified on
lavapipe (ms01, cpu_icd, job m3-max-16047): both pass, with the touched modules' 32 tests, and
clippy -D warnings under m2v_cpu_icd is clean. Device evidence before and after on the 2080 and
the 3090 follows with the next commits.

docs/FAST-PATHS.md: the memory blocks' row states the small-heap rule and its cost (about eight
times as many blocks for the same placements there, none made ahead of its need).
2026-11-11 08:31:42 -08:00
..