D3D12.X: defer compute driver_cache path hashing until RAM cache miss #2909
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2909"
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 real-alponzo on 2026-11-26T22:50:25Z.
Defer
driver_cache::path_for/driver_cache::path(which hashes the full DXIL buffer withfnv64) incompute_containerand the compute pass offinish_two_passuntilcompute_blob(key)misses inCOMPUTE_BLOBS, avoiding unnecessary full-buffer FNV-1a hashing on warm RAM-cache hits.Fixes #2883.
What is in it
resolve_compute_blobincrates/xcl/src/hle/d3d12x/real.rsto check the RAM cache first and only compute/load the on-diskdriver_cachepath on a RAM miss.driver_cache::path_for/driver_cache::pathlazily during writeback so the newly compiled blob is still persisted to disk.compute_blob_cache_tests::resolve_compute_blob_skips_disk_hash_on_ram_hitandcompute_blob_cache_tests::resolve_compute_blob_loads_from_disk_on_ram_miss.Regression run
Base (
main):PR head (
67c26e28):Tested
rustc 1.100.0, DXC 1.9.2602.17.cargo test -p xcl --lib compute_blob_cache_tests -- --nocapture:2 passed; 0 failed; 0 ignored; 1345 filtered out..\scripts\smoke.ps1 -Game "C:\VIctory-SSD-test\game" -Seconds 60on8b957becand67c26e28(blocks above).Not tested
cargo test --workspaceon this exact branch (verified targeted unit tests and paired 60 s retail smoke; CI covers the full suite).AI use
Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-11-26T23:11:19Z.
Full suite on NVIDIA (listed under Not tested): passes. The new RAM-hit test fails with the old order (hash first). No existing test or the e2e title reaches the RAM-hit branch in
compute_container/finish_two_pass, so the helper tests are its only coverage.Tested:
67c26e2(its base is currentmain8b957be, so head = merged). RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug, Graphics Tools (D3D12 debug layer) installed.cargo test --workspace --no-fail-fast -- --test-threads=4SKIPPEDlines (no wave64, refused per-lane forms)compute_blob_cache_tests(2 tests), 3 runsresolve_compute_blobwithdisk_path()called before the RAM check (scratch,main's order)resolve_compute_blob_skips_disk_hash_on_ram_hitfails 3 of 3:disk path / fnv64 must not run on a RAM-cache hiteprintln!indriver_cache::path_forand on each RAM hit,cargo test -p xcl --lib+--test gpu_compute_e2e,mainvs headpath_for4 times, 0 RAM hitse2edebug-layer tests, head vsmain8b957bepath_forBy reading, the writeback is unchanged: when a RAM blob is refused and the build succeeds,
diskis computed beforedriver_cache::keep, anddriver_cache::note(false, …)only runs whenfrom_diskis set, sodiskhas already been computed there.Not tested: a warm title run where a RAM hit happens (none of the suite's builds repeat a program), the saved time, AMD / Intel on this run.
AI use: Claude Code (Claude Opus 5.5) ran the tests and scratch checks and wrote this report.
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-26T23:32:28Z.
Tested: Clean
67c26e28f4d5d148595923ebb254205b07164b83, Windows 11 build 26200, Ryzen 7 3800X, Rust 1.100.0 x64 MSVC, debug.cargo test -p xcl --lib compute_blob_cache_tests -- --nocapture: 2 passed.cargo test -p xcl --lib real::driver_cache::tests -- --nocapture: 4 passed. Both had zero failures, ignores and skips. The RAM-hit case bypassed both disk callbacks, while a miss called each once. The disk fixtures covered cache-key filenames, persistence/readback, refused-file removal, and overlapping writes.A separate optimized synthetic microbenchmark on the same host measured the disk-filename routine at 1.010 ms for 1 MiB and 4.069 ms for 4 MiB (median of seven alternating rounds), versus 0.200 ms and 0.815 ms for the RAM-key routine that still runs on hits. These are isolated routine costs.
Not tested: GPU, driver rejection of a RAM blob through a live pipeline, retail smoke, world-load timings, or the full workspace suite.
AI use: T3 Code / Codex (
gpt-6.2-sol) ran the tests, wrote and ran the isolated benchmark, and drafted the report.Imported from ivall/xcl. Originally posted by upipibi on 2026-11-27T00:12:58Z.
Tested head
67c26e28f4d5d148595923ebb254205b07164b83, merge-base8b957bec6f82495aec940944c6bf47faa02db590, RTX 3070 (Ampere) driver 616.56, Windows 11, rustc 1.100.0 (0ef1bc386 2026-11-09)Debug build, no env vars, no game files.
cargo test -p xcl --lib compute_blob_cache_tests -- --test-threads=1, 3 runs on head:2 passed, 0 failedeach time (resolve_compute_blob_skips_disk_hash_on_ram_hit,resolve_compute_blob_loads_from_disk_on_ram_miss).compute_blob_cache_testsmodule at the end ofreal.rs) applied to the merge-base8b957bec: does not compile,error[E0432]: unresolved importsuper::resolve_compute_blob``, so the tests cannot run there (the function is the PR's new code).cargo test -p xcl --lib -- --test-threads=4(whole lib): head1320 passed, 0 failed(27 ignored); merge-base1318 passed, 0 failed(27 ignored). The +2 is the two new tests.hle::xaudio2tests ran normally, nothing skipped for them.no wave64(RTX 3070 is wave32-only), 3 per-lane form refused (#1426f16 forms), 1pso_measurement_compiles_an_exact_synthetic_record(cannot disable the driver cache / SDK component missing).Not tested: retail title.
AI-assisted (Claude Code, Claude Sonnet 5.5 ran the tests; Claude Opus 5.5 checked and posted).
Imported from ivall/xcl. Originally posted by retrope13 on 2026-11-27T00:16:27Z.
Verified
67c26e28f4d5d148595923ebb254205b07164b83againstmain(8b957bec6f82495aec940944c6bf47faa02db590) on NVIDIA Ada Lovelace (debug +--releasetargeted GPU cache tests and paired full workspace suite).Hardware / toolchain: Windows 11 26H2 (build 26300.9818), Intel Core i5-14500HX, 24 GB RAM, NVIDIA GeForce RTX 4060 Laptop GPU (8 GB, driver
32.0.16.2140/621.40), Intel UHD Graphics (driver32.0.101.7092),rustc 1.100.0(stable-x86_64-pc-windows-msvc), Windows SDK10.0.26100.0(DXC1.9.2602.17).Tested:
cargo test --locked -p xcl --lib compute_blob -- --nocapture(XCL_ADAPTER=NVIDIA):4 passed; 0 failed; 0 ignoredin both debug (0.00s) and--release(0.01s) (covers both newcompute_blob_cache_testsand existingcompute_blob_tests).cargo test --locked -p xcl --test gpu_two_pass_cache_e2e -- --nocapture:XCL_ADAPTER=NVIDIA:1 passed; 0 failed(no skip) in both debug (8.20s) and--release(7.88s).XCL_ADAPTER=Intel/WARP: capability-skipped (SKIPPED ...: no wave64).XCL_ADAPTER=NVIDIA,cargo build --workspace --locked,cargo test --workspace --locked --no-fail-fast -- --test-threads=4, debug):8b957bec:1,446 passed, 0 failed, 47 ignored67c26e28:1,448 passed, 0 failed, 47 ignored(+2 new tests, zero regressions)Code review notes (non-blocking):
resolve_compute_blob(real.rs:4422–4433),compute_container(real.rs:4446–4497), andfinish_two_pass(real.rs:6162–6204) preserve all fallback/writeback behavior (copy.Flags.0is untouched before lazydriver_cache::path_forat4489, and graphics PSOs at5307/6080already usedriver_cache::graphics_path(hash, bytes)without re-hashing DXIL).real.rs:4488,6195), gating lazydriver_cache::path_for/pathondriver_cache::worth_keeping(in_driver)(matchingfinish_two_pass's graphics path at6143–6148) would also skip hashing fast (< 250 ms) retries thatdriver_cache::keepwill not persist.main: on a disk-cache hit (reused && from_disk,real.rs:4495–4497and6202–6204), the loaded compute blob is not promoted intoCOMPUTE_BLOBS(unlikeremember_graphics_blobat6139), so a second build of a disk-warm compute PSO still misses RAM and re-hashes/re-reads disk.Not tested:
AI use:
real.rs, ran the paired debug and release tests, and drafted this verification report.Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-27T00:40:27Z.
Native ordinary compute driver-cache check
On an RTX 5070 with disk caching enabled, the ordinary
compute_containerpath in PR #2909 accepted a native RAM-cached PSO twice without hashing any DXIL bytes for the disk filename. The second acceptance occurred after deleting the on-disk copy. A deliberately invalid RAM blob then forced a native cold retry, which recreated the missing disk file. After evicting the RAM entry, the driver accepted the regenerated file.This was a local test overlay on
67c26e28f4d5d148595923ebb254205b07164b83, with a counter atdriver_cache::name_forand a fresh writable cache. It used actual D3D12 PSO creation and the same program, flags and root signature throughout. The repository's fixture retention switch admitted the small synthetic shader. One test passed, with no skips. The counter covers disk-name hashing only. Two-pass compute, actual world-load RAM-hit frequency, and retail CPU-time savings remain unmeasured. Run logAI use: OpenAI Codex wrote and ran the fixture, inspected the code, and drafted the report.
Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-27T02:06:23Z.
Tested (AMD): clean
67c26e28f4d5d148595923ebb254205b07164b83(base = main8b957bec). Windows 11 26200, Ryzen 7 5700X3D, AMD Radeon RX 7800 XT (driver 32.0.31035.1003), Rust 1.100.0 MSVC, DXC 1.8.2502.11 (Windows SDK 10.0.26100), debug.cargo test -j 4 -p xcl --no-fail-fast -- --test-threads=4thencargo build --workspace+cargo test -p xcl --test e2e: thee2etests need the workspace-built test title, so the first run failed 3 of them for lack of it and the rerun passed 4 of 4. Lib/other targets: 1 failed, 7SKIPPEDlines (no heap windows, refused V_CVT_F16_F32 / V_MUL_F16 / VOP3-modifier forms), 47 ignored. The one failure,gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1(seed 722:res[30] = 0x1, CPU 0x7fffffff), also fails onmain8b957becwith the same seed on this GPU, so it is not from the PR.compute_blob_cache_tests(2) pass, as do the 4driver_cachetests.Review (by reading, no bugs found): the RAM check now precedes the disk-path hash, and after a refused RAM blob the path is computed before
driver_cache::keep, in bothcompute_containerandfinish_two_pass, so persistence is unchanged. Agrees with the earlier reports.Not tested: retail smoke. The
scripts/smoke.ps1run starts with a cold-cache precompile of about 26k shaders, which did not fit this session's time budget, so I did not produce a base/headxcl-smokepair. No runtime hit-rate or timing was measured either.AI use: Claude Code (Claude Sonnet 5.5) ran the checks and wrote this.
Imported from ivall/xcl. Originally posted by LocranKing on 2026-11-27T10:00:31Z.
Tested PR #2909 (
67c26e28) againstmain(8b957bec) on Windows 11 (26300), Ryzen 5 5500 (6C/12T), RTX 3060 Ti 8 GiB (driver621.40),rustc 1.100.0, DXC1.9.2602.17.Unit Tests (
cargo test --locked -p xcl)hle::d3d12x::real::compute_blob_cache_tests::resolve_compute_blob_skips_disk_hash_on_ram_hit: okhle::d3d12x::real::compute_blob_cache_tests::resolve_compute_blob_loads_from_disk_on_ram_miss: ok(
2 passed, 0 failed.)Paired 180 s Retail Smoke (
9cc6a39e, Series Slockhart,XCL_HEAP_WINDOWS=1,XCL_DIRECT_DXIL=all,XCL_DIRECT_SPLIT_INSTRUCTIONS=0,XCL_PSO_WAIT_MS=50)Both runs started from identical pre-warmed DXIL/driver cache snapshots and reached the 3D world (
~60 sin-world):main(8b957bec)67.2 s/188.4 s124014(28windows)29,411 MB14,281 / 2,241 MB9,178draws,34,068dispatches0 / 0(exit: 0x0)67c26e28)109.8 s/229.1 s124715(29windows)30,376 MB14,449 / 2,243 MB12,981draws,51,401dispatches0 / 0(exit: 0x0)Behavior matched
mainwithout regressions (exit: 0x0,0crashes,0device removals).Not tested: Instrumented micro-timing / byte counts of
COMPUTE_BLOBSRAM hits inside the retail title run (verification aspect from #2883), or full workspace test suite on67c26e28.Imported from ivall/xcl. Originally posted by ettehn on 2026-11-27T13:23:48Z.
I reproduced the second follow-up in retrope13’s review on the ordinary compute path. I used a local release build based on
623d02e4(the compute-cache source matches main06f90c19), Windows x64, RTX 5070 Ti Laptop, driver 621.24.I seeded a private cache with
xcl shaders <synthetic-input> --precompile --pipelines. One 45,900-byte DXIL compute shader produced a 56,906-byte driver blob. The probe repeatedly created the same console PSO, resolved it, dispatched it and checked all 64 output words against the CPU result. Production cache thresholds were in effect.This measures a pre-existing distinction relevant to #2883. When profiling repeat creates, it matters whether the first build happened offline or in the running process. Title frequency, world-load impact, two-pass compute and this PR’s head remain unmeasured in this experiment.
OpenAI Codex (GPT-6) assisted with the probe, measurements and report.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-28T23:41:58Z.
Rebase note for #2909 head
67c26e2against currentmain227d2cb: the core RAM-hit optimization is still useful, but the lookup path has changed since this PR's base.compute_containernow constructs a pipeline-library name by hashing the DXIL before the RAM-cache lookup. The two-pass compute path does likewise. Both paths also pass their optional disk path towarm_replay::acceptedwhen a RAM blob succeeds; aNonepath prevents receipt capture. Reusing this PR's old “no disk path on RAM hit” branch during rebase would therefore lose that capture.For the current code, the narrow integration is to form the canonical name once, use it for the pipeline-library lookup and two-pass store, and derive the enabled disk path from that same name without another DXIL hash. Keep the path available on accepted RAM hits for receipt verification, and preserve the loaded-blob generation, rejection retry, and disk-only writeback paths. That removes duplicate filename hashing; the initial library-name hash and the separate RAM-key hash remain. A stronger zero-filename-hash RAM-hit path would need to preserve library lookup precedence and receipt capture explicitly.
Please cover an accepted RAM hit with receipt capture, a library hit, a cold disk hit, and rejected-RAM-to-cold-writeback in a focused regression; then rerun the clean-head paired smoke required for the rebase. I recorded the duplicate comparison with #2998. This is a source review of the current code, not a new build or timing result.
AI use: Codex (GPT-6.2 Sol) compared the exact diffs and current call paths; Codex (GPT-6.2 Astra) independently checked the cache and receipt invariants.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:09:26Z.
Triage (#1607) – head
67c26e2#2998 made the same change and was closed in favour of this PR.
Main has since reworked this code.
compute_containernow hashes the DXIL (driver_cache::name_for_root_node->fnv64(dxil)) for the pipeline-library name before it looks in RAM, and hashes it again inpath_for_root_node.finish_two_passdoes the same. So deferring only the disk path no longer avoids the hash on a RAM hit; it only saves the second one. The rebase needs to defer or reuse both hashes, and the PR conflicts now.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.