Expose DeviceDescriptor::memory_hints via WGPUDeviceExtras - #619
Open
RubyBit wants to merge 1 commit into
Open
Conversation
wgpu's DeviceDescriptor has had memory_hints since MemoryHints was
introduced, but map_device_descriptor hardcoded Default::default()
(Performance), with a `// TODO(wgpu.h)` marker. Performance hints make
gpu-allocator commit 128 MiB device + 64 MiB host memory blocks for the
few tiny internal allocations wgpu makes at device open, so creating a
bare device commits ~200 MiB of VRAM (measured on NVIDIA RTX 4080
Laptop/Vulkan; D3D12 is similar), and all committed memory rounds up in
256 MiB steps. Applications with small or mostly-static workloads have
had no way to opt out through the C API.
Add a WGPUMemoryHints enum (Undefined/Performance/MemoryUsage/Manual)
and memoryHints + suballocatedDeviceMemoryBlockSize{Start,End} fields to
WGPUDeviceExtras, mapped onto wgt::MemoryHints. Zero-initialized extras
keep the previous behavior (Undefined -> Performance).
Measured bare-device committed VRAM (RTX 4080 Laptop, Vulkan):
Performance (old default): 201 MiB
MemoryUsage: 21 MiB
Manual { 4 MiB..256 MiB }: 17 MiB
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
RubyBit
force-pushed
the
expose-memory-hints
branch
from
July 12, 2026 16:55
93db410 to
154a73a
Compare
|
Added by #594 so unless you need this instantly I would prefer to wait. |
Author
|
I see, but when can we expect the PR merged then? v30 also released a few weeks ago. |
|
@RubyBit I would expect within the next month at most for it to be merged, but I have hopes it could happen sooner. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
cargo clippyreports no issuescargo docreports no issues (unrelated to my changes)cargo denyissues have been fixed or added todeny.tomlAdded new functionality. @githubnameDescription
wgpu's DeviceDescriptor has had memory_hints since MemoryHints was introduced, but map_device_descriptor hardcoded Default::default() (Performance) to be changed in the future (so I changed it): Performance hints make gpu-allocator commit 128 MiB device + 64 MiB host memory blocks for the few tiny internal allocations wgpu makes at device open, so creating a bare device commits ~200 MiB of VRAM (measured on NVIDIA RTX 4080 Laptop/Vulkan; D3D12 is similar), and all committed memory rounds up in 256 MiB steps. Applications with small or mostly-static workloads have had no way to opt out through the C API (such as my tensor library which can load pretty small models on the gpu through wgpu and there is an unnecessary, around 200 MiB overhead).
Add a WGPUMemoryHints enum (Undefined/Performance/MemoryUsage/Manual) and memoryHints + suballocatedDeviceMemoryBlockSize{Start,End} fields to WGPUDeviceExtras, mapped onto wgt::MemoryHints. Zero-initialized extras keep the previous behavior (Undefined -> Performance).
Measured bare-device committed VRAM (RTX 4080 Laptop, Vulkan):
Performance (old default): 201 MiB
MemoryUsage: 21 MiB
Manual { 4 MiB..256 MiB }: 17 MiB
Related Issues