Skip to content

Avoid the extra JavaScript copy in WebGPU buffer uploads - #5

Draft
JulianRuiseco wants to merge 1 commit into
patch-27.0.1from
jrr/wasm-upload-memory-view
Draft

JulianRuiseco wants to merge 1 commit into
patch-27.0.1from
jrr/wasm-upload-memory-view

Conversation

@JulianRuiseco

Copy link
Copy Markdown

WebGPU uploads currently allocate and copy each Rust slice into a new JavaScript Uint8Array. Pass the borrowed WASM slice to writeBuffer instead. WebGPU snapshots its source synchronously, so the slice need not outlive the call.

Validation: Linux Bazel built the SpatialEngine WASM consumer with this patch. On an M4 Max, repeated OS1-128 replay overload runs completed 448-469 MiB/s versus 426-431 MiB/s before the change. Both changed runs had an 18.0 ms p95 browser animation-frame interval. GPU readback matched all 32 sampled writes (425,824 bytes). Warm 8x replay remained near 388 MiB/s in both variants.

This removes one JavaScript allocation and copy per write; browser-internal copies remain. Chromium WebGPU was tested. Safari and Firefox runtime checks remain open. Browser animation-frame timing does not prove complete visible frames.

@fslabs-bot fslabs-bot Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 4, 2026
@fslabs-bot

fslabs-bot Bot commented Oct 4, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@fslabs-bot fslabs-bot Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant