Skip to content

perf(webgpu): stop reserving GPU memory in 128-256 MiB blocks - #215

Merged
triniwiz merged 1 commit into
masterfrom
perf/webgpu-memory-hints
Nov 14, 2026
Merged

triniwiz merged 1 commit into
masterfrom
perf/webgpu-memory-hints

Conversation

@triniwiz

Copy link
Copy Markdown
Member

Devices were requested with wgpu's default memory hints. On Vulkan the allocator then reserves device memory in 128 then 256 MiB blocks (host-visible in 64 then 128 MiB), and a reserved block counts as graphics memory in full. A fresh device held 192 MiB with nothing in it, and a 4K texture with mips (85 MiB) cost about 128 MiB because only two fit a block.

MemoryHints::MemoryUsage starts blocks at 8 MiB and gives larger resources an exact-size allocation, as Dawn does.

Measured on Linux (Intel, Mesa) with a headless harness on the native API and a three.js WebGPURenderer scene, process DRM memory before and after:

test before after
empty device 215 MiB 34 MiB
three.js scene, +384 models 287 MiB 183 MiB
three.js scene, +6144 models 335 MiB 237 MiB
16 retained 4K textures 2331 MiB 1716 MiB

Frame rate and render time were unchanged across the scene ramp.

Devices were requested with wgpu's default memory hints, which make the
Vulkan allocator reserve device memory in 128 then 256 MiB blocks and
host-visible memory in 64 then 128 MiB blocks. Reserved blocks count as
graphics memory in full, so a fresh device held 192 MiB with nothing in
it, and a 4K texture with mips (85 MiB) cost about 128 MiB because only
two fit a block.

MemoryHints::MemoryUsage starts blocks at 8 MiB and gives larger
resources an exact-size allocation, as Dawn does. Measured on Linux
(Intel, Mesa) through the native API and a three.js WebGPURenderer
scene, DRM memory before -> after: empty device 215 -> 34 MiB; scene at
+384 models 287 -> 183 MiB; 16 retained 4K textures 2331 -> 1716 MiB.
Frame times unchanged.
@coderabbitai

coderabbitai Bot commented Nov 13, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3749e3a2-ebae-4092-9d3f-996ac53489a8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

Copy link
Copy Markdown

ℹ️ Note: npm publishing is disabled for pull requests.
Publishing is performed only from tag pushes via the npm Release workflow.
If you need a test publish, merge to master — pushes publish pr-tagged prereleases.

@triniwiz
triniwiz merged commit 4106d7a into master Nov 14, 2026
27 checks passed
@triniwiz
triniwiz deleted the perf/webgpu-memory-hints branch November 14, 2026 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant