perf(ui): reuse handles vector in WebGPU custom Dispatch (#132) #148
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Graphics!148
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/issue-132"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
UIRenderer::Dispatch(implementations/Crafter.Graphics-UI-WebGPU.cpp:180) built a freshstd::vector<uint32_t> handleswithreserveon every call, forcing one malloc+free per dispatch. Custom compute dispatches run per-frame, so this is pure per-frame allocation churn.Fix
Made the vector
thread_localandclear()it at the start of each call. Capacity grows to the high-water mark once and is reused thereafter — no allocation after warmup. Chose a reused vector over a fixedstd::arraybecause the binding count is a runtimestd::vectorwith no static upper bound, andthread_localkeeps it valid even if dispatches ever cross threads. Behavior is byte-for-byte identical.Testing
crafter-build test— 24 passed. The WebGPU custom-dispatch path itself is browser-only (CRAFTER_GRAPHICS_WINDOW_DOM-guarded) so it isn't exercised by the native suite directly; the change is a behavior-preserving mechanical refactor that compiles clean across the full build.Resolves #132