[perf] WebGPU full-buffer readback copies entire allocation even for a small prefix (WebGPUBuffer.cppm) #133

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: interfaces/Crafter.Graphics-WebGPUBuffer.cppm:117-128
Severity: low · Effort: moderate · Category: memory

Problem

EnqueueReadback / PollReadback always pass the full size; over-provisioned event-queue buffers copy full capacity GPU→staging→wasm per drain.

Fix

Add a byteCount parameter for the live prefix. Constraint: the live event count is GPU-written / unknown at enqueue, so only a fixed header prefix is trivially shrinkable; the variable array needs a two-stage readback.

Found by an adversarially-verified performance audit (confirmed real after a skeptic pass). **Location:** `interfaces/Crafter.Graphics-WebGPUBuffer.cppm:117-128` **Severity:** low · **Effort:** moderate · **Category:** memory ### Problem `EnqueueReadback` / `PollReadback` always pass the full `size`; over-provisioned event-queue buffers copy full capacity GPU→staging→wasm per drain. ### Fix Add a `byteCount` parameter for the live prefix. Constraint: the live event count is GPU-written / unknown at enqueue, so only a fixed header prefix is trivially shrinkable; the variable array needs a two-stage readback.
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#133
No description provided.