Shaders: capture hashes and copies a shader outside the capture lock #3295
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3295"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T06:18:56Z.
Every pipeline creation passes its shaders through the capture
(statistics of submitted / unique shaders). It held the global STATE lock
while hashing the bytecode and copying it, so pipelines created on several
threads (the background pipeline workers) could wait on each other there
(not measured). The
hash is now computed before taking the lock, the bytecode is copied only
for a shader not seen before, and the per-kind statistics are counted in a
second short critical section.
Ported from amd-dev
48cf7139(its gpu/shader.rs part), raylitebull.What is in it
crates/xcl/src/gpu/shader.rs:capturehashes before locking, copies only a new shader, counts kinds in a second short sectionTested
cargo test --workspace --no-fail-fast -- --test-threads=4on7d52779e: 2604 passed, 4 failed, 49 ignored. The 4 failures aregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3(E_OUTOFMEMORYfromCreateComputePipelineState, seeds 70 / 545 / 1019 / 1507), the same as on main on this machine; they pass on another RTX 5070 Ti. SKIPPED GPU tests: 44 notices, almost allno wave64.Regression run
main:
this PR:
Not tested
AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-29T06:21:07Z.
Concurrent capture check on Ryzen 7 5700X3D, Windows, exact parent
b10cc4c6and head7d52779e. Eight synchronized threads submitted 64 immutable 256 KiB containers each, alternating a shared input with a thread-specific one. Each fresh process therefore saw 512 submissions, 9 distinct contents, and 256 submissions each under cs and ps.All 12 runs produced exactly 9 unique captures, 9 kind and unknown-part counts, both correct stage totals, and one byte-for-byte match under the expected FNV key for every input. The copy remains inside the first STATE lock on each unique hash. On this workload the parent copied 128 MiB there (512 inputs); the head copies 2.25 MiB (9 inputs) and hashes all 128 MiB outside the mutex.
For scale, six alternating paired runs of the optimized native CPU harness (base/head/head/base repeated) took 145.6–158.0 ms on the parent and 17.6–18.6 ms on the head for the worker section. The harness compiled the production capture/dedup/statistics prefix and container parsing, substituted a successful readability gate for owned buffers, and replaced downstream logging/dumping with an in-memory capture sink. This is workload wall time, not a measurement of time blocked inside the lock or end-to-end pipeline creation. It establishes the duplicate-heavy case; all-unique traffic still serializes the copies.
OpenAI Codex prepared and ran the synthetic controls and drafted this report.