D3D12.X: keep the driver-blob disk cache under 2 GiB, least recently used out first #3330
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3330"
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 Prime1997 on 2026-11-29T08:40:28Z.
Requested by Prime
Nothing removed a driver blob file once written: a blob the driver refuses is dropped, but the files of every older driver, adapter, title build and translator change stay in
<DXIL cache>\driverfor good, and lowering the time thresholds (so more pipelines skip the driver's compile in the next run) would make it grow faster. On the PC below that folder held 3.1 GB in 13,677 files.The first blob a run keeps now sweeps that folder once, on a thread of its own: past the cap (
XCL_PSO_DISK_CACHE_MAX_MB, no cap by default: unset or 0 means none and nothing is swept) the least recently used.psofiles go until three quarters of the cap are left. A file read again gets its last access time set (at most once a day), not its last write time, which the warm-replay recipes check.What is in it
crates/xcl/src/hle/d3d12x/real.rs:sweep/sweep_once(threadxcl-blob-sweep, info lineD3D12.X: driver-blob disk cache over N MiB: removed ...), the cap fromXCL_PSO_DISK_CACHE_MAX_MB, last-access marking on reads; teststhe_disk_cap_comes_from_the_environment,the_least_recently_used_files_go_down_to_three_quarters_of_the_cap,a_sweep_removes_old_blobs_and_leaves_other_filesREADME.md:XCL_PSO_DISK_CACHE_MAX_MBTested
cargo test --workspace --no-fail-fast -- --test-threads=4with the threeuma_drivertests below skipped, on829df023be: 2608 passed, 0 failed, 49 ignored (SKIPPED GPU tests: 28 lines: 21no wave64(this card runs wave32), 3 a wave32 per-lane form refused by the translator (#1426), 2no heap windows(opt-inXCL_HEAP_WINDOWS=1), 1no dxc.exe, 1cannot disable the driver cache(needs Windows Developer Mode))cargo test -p xcl --lib -- --test-threads=1 uma_driver::tests::a_refused_gpu_upload_segment_becomes_custom uma_driver::tests::mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment uma_driver::tests::failed_restore_stops_before_importing_an_unbacked_window): 3 passed, 0 failed. They are left out of the whole run because on this PC's driver they can end the library test process (exit 0x7c10003, "coherent window could not be restored"), onmaintoocargo test -p xcl --lib -- --test-threads=4, same skips): 2469 passed, 0 failed; 2469 passed, 0 failedmainfa204595a4: 2605 passed, 0 failed, 49 ignored, 28SKIPPEDlines (own-prs-20261129 run, same command)scripts/smoke.ps1, no input, copied profile and shader cache): blocks belowRegression run
Not tested
AI use
Optional temporary Discord for coordinating contributor work, testing and comparing results.
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-29T13:47:51Z.
Reviewed and tested at
f80f9f8c.Code review findings
CONFLICTINGwithmain. Commitf80f9f8cremoved the 2 GiB default (max_bytes_of(None) == None, opt-in only viaXCL_PSO_DISK_CACHE_MAX_MB), so the PR title ("keep the driver-blob disk cache under 2 GiB") no longer matches what the PR does.sweep_once(dir)is only invoked fromKeepGuard::reserve(when persisting a new slow blob). If a user setsXCL_PSO_DISK_CACHE_MAX_MBbelow an existing cache size and does a warm run where existing blobs hit without writing a new one, no sweep ever runs.driver_cache::load):load()now runsfile.metadata()on every hit, and when stale (>= 24 h),touch(p)opens the file a second time by path whilefileis still open.Tested locally
32.0.16.2140), AMD Ryzen 7 7800X3D,rustc 1.100.0.cargo test -p xcl --lib hle::d3d12x::real::driver_cache:: -- --test-threads=1: 22 passed, 0 failed.AI use
Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-29T13:59:51Z.
Ran the driver-blob disk-cap tests at
f80f9f8con an NVIDIA Blackwell desktop part.System
Results
XCL_ADAPTER=NVIDIA cargo test -p xcl --lib the_disk_cap_comes_from_the_environment -- --test-threads=1: 1 passed, 0 failed, 0 ignored.XCL_ADAPTER=NVIDIA cargo test -p xcl --lib the_least_recently_used_files_go_down_to_three_quarters_of_the_cap -- --test-threads=1: 1 passed, 0 failed, 0 ignored.XCL_ADAPTER=NVIDIA cargo test -p xcl --lib a_sweep_removes_old_blobs_and_leaves_other_files -- --test-threads=1: 1 passed, 0 failed, 0 ignored.What this adds
All three new tests pass: the disk cap comes from the environment, the least recently used blobs are removed down to three quarters of the cap, and a sweep removes old blobs while leaving other files alone. The PR is a draft; this is the first datapoint from an RTX 5070 Ti in the thread. These are CPU-side filesystem tests; the sweep line was not exercised in a title here.
Not tested
A retail title, a paired smoke run, the full workspace suite here, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - ran the commands above on this machine and wrote this report; no game data was used.
Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-29T19:36:43Z.
Re-ran the driver-blob disk-cap tests at
0387e92aafter the head moved fromf80f9f8c(a merge ofmainbc2cbb72); this is a new response in the same thread, not an edit of my earlier report: https://github.com/xcl-dev/xcl/pull/3330#issuecomment-7256959524System
Results
XCL_ADAPTER=NVIDIA cargo test -p xcl --lib the_disk_cap_comes_from_the_environment -- --test-threads=1: 1 passed, 0 failed, 0 ignored.XCL_ADAPTER=NVIDIA cargo test -p xcl --lib the_least_recently_used_files_go_down_to_three_quarters_of_the_cap -- --test-threads=1: 1 passed, 0 failed, 0 ignored.XCL_ADAPTER=NVIDIA cargo test -p xcl --lib a_sweep_removes_old_blobs_and_leaves_other_files -- --test-threads=1: 1 passed, 0 failed, 0 ignored.What this adds
All three tests still pass on the merged head: the cap comes from the environment, LRU files are removed down to three quarters of the cap, and a sweep removes old blobs while leaving other files alone. This adds the new head and driver 32.0.16.2140 as dimensions; no title run was made and the sweep line was not exercised in a title.
Not tested
A retail title, a paired smoke run, the full workspace suite here, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - ran the commands above on this machine and wrote this report; no game data was used.
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-29T22:39:33Z.
Review: COMMENTED
Static review of
f80f9f8cfor the stack in the #3041 comparison.I independently reached the same warm-cache finding as saintwolf on the measured revision. A user who sets or lowers
XCL_PSO_DISK_CACHE_MAX_MBcan remain over the limit indefinitely on cache-hit-only runs, becausesweep_onceis reached only when a new blob qualifies for saving.Review assisted by Codex (GPT-6, exact variant unavailable). No new build or GPU run for this review.
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-29T22:43:27Z.
Review: COMMENTED
Critical review of current head
0387e92a. Behavior does not match the PR title:max_bytes_of(None)returnsNone; there is no default 2 GiB cap. More materially,sweep_onceruns only when reserving a newly saved slow blob. A cache-hit-only run can stay above a newly configured cap forever. Trigger a sweep when the cache directory is first opened/read and test a warm cache already over limit. Please also avoidmetadataon every hit if the touch decision can be cached. These points are present in the existing review; they still apply to this head. No local Windows run.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:58:32Z.
Review (head
0387e92a, diff read, not a merge-check; draft, so not built or run):load(real.rs~6591) callsmetadata()on each hit and, for a file a day old or more, opens it and sets its access time, whether or notXCL_PSO_DISK_CACHE_MAX_MBis set. That's on the bind path, possibly on title threads, and isn't measured. Gating it onmax_bytes()would keep the default as it was.xcl shadersjust counted. It starts at the firstKeepTurn(~6785) and can remove.psofiles the recipe index (shaders.rs ~3959) already counts as verified, so the prep reports them prepared and the next run compiles them again.829df023, not the head; the branch has a fixup commit and a merge of main (squash and rebase). AI use should name the model.Fine: the
to_removearithmetic and its test, staging.tmp*files and receipts are left alone, the access-time touch leaves thewarm_replaystamp (length, creation, write time) unchanged, readers open withFILE_SHARE_DELETEso deleting under a reader is safe, and the listing uses find data on its own thread.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T16:13:34Z.
Test report (not a merge-check: draft)
base:
b2b1f109d2head:
0387e92a05merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2905 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: not repeated here; my review of this same head is at https://github.com/xcl-dev/xcl/pull/3330#issuecomment-7300250529, and its findings stand. This run adds what reading couldn't: whether the change merges, builds and passes the whole suite on current main.
performance: no smoke run.
assessment: merges, builds and passes the whole suite on current main (0 failed); the findings in my review stand
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
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.