D3D12.X: persist graphics PSO blobs to disk even when GRAPHICS_BLOBS is full #2910
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2910"
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:28Z.
Ensure slow graphics PSO blobs in
translated_graphics_pso_oncecontinue persisting todriver_cacheon disk even afterGRAPHICS_BLOBSreaches its 256 MiB in-memory cap, matchingfinish_two_pass's mesh pass.Fixes #2884.
What is in it
keep_graphics_blobincrates/xcl/src/hle/d3d12x/real.rsto delegate directly tokeep_graphics_blob_with, returningOption<Arc<Vec<u8>>>directly (and extracting blobs whenslow || dxil_len >= COMPUTE_BLOB_MIN_DXIL || keep_fixtures), while still enforcingGRAPHICS_BLOBS_MAXinsideremember_graphics_blob_into.translated_graphics_pso_onceto gateslowondisk.is_some() && driver_cache::worth_keeping(build.in_driver)and pass the returned blob directly todriver_cache::keepinstead of re-queryinggraphics_blob(gkey).graphics_blob_cache_tests::keep_graphics_blob_returns_blob_for_disk_even_when_ram_cache_is_fullandgraphics_blob_cache_tests::keep_graphics_blob_skips_fast_small_psoexercising the productionkeep_graphics_blob_withpath with an explicitkeep_fixturesflag.Regression run
Base (
main):PR head (
2481b11f):Tested
rustc 1.100.0, DXC 1.9.2602.17.cargo test -p xcl --lib graphics_blob_cache_tests -- --nocapture:2 passed; 0 failed; 0 ignored; 1345 filtered out..\scripts\smoke.ps1 -Game "C:\VIctory-SSD-test\game" -Seconds 60on8b957becand2481b11f(blocks above).Not tested
GRAPHICS_BLOBScap live.AI use
keep_graphics_blobdelegation and return-value fix, wrote the unit tests, ran the tests and paired smoke runs, and drafted this PR description.Imported from ivall/xcl. Originally posted by akimfomin on 2026-11-26T23:02:45Z.
The new slow-small-PSO path still extracts a driver blob when
XCL_PSO_DISK_CACHE=0. I traced the call at3d34505:graphics_pathreturnsNone, butslowstill bypasses the DXIL size floor before the disk path is checked. That adds a potentialGetCachedBlobcall and byte copy in the opt-out case. The baseline skipped extraction for that small shader.Consider
let slow = disk.is_some() && driver_cache::worth_keeping(build.in_driver);for the new exception to the size floor. One paired regression: for a slow small graphics PSO with a full RAM cache, expect a saved blob when enabled and no extra extraction when disabled. A fresh-process hit against a blank-directory control would also establish reuse. Related two-process control in Continued. PortBridge · AI-assisted source comparison, no latency measurement.Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-11-26T23:15:43Z.
Rerun on the new head
2481b11: passes on NVIDIA, and the new test now covers the shipped path:keep_graphics_blobcallskeep_graphics_blob_with, and withmain's behaviour put back there the test fails.cargo test --workspace --no-fail-fast -- --test-threads=4,2481b11(base =main8b957be, so head = merged)SKIPPEDlineskeep_graphics_blob_withreturnsNonewhenremember_graphics_blob_intodid not keep the blob (as onmain)keep_graphics_blob_returns_blob_for_disk_even_when_ram_cache_is_fullfails 3 of 3 (left: None);keep_graphics_blob_skips_fast_small_psopasses (it guards the other branch)hle::d3d12x::real::(65 tests),--test-threads=8, 30 runse2etest_title_draws_with_a_root_signature_under_the_debug_layermain8b957be: 3× error id 93, 1× error id 1046, 1× warning id 820, 8× id 0 at exitFrom reading:
keep_graphics_blobnow holds theGRAPHICS_BLOBSlock whileread_pso_cached_blobcalls the driver'sGetCachedBlob, whichmaindid outside it. So other threads looking up a graphics blob wait for that copy. I did not measure whether this matters.First run, on
3d34505: Full suite on NVIDIA (listed under Not tested): passes. But the new tests exercisekeep_graphics_blob_with, a#[cfg(test)]copy of the logic, not the shippedkeep_graphics_blob: with the old behaviour put back in the real function, both tests still pass.Tested:
3d34505(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=4(all test binaries, which the PR lists under Not tested)SKIPPEDlines (no wave64, refused per-lane forms)keep_graphics_blobends withgraphics_blob(key)instead ofSome(blob)(a blob is returned only if the RAM cache kept it, as onmain)graphics_blob_cache_testsstill pass, 3 of 3keep_graphics_blob_withkeep_graphics_blob_returns_blob_for_disk_even_when_ram_cache_is_fullfails 3 of 3e2etest_title_draws_with_a_root_signature_under_the_debug_layermain8b957be: 3× error id 93, 1× error id 1046, 1× warning id 820, 8× id 0 at exitSo the disk-persistence fix has no test of its own. If
keep_graphics_blobcalled one shared helper (for example the currentkeep_graphics_blob_withwithout#[cfg(test)], takingread_pso_cached_blobas the closure, withgraphics_blob/remember_graphics_blobaround it), the test would cover the shipped path.Not tested: a title run that fills the 256 MiB
GRAPHICS_BLOBScap, AMD / Intel on this run.AI use: Claude Code (Claude Opus 5.5) ran the tests and the scratch checks and wrote this report.
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-27T00:28:22Z.
Code review location:
crates/xcl/src/hle/d3d12x/real.rs; line 4874The new tests call
keep_graphics_blob_with, a#[cfg(test)]copy of the logic, while production runs the separateunsafe fn keep_graphics_blob. The two have already drifted (this one has thebytes.is_empty()check, production has thepso.is_null()check), and the tests would pass onmaintoo, so they don't guard the fix (AGENTS.md: a bug fix comes with a test that fails without the fix).Please have
keep_graphics_blobdelegate to this function: take theGRAPHICS_BLOBSlock, pass its map, total andGRAPHICS_BLOBS_MAX, and use|| read_pso_cached_blob(pso)asread_blob, keeping the null check in the wrapper. Then drop the#[cfg(test)]gate so the tests cover the code that runs.Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-27T00:28:22Z.
Review: CHANGES_REQUESTED
The fix in
translated_graphics_pso_oncelooks right to me: it uses the same blob-keeping rule as the mesh path infinish_two_pass, and the RAM cap is still enforced. One change is needed before merge: the tests don't exercise the function this PR fixes (inline comment).Review written with Claude Code (Claude Opus 5.5); I checked each point against the diff.
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-27T00:28:25Z.
Two more points, neither blocking on its own:
keep_graphics_blob_skips_fast_small_psorelies on the process-wideKEEP_FIXTURESflag being off. Today onlytests/gpu_two_pass_cache_e2e.rssets it, in a separate binary, so the test passes. But if a lib test ever callsforce_driver_cache_fixture_retention(), this test panics inread_blob, depending on test order. Passing the fixture flag into the helper as a parameter (or asserting!driver_cache::keep_fixtures()up front) would make it deterministic.xcllib suite; the integration test binaries were not run. CONTRIBUTING.md asks for the wholecargo test --workspace -- --test-threads=4on a GPU, and CI has no GPU, so it doesn't cover this. The pre-existing #1905 failure stops the lib binary first;cargo test --workspace --no-fail-fast -- --test-threads=4runs the rest. Please add those counts. The driver-cache integration tests (gpu_two_pass_cache_e2e) are the ones closest to this change.Written with Claude Code (Claude Opus 5.5); checked against the PR head
3d345054.Imported from ivall/xcl. Originally posted by real-alponzo on 2026-11-27T03:30:46Z.
Thanks @KOLESNiii and @fromthemoonx! Addressed in
2481b11f: \keep_graphics_blob\ now delegates directly to \keep_graphics_blob_with\ (dropping #[cfg(test)]), \keep_fixtures\ is passed explicitly to keep tests order-independent, and \slow\ is gated on \disk.is_some(). Re-ran unit tests and 60 s smoke.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-27T06:19:52Z.
NVIDIA and AMD full-suite run, to go with the reports above by fromthemoonx, since none of them covers AMD. Tested exact head
2481b11f(on its base8b957be).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace --no-fail-fast -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1436 passed, 0 failed, 45 ignored. SKIPPED (no wave64):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,dispatch_chain_native_wave64_builds_whole,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.keep_graphics_blob_returns_blob_for_disk_even_when_ram_cache_is_full,keep_graphics_blob_skips_fast_small_pso.XCL_ADAPTER=radeon),cargo test --workspace --no-fail-fast -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1447 passed, 0 failed, 47 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on mainc2ee10e4too, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests,const_and_null_mask_operands_agree_with_hlsl_on_the_gpuandmask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-27T06:20:52Z.
Independent Windows/NVIDIA test of PR head
2481b11fon an RTX 3080 Ti (driver 621.35), Windows 11 build 26300, Rust 1.99.1 MSVC.cargo test --offline --locked -p xcl --lib graphics_blob_cache_tests -- --test-threads=4: 2 passed, 0 failed, 0 ignored.cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4: 1,448 passed, 0 failed, 47 ignored across 38 test binaries. The run printed 25SKIPPEDGPU notices (mostly unavailable wave64 paths, plus unsupported per-lane forms and one heap-window case); these are not GPU coverage. The driver-cache integration tests ran, andconsole_mesh_caches_hlsl_compute_pass_in_memory_and_on_diskpassed in this run.This verifies the synthetic suite on this adapter. I did not run a retail title or fill the 256 MiB graphics-blob cap in a live workload, and I did not measure the
GetCachedBloblock contention already noted in this PR.AI use: Codex (GPT-6.2 Sol) reviewed the changed path, ran the tests, and drafted this report.
Imported from ivall/xcl. Originally posted by LocranKing on 2026-11-27T10:00:34Z.
Tested PR #2910 (
2481b11f) 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)keep_graphics_blob:2 passed, 0 failed(keep_graphics_blob_returns_blob_for_disk_even_when_ram_cache_is_fullandkeep_graphics_blob_skips_fast_small_pso).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):xcl.log)main(8b957bec)67.2 s/188.4 s124014(28windows)29,411 MB14,281 / 2,241 MB16blobs logged (last: 253 ms, 41 KB)0 / 0(exit: 0x0)2481b11f)66.0 s/185.9 s122519(29windows)29,719 MB14,379 / 2,227 MB8blobs logged (last: 5279 ms, 385 KB)0 / 0(exit: 0x0)Both runs exited cleanly (
0x0,0crashes,0device removals). Note regarding #2884: during this short180 s(~60 sworld) window on Series S (XCL_DIRECT_DXIL=all), only8–16slow driver blobs (~385–718 KBmax logged) were saved on disk, so the 256 MiBGRAPHICS_BLOBSRAM cap was not reached within this run duration.Not tested: Multi-hour / heavy graphics PSO runs reaching 256 MiB in
GRAPHICS_BLOBS, or a second warm pass reusing the newly persisted blobs.Imported from ivall/xcl. Originally posted by throny on 2026-11-27T22:28:46Z.
merge-check claim
head:
2481b11fcaImported from ivall/xcl. Originally posted by throny on 2026-11-27T23:13:03Z.
merge-check
base:
2c717a04head:
2481b11fcamerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1468 passed, 0 failed, 47 ignored (26 SKIPPED lines); base alone: 1466 passed, 0 failed, 47 ignored
review: none blocking. keep_graphics_blob has one caller and it is updated. Open from the thread and not measured: GRAPHICS_BLOBS stays locked during GetCachedBlob and the copy, so other pipeline builds wait on it meanwhile (no draw path waits on it, no lock-order problem found). The new test fails on main's behaviour by reading the code.
performance: default path (the disk cache is on by default). Builds of 250 ms or more now get their blob extracted also under 16 KB of DXIL, and are written to disk once the 256 MiB RAM cap is full, so the files written in one run no longer have an upper bound (before, about 256 MiB). Writes stay on the thread that creates the pipeline and stay atomic. No per-frame cost; disk growth over a long session was not measured here.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:09:42Z.
Triage (#1607) – head
2481b11Main already does this:
665f72fc("D3D12.X: persist slow driver blobs past the RAM cap", on main since the #2959 merge). Intranslated_graphics_pso_onceand the other graphics paths,keep_driver_blobreads the blob and stores it on disk when the build was slow, even whenGRAPHICS_BLOBSrefuses it for RAM. That is what this PR adds. The PR's code no longer applies either:GRAPHICS_BLOBSis now aDriverBlobswith a 3-part key.In the diff:
keep_graphics_blobcallsread_pso_cached_blob(the driver'sGetCachedBlob) while it holds theGRAPHICS_BLOBSlock. It also lets slow pipelines underCOMPUTE_BLOB_MIN_DXILinto the RAM cache, not only onto disk.Recommendation: close (superseded by main commit
665f72fc).AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T13:00:51Z.
Closing as superseded: this change is already on
main(665f72fc). main keep_driver_blob_at writes the slow graphics blob to disk (to_disk) even when GRAPHICS_BLOBS admission refuses it (665f72fc, adapted from #2574)Two independent checks found this: Foniass's close list on #1607 and ours against current
main. If something here is still missing onmain, say so and reopen it, or ask and I will.AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.
Pull request closed