Shaders: O(1) LRU shader cache, compile coalescing, and mesh CS caching #255
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!255
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/255/head"
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?
@RandomGithub12309 on GitHub · 2026-11-23 21:56 UTC · original
RandomGithub12309:shaders/pso-cache-coalescing-and-mesh-cs→main· +475 −82 · 1 files · 1 commits · closed without mergingPart of #156. Reuse shader translations across PSO workers and mesh/pixel shader pairings.
What is in it
crates/xcl/src/gpu/recomp/pso.rs:VecDequeshader cache with hash buckets and a doubly-linked intrusive LRU order (expected O(1) lookup and eviction under the cache lock, cap 4,096 entries within the 64 MiB budget, full shader-byte verification on hash collisions).(cache, key, blob)via anInFlightleader/waiter (Mutex+Condvar+ panic-safeDropguard) so concurrent waiters share both successful builds and compile failures instead of retrying failing compiles serially, while distinct keys compile in parallel andcached_onlyprobes stay non-blocking.console_mesh, both HLSL andXCL_DIRECT_DXILpaths) under a separateCacheStage::Meshin-memory andv2on-disk cache identity.shader_cache_coalesces_concurrent_same_key_compiles,shader_cache_coalesces_concurrent_same_key_failures), and mesh vs compute disk-cache isolation.Tested
rustc 1.100.0 (0ef1bc386 2026-11-09)stable-x86_64-pc-windows-msvc, Windows SDK DXC 1.8.2502.11 (debug for unit tests, release forsmoke.ps1).cargo test -p xcl --lib gpu::recomp::pso -- --test-threads=1 --nocaptureat80c5ca5: 20 passed, 0 failed, 1 ignored (0 skipped).cargo test --workspace -- --test-threads=4 --skip fuzz_validate_and_gpuat80c5ca5:xcllib 944 passed, 0 failed, 25 ignored (SKIPPEDon this adapter: wave64-only GPU tests andpso_measurement_compiles_an_exact_synthetic_recordbecause Windows Developer Mode is off;gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_{0..3}excluded due to pre-existing0x8007000ECreateComputePipelineStateOOM on this adapter).scripts/smoke.ps1release build at80c5ca5vsmain(8e87fc7).Regression run
Not tested
XCL_SAMPLE_*data, an end-to-end repeatedconsole_meshcache-hit test on a real MS container, and gameplay beyond the 60 s smoke window.AI use
main, added shared failure coalescing and its test, ran the tests andscripts/smoke.ps1on the hardware above, and updated this description. OpenAI Codex (GPT-6) implemented the linked LRU eviction and collision-bucket repair test in the earlier revision.@PHeitor1 on GitHub · 2026-11-23 22:22 UTC · original
Tested on RTX 5060 Ti 8 GB, driver 621.24, Ryzen 5 5600X, Windows 11 Pro 26300 (native), Rust 1.100.0 msvc, debug.
cargo test --workspace --no-fail-fast -- --test-threads=4on the heade336d82: 656 passed, 0 failed, 40 ignored (main60565c4: 651 / 0 / 40). SKIPPED: only the usual twono wave64(gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware).One review note:
evict_oldestscans every entry of every bucket for the minimumlast_used, so eviction is O(n), not O(1) as the title says, and it runs under the global cache mutex. With the cap raised from 128 to 4096, each insert past the cap scans up to 4096 entries while every PSO worker waits on that lock. Lookups are O(1) now, so it is still a win over theVecDeque, but either the title should say so or eviction needs an ordered structure (e.g. aBTreeMap<u64 /*tick*/, ShaderKey>beside the map, or an intrusive LRU list).Run and written with Claude Code (Claude Opus 5.5).
@Kalmarv on GitHub · 2026-11-24 00:13 UTC · original
Tested
6873d46merged ontomain4017f8f(clean withgit merge-tree). No blocker found; one behaviour to know about.swap_remove,eviction_repairs_collision_bucket_after_slot_reusefails. With the shared flight taken out,shader_cache_coalesces_concurrent_same_key_compilesfails with 4 compiles instead of 1.main. Most new tests use the new API and do not build there. The two that can be ported,shader_cache_overwrite_updates_byte_accountingandconsole_mesh_rejects_non_mesh_blob_before_caching, pass onmaintoo: they guard behaviourmainalready has.main. The waiters queue behind the flight and then each run the failing compile again. Handing them the first error would avoid it, if failing translations shared by several pipelines matter.{stage:?}prints the same names), so existing caches are still found. Read, not run.Tested
6873d46merged onto4017f8fas6f6d885;main4017f8fas the control.cargo build --workspace, thencargo test --workspace -- --test-threads=4on the merge: 658 passed, 0 failed, 40 ignored (lib 618 passed, 20 ignored). SKIPPED at run time:gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware(no wave64 on this GPU).cargo test -p xcl --lib -- shader_cache_tests: 14 passed, 0 failed on the merge.Not tested
console_meshcall for the same MS container and sees it served from the cache.main, one run each; we have no title to repeat it.🤖 Claude Fable 5.2
@AC-Storm-YT on GitHub · 2026-11-24 00:25 UTC · original
Test run on AMD RDNA4 – commit
6873d46(this PR's head, as is, not merged withmain), clean treeTested
backend 'real' – AMD Radeon RX 9070 XT); AMD Ryzen 7 9800X3D; Windows 11 Pro build 26200; Rust 1.100.0stable-x86_64-pc-windows-msvc, debug; DXC 1.8.2502.11cargo build --workspace: okcargo test --workspace -- --test-threads=4: 657 passed, 0 failed, 40 ignored. No SKIPPED tests.shader_cache_with_max_entries_keeps_more_and_evicts_lru,eviction_repairs_collision_bucket_after_slot_reuse,shader_cache_overwrite_updates_byte_accounting,shader_cache_coalesces_concurrent_same_key_compiles,translated_disk_cache_isolates_mesh_stage_from_compute,console_mesh_rejects_non_mesh_blob_before_cachingNot tested
smoke.ps1run, so nothing about shader-cache behaviour in a gamemainAI use: run and report by Claude Code (Claude Opus 5.5).
@RandomGithub12309 on GitHub · 2026-11-25 00:57 UTC · original · edited 2026-11-25 01:03 UTC
Updated at
80c5ca5(squashed and rebased ontomain8e87fc7), though #1836 (80f4819) has since merged ontomaincovering O(1)ShaderCache(cap 4,096), in-flight compile coalescing, andStage::Meshcaching.Pull request closed