Prefer cached host memory for readback allocations - #42
Merged
conda-forge-admin merged 2 commits intoAug 20, 2026
Merged
Conversation
Contributor
|
Hi! This is the friendly automated conda-forge-linting service. I just wanted to let you know that I linted all conda-recipes in your PR ( |
Contributor
Author
hmaarrfk
force-pushed
the
prefer_cached_host_memory_for_readback
branch
from
August 20, 2026 02:12
3c328ce to
59571ec
Compare
Contributor
|
Hi! This is the friendly conda-forge automerge bot! I considered the following status checks when analyzing this PR:
Thus the PR was passing and merged! Have a great day! |
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.
Readback (
MemoryLocation::GpuToCpu) allocations land on uncached memory on Intel iGPUs since wgpu v28, making CPU reads of mapped buffers about 100x slower than RAM. This carries a one-hunk fix ingpu-allocatoruntil it can be upstreamed.Mechanism
wgpu v28 switched the Vulkan backend from
gpu-alloctogpu-allocator(gfx-rs/wgpu#8158).gpu-allocator'sGpuToCpupath triesHOST_VISIBLE|HOST_COHERENT|HOST_CACHED, then falls back toHOST_VISIBLE|HOST_COHERENT— both requireHOST_COHERENT. Intel's ANV on Arrow Lake exposes cached memory and coherent memory but never both, so every readback allocation lands on the uncached (write-combined) type.gpu-allocscoredHOST_CACHEDas a preference rather than a requirement, which is why this only appears from v28 on.Measured on one
VkDevice, one heap, Arrow Lake iGPU — allocating from each host-visible type and timing an 8 MiB CPU read:The patch adds one attempt between the two that already exist: try
HOST_VISIBLE|HOST_CACHEDbefore giving up and taking a coherent-but-uncached type. It is safe becausewgpu-halalready keysflush_mapped_ranges/invalidate_mapped_rangesoff the allocation's real property flags (vulkan/device.rs:993), so non-coherent memory is fully supported — it was simply never selected.Effect
Same machine, same Mesa, only the library differing (8.29 MB mapped read):
Confirmed on a second Arrow Lake machine on a different Mesa (25.2.8): 24.45 GB/s on 27, 0.23 GB/s on 29 stock, 24.59 GB/s on 29 + patch — so this tracks the adapter's memory types, not the driver version. A Tiger Lake iGPU is unaffected either way because it does expose a
COHERENT|CACHEDtype, as are all NVIDIA adapters for the same reason. A standalone Rust reproducer against thewgpucrate puts the boundary at v28.0.0 exactly (v27.0.1 = 1.0x, v28.0.0 = 86.6x, v29.0.4 = 86.4x).Why
gpu-allocatoris vendored as a second sourcegpu-allocatoris pulled from crates.io duringcargo build, so a feedstock patch cannot otherwise reach it. Adding it as a secondsource:with a[patch.crates-io]override is the only way to carry the fix without forking wgpu-native itself. The vendored version (0.28.0) and its sha256 match what wgpu-native's committedCargo.lockalready resolves, so the dependency graph is unchanged apart from the patch.Two conda-build details worth flagging for review:
fn:set to a.tar.gzname. A.cratefile is a gzipped tarball, but conda-build dispatches extraction on the file extension and.crateis not in itsdecompressible_exts, so without this it is copied into the source tree rather than unpacked and the patch has nothing to apply to.[patch.crates-io]is honored because wgpu-native'sCargo.tomlis itself the workspace root ([workspace] members = ["."]).This should be upstreamed and removed
Submitted upstream as Traverse-Research/gpu-allocator#311. The patch is intended to be dropped as soon as it lands there, and the extra
source:entry and the[patch.crates-io]patch go with it. This is a temporary carry, not a permanent feedstock divergence.What is not tested
Measured on Linux/x86_64 with Intel and NVIDIA adapters. Windows, macOS/Metal and AMD were not tested. The patch only affects the Vulkan path's
GpuToCpumemory-type search; on adapters that expose a coherent+cached type the new branch never executes, and on non-Vulkan backends it is not reached at all.Checklist
0(if the version changed) — n/a, version unchangedconda-smithy— done by the webservices bot on this branch.