[perf] UIRenderer::Dispatch heap-allocates a std::vector per custom dispatch (UI-WebGPU.cpp) #132

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

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

Location: implementations/Crafter.Graphics-UI-WebGPU.cpp:180-207
Severity: low · Effort: trivial · Category: allocation

Problem

UIRenderer::Dispatch builds a std::vector<uint32_t> handles with reserve, forcing one malloc+free per dispatch; custom compute dispatches run per-frame. The count is bounded and known at pipeline-load.

Fix

Fixed-capacity std::array<uint32_t, kMaxBindings> or a reused thread_local vector. Secondary WebGPU path, modest absolute cost.

Found by an adversarially-verified performance audit (confirmed real after a skeptic pass). **Location:** `implementations/Crafter.Graphics-UI-WebGPU.cpp:180-207` **Severity:** low · **Effort:** trivial · **Category:** allocation ### Problem `UIRenderer::Dispatch` builds a `std::vector<uint32_t> handles` with `reserve`, forcing one malloc+free per dispatch; custom compute dispatches run per-frame. The count is bounded and known at pipeline-load. ### Fix Fixed-capacity `std::array<uint32_t, kMaxBindings>` or a reused `thread_local` vector. Secondary WebGPU path, modest absolute cost.
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#132
No description provided.