Repository navigation
Conversation
An async pipeline keeps its description with copies of its shader bytecode until it is built. A title that creates tens of thousands of pipelines from a few thousand shaders held one copy per pipeline (about 84,000 pending pipelines on a retail title); with the copies shared, its commit at 80 s was about 1 GB lower (27,016 MB against 27,972 MB). own_shader and own_stream now intern the bytes (a weak map keyed by hash and length, compared in full), so every pipeline with the same shader holds the same Arc<[u8]>. shaders_key takes any byte slices.
|
Checked 44d6921 on Windows with an RX 7900 XT. The title run adds this PR to the #782 residency comparison and uses the same saved Series X profile, 28 GiB job cap, 6 GiB texture budget, and A press at 75 seconds. The disk cache directories started from the same snapshot. The AMD driver cache persisted. At 150.26 s, queued or active descriptors referenced 588 MiB of shader bytes counting duplicates. The interner held 185 MiB of live payload and 2 MiB of payload behind expired weak entries, about 401 MiB less than retaining each reference separately. The process committed 28,231 MB at that sample, versus 28,117 MB without #827 at 150.07 s. Texture and driver allocation patterns varied. The run had an explicit native compute creation E_OUTOFMEMORY (0x8007000e) at 151.450 s, peaked at 28,440 MB sampled process commit, and exited with 0xc0000409. No device removal was logged. The weak-cache entry has a lifetime detail. Arc<[u8]> allocates the bytes inline, so Weak<[u8]> retains the backing allocation after strong_count reaches zero. An 8 MiB standalone allocator probe on the installed MSVC Rust toolchain measured 8,388,624 bytes retained after the final owner dropped, versus 40 bytes for Arc<Vec> with Weak<Vec>. A local change to Arc<Vec> preserves pointer sharing between descriptors and releases the payload with the last strong owner. Both shader-key and sharing tests pass with that representation. The retail sample retained only 2 MiB in expired entries, so this specific issue does not account for the memory peak. |
|
Shader allocation lifetime on A separate
|
|
Test run of Tested
Review: Sharing the shader bytes of pending pipelines as Not tested: no retail title or regression run (I have no unpacked game), release build. Run and review by Claude Code (Claude Opus 5.5) on this machine. |
|
Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, applied on That is one more passing test than AI-assisted (opencode): applied the patch to a built tree, ran the suite, restored the two files. |
|
Paired 150 s runs of
So the interning saving is real and measurable on a second host in a plain 150 s window: ~120 MB here, consistent in both the 80 s sample and the peak. Smaller than the 1 GB figure from your longer stacked run, as expected — this window creates far fewer pending pipelines than a full world load, and the saving should scale with the pending population. Frame pacing identical (60 presents / 2 s throughout both). The AI use: GPT-6.2 Astra (API model selector) in DSH built both commits, ran the paired runs, and drafted this comment; the human contributor reviewed the numbers before posting. |
|
Linux / AMD RDNA3 datapoint. Merged state: head Full suite, Not tested: retail titles (none here), Windows, RDNA4. Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting. |
|
Code/CI review only (not independently runtime-tested by me): clean merge with both checks green ( |
An async pipeline keeps its description with copies of its shader bytecode until it is built. A title that creates tens of thousands of pipelines from a few thousand shaders held one copy per pipeline. own_shader and own_stream now intern the bytes in a weak map keyed by (fnv64, length) with full-byte comparison, so pending pipelines with the same shader share one allocation while different bytes stay separate. Adapted from PR xcl-dev#827 by Cattn (44d6921): - Store Arc<Box<[u8]>> instead of Arc<[u8]> so Weak entries do not pin the inline shader byte payload in heap memory after the last strong OwnedDesc drops (measured 32 x 1 MiB own_compute drop: +33,755,136 B retained with Arc<[u8]> vs +8,192 B with Arc<Box<[u8]>>). - Prune expired weak entries in amortized O(1) once the map reaches its growth threshold so control blocks and buckets stay bounded. - Add unit tests exercising own_compute, own_graphics, and own_stream with equal and different shader bytes. Co-Authored-By: Gemini 4 Neon <noreply@google.com> (cherry picked from commit dfbb0e5f9db742c967095e08c538dcadd16b7462)
# Conflicts: # crates/xcl/src/hle/d3d12x/real.rs
…blob by its bytes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Verification on RTX 3060 Ti (Windows 11): merge conflict with current |
An async pipeline keeps its description, with copies of its shader bytecode, until it is built. A title that creates tens of thousands of pipelines from a few thousand shaders holds one copy per pipeline. A retail title had about 84,000 pending pipelines; with the copies shared, its commit at 80 s was about 1 GB lower (27,016 MB against 27,972 MB, in a longer run on a branch with other changes).
What is in it
crates/xcl/src/hle/d3d12x/real.rs:intern_shader_blobkeeps a weak map from (hash, length) toArc<[u8]>, compares the bytes in full, andown_shader/own_streamstore the sharedArcinstead of aVec<u8>copy.shaders_keytakes any byte slices. A unit test checks that equal shaders share one copy, different ones do not, and that a copy is made again once every pipeline released it.Tested
cargo test --workspace --no-fail-fast -- --test-threads=4on 44d6921: 702 passed, 0 failed, 41 ignoredgpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64)Regression run
The first smoke run of this commit came right after two others with a warm shader cache, got further into loading in its 60 s and peaked at 22,423 MB. I ran main and this PR again back to back; these are the second pair.
main:
this PR:
Not tested
AI use
🤖 Generated with Claude Code