[perf] No buffer suballocator — vkAllocateMemory per buffer (VulkanBuffer.cppm) #113

Closed
opened 2026-06-17 21:16:02 +02:00 by jorijnvdgraaf · 0 comments

Found by an adversarially-verified performance audit (finding confirmed real after a skeptic pass).

Location: interfaces/Crafter.Graphics-VulkanBuffer.cppm:116-135
Severity: high · Effort: large · Category: allocation

Problem

Every Create issues a full create + getMemoryRequirements + vkAllocateMemory + bind + getDeviceAddress, with one VkDeviceMemory per buffer. Mesh::Build alone burns 4+ allocations per mesh. vkAllocateMemory is kernel-heavy and the total live allocation count is capped by maxMemoryAllocationCount (~4096 on many drivers), so many-mesh scenes hit a hard ceiling.

Fix

VMA-style block suballocator: allocate large blocks and hand out (offset, size) sub-ranges bound at non-zero offsets; persistently map one HOST_VISIBLE block and slice the pointer. Must thread offsets through bind/map/unmap, the device-address query, Resize in-place reuse, and the fence-keyed deletion queue.

Found by an adversarially-verified performance audit (finding confirmed real after a skeptic pass). **Location:** `interfaces/Crafter.Graphics-VulkanBuffer.cppm:116-135` **Severity:** high · **Effort:** large · **Category:** allocation ### Problem Every `Create` issues a full create + getMemoryRequirements + `vkAllocateMemory` + bind + getDeviceAddress, with **one `VkDeviceMemory` per buffer**. `Mesh::Build` alone burns 4+ allocations per mesh. `vkAllocateMemory` is kernel-heavy and the total live allocation count is capped by `maxMemoryAllocationCount` (~4096 on many drivers), so many-mesh scenes hit a hard ceiling. ### Fix VMA-style block suballocator: allocate large blocks and hand out `(offset, size)` sub-ranges bound at non-zero offsets; persistently map one HOST_VISIBLE block and slice the pointer. Must thread offsets through bind/map/unmap, the device-address query, `Resize` in-place reuse, and the fence-keyed deletion queue.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Catcrafts/Crafter.Graphics#113
No description provided.