Skip to content

D3D12.X: persist compute blobs when the RAM cache is full - #2740

Open
ZekkJJ wants to merge 1 commit into
xcl-dev:mainfrom
ZekkJJ:codex/compute-driver-cache-ram-budget
Open

ZekkJJ wants to merge 1 commit into
xcl-dev:mainfrom
ZekkJJ:codex/compute-driver-cache-ram-budget

Conversation

@ZekkJJ

@ZekkJJ ZekkJJ commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

A slow translated compute PSO can compile successfully after the 512 MiB compute blob RAM cache fills up. Preserve its driver blob for the disk cache even if it cannot be admitted to RAM. This extracts the standalone fix from the NVIDIA reference stack in #2706 and retains the original author of ee0183fd.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs gives the caller the driver blob for disk retention and independently checks the RAM budget. Regular translated compute and the two-pass compute path use the same policy.
  • A same-key insertion under the cache lock reuses the existing blob and charges its bytes once. The regression verifies bytes returned above the budget and a duplicate insertion.

Tested

  • Exact head 9ecae592ea3a1ba2b41db0167e06da435b271791 on NVIDIA GeForce RTX 4060 Laptop (616.56), Ryzen 7 8845HS, Windows 11 build 26200.9974, Rust 1.98.1 MSVC, DXC 1.8.2502.11.

  • cargo test --offline --locked -p xcl --lib compute_blob_tests -- --nocapture --test-threads=1 passed 3 with zero skips.

  • cargo test --offline --locked -p xcl --test gpu_compute_e2e -- --nocapture --test-threads=1 reported 7 passed and 1 runtime heap-window skip. The skipped case passed on this exact revision in a focused rerun with XCL_HEAP_WINDOWS=1.

  • The exact-head debug workspace build and complete RTX 4060 Laptop run reported 1436 passed, 0 failed, and 47 ignored. There were 26 runtime skip markers (21 no native wave64, 3 refused wave32 per-lane operations, 1 no heap windows, and 1 Windows Developer Mode unavailable).

  • The first 60-second smoke pair recorded 388 frames on the head against 499 on main, below the frame threshold. Both completed with zero crashes and device removals. The isolated 120-second pair below repeats the comparison.

Regression run

Clean release builds on the same RTX 4060 Laptop GPU and retail workload. XCL used a separate title state and DXIL cache for each run.

Main

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 4060 Laptop GPU
title: Retail workload A
seconds: 120
exit: 0x0
frames shown: 2406 (PresentX 2407)
presents per 2 s (last 3): 14 21 20
device removals: 0
crashes: 0
peak commit: 16637 MB

PR head

xcl-smoke v1
commit: 9ecae592ea3a1ba2b41db0167e06da435b271791
gpu: NVIDIA GeForce RTX 4060 Laptop GPU
title: Retail workload A
seconds: 120
exit: 0x0
frames shown: 1958 (PresentX 1959)
presents per 2 s (last 3): 35 36 36
device removals: 0
crashes: 0
peak commit: 16629 MB

Not tested

  • AMD and Intel hardware on this head. The retail smoke did not deliberately fill the process-wide compute blob budget. A local-store unit fixture covers that boundary.

AI use

Claude Code (Claude Fable 5.2) assisted the original commit. OpenAI Codex (gpt-6.2-sol) adapted it to current main, added the duplicate accounting check, ran validation, and prepared this submission.

…ough the memory store is full

The disk cache of compute driver blobs (xcl-dev#634) wrote a blob only when the
in-memory store had taken it first: keep_compute_blob stored it there within
COMPUTE_BLOBS_MAX (512 MB) and the caller then looked it up for the file. Once
the store was full the lookup found nothing and no later build was written.
Those are the builds that matter most: a retail title's world needs compute
pipelines of 20 to 150 s each in the NVIDIA driver, made after hundreds of
smaller ones, and it built them again in every run.

keep_compute_blob now returns the blob it fetched; it is kept in memory only
while there is room (remember_compute_blob), and goes to the disk either way.

Assisted-by: Claude Code (Claude Fable 5.2)
@Decodere

Copy link
Copy Markdown
Contributor

Independent RTX 4060 (8 GB) / Windows 11 verification of PR #2740 at 9ecae592ea3a1ba2b41db0167e06da435b271791 (exact parent origin/main b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7). Measurements and targeted test results only; not a full source review.

Setup

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6 cores / 12 threads), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200
  • Toolchain / caches: rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.9.2609.5, release builds, warm DXIL/pipeline caches, quiet machine (zero concurrent builds/tests during timed runs)
  • Workload: Retail workload title: 29640639 via scripts/smoke.ps1 -Seconds 60 (XCL_NETWORK=0 XCL_ACTIVITY=1, default flags, no input)

Targeted RTX 4060 release unit tests (9ecae592)

  • cargo test --release -p xcl --lib a_blob_over_the_memory_budget_still_reaches_its_caller -- --nocapture: 1 passed, 0 failed, 0 ignored (0.00 s, exit 0).
  • cargo test --release -p xcl --lib hle::d3d12x::real::compute_blob_tests:: -- --test-threads=4: 3 passed, 0 failed, 0 ignored (0.00 s, 0 skipped, exit 0).
  • cargo test --release -p xcl --lib hle::d3d12x::real::driver_cache:: -- --test-threads=4: 4 passed, 0 failed, 0 ignored (0.00 s, 0 skipped, exit 0).
  • cargo test --release -p xcl --lib hle::d3d12x::real:: -- --test-threads=4: 61 passed, 0 failed, 0 ignored (0.85 s, 0 skipped, exit 0).

Observations

  • Returning the newly read driver blob from keep_compute_blob even when COMPUTE_BLOBS_MAX is reached passes a_blob_over_the_memory_budget_still_reaches_its_caller, all compute_blob_tests:: and driver_cache:: cases, and the full 61-test hle::d3d12x::real:: module in --release on this RTX 4060 host with 0 skips.
  • Quiet 60 s retail smoke ran cleanly (exit: 0x0, 1519 frames shown, 60 60 60 steady-state presents per 2 s, 0 device removals, 0 crashes, 13992 MB peak commit vs parent b49be183's 14018 MB / 1518 frames).

Paired 60 s RTX 4060 smoke (b49be183 vs 9ecae592)

Parent origin/main (b49be183):

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1518 (PresentX 1518)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14018 MB

PR #2740 head (9ecae592):

xcl-smoke v1
commit: 9ecae592ea3a1ba2b41db0167e06da435b271791
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1519 (PresentX 1519)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13992 MB

Limits of coverage

  • Full workspace test suite was not re-run on 9ecae592 (only targeted compute_blob_tests::, driver_cache::, and hle::d3d12x::real:: release tests plus paired quiet 60 s smoke).
  • The warm-cache 60 s retail smoke verifies no runtime regression on the normal path; filling COMPUTE_BLOBS_MAX during live cold compute PSO compilation was not triggered in this run (that overflow-to-caller path is exercised by a_blob_over_the_memory_budget_still_reaches_its_caller).
  • Single discrete NVIDIA 8 GB GPU (RTX 4060) on native Windows 11; no AMD, Intel, or Wine/Linux run on this host.

AI use

Ran the targeted release unit tests and paired quiet 60 s smoke runs with assistance from Google Antigravity (Gemini 4 Neon); all test counts and smoke blocks were taken directly from cargo test and scripts/smoke.ps1 outputs.

@sage-sage

Copy link
Copy Markdown

Test report: passes on NVIDIA. Exact head 9ecae592 (its base is current main b49be18, so head = merged).

Tested

  • RTX 4080 SUPER (driver 621.40), Ryzen 5 7600X, Windows 11 26H2 build 26300.10075, rustc 1.100.0 MSVC, DXC 1.9.2602.17 (Windows SDK 10.0.26100), debug build
  • cargo test --workspace -- --test-threads=4: 1436 passed, 0 failed, 47 ignored; a_blob_over_the_memory_budget_still_reaches_its_caller passes
  • SKIPPED: 29 lines, the same as on main on this machine (wave64, debug layer, Developer Mode, heap windows)

Not tested

  • No game, so not a title filling the compute blob budget; AMD, Intel.

Claude Code (Claude Opus 5.5) ran the tests and wrote this report.

@thehollowedone

Copy link
Copy Markdown

Independent synthetic D3D12 cache-boundary check of PR head 9ecae592 against its parent b49be183 on Windows 11 build 26300, RTX 3080 Ti (621.35), rustc 1.99.1 MSVC, and DXC 1.8.2502.11.

I added the same uncommitted, test-only fixture to each checkout. It compiles an 86,012-byte synthetic compute DXIL program, sets the process-local compute-blob accounting to the 512 MiB limit without allocating 512 MiB, creates a real D3D12 PSO, and checks for a saved driver blob and a second PSO created from that disk blob. A 300 ms delay in the test's create callback crosses the disk-retention threshold; it is not a driver compile-time measurement.

cargo test --offline --locked -p xcl --lib full_compute_blob_budget_writes_and_reloads_driver_blob -- --nocapture --test-threads=1:

  • Parent: 0 passed, 1 failed, 0 ignored; the expected failure is driver blob written despite full RAM cache.
  • PR head: 1 passed, 0 failed, 0 ignored; 0 skips. The disk blob was saved and the second creation reported reused=true.

This exercises the real compute-PSO disk path at the simulated RAM boundary. It does not cover the two-pass path, a naturally full cache during a title run, or a change in frame rate. Synthetic shader only; no game files or diagnostics were used. AI use: Codex (GPT-6.2 Sol) wrote and ran the test fixture and drafted this report.

@emirduran707

Copy link
Copy Markdown
Contributor

Independent AMD RDNA4 (native wave64) verification of exact PR head 9ecae592ea3a1ba2b41db0167e06da435b271791 on Windows 11 Pro 26300 (AMD Radeon RX 9060 XT 16 GB, driver 32.0.31044.16, Ryzen 5 5600, Rust 1.100.0 MSVC, DXC 1.9.2602.17).

Tested

  • cargo build --workspace (debug): passed (0 errors).
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1434 passed, 2 failed, 47 ignored (8 SKIPPED: 6 per-lane DXIL forms refused by host adapter/driver, 1 heap_window_out_of_memory_falls_back_to_the_switch_form no heap windows, 1 pso_measurement_compiles_an_exact_synthetic_record Windows Developer Mode off).
    • The new test hle::d3d12x::real::compute_blob_tests::a_blob_over_the_memory_budget_still_reaches_its_caller passed.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 and fuzz_validate_and_gpu_3) are pre-existing on unmodified main on this RX 9060 XT / driver 32.0.31044.16.
  • cargo build --release -p xcl + 60 s retail-title smoke test (scripts/smoke.ps1, offline):
xcl-smoke v1
commit: 9ecae592ea3a1ba2b41db0167e06da435b271791
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1578 (PresentX 1578)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 18776 MB

(Compare against main b49be183 on this machine: 1603 frames, 18576 MB peak, 0 device removals, 0 crashes.)

Not tested

  • NVIDIA / Intel GPUs, Linux / Wine.

AI use

  • Verification run and report prepared with Antigravity (Gemini 4 Neon); all build, test, and smoke results are from live runs on this machine.

@oni-swr

oni-swr commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Independent AMD RX 7800 XT / Windows 11 test report for PR #2740 at exact head 9ecae592ea3a1ba2b41db0167e06da435b271791 (parent main b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7; the head had not moved when tested). Unit/integration tests only; no title was run.

Tested

  • AMD Radeon RX 7800 XT (driver 32.0.31035.1003), Windows 11 Pro build 10.0.26200, rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.8.2502.11 (Windows SDK 10.0.26100), debug build, separate target dir.
  • Env: XCL_ADAPTER=7800, XCL_REQUIRE_GPU=1, -j 4 on every cargo command.
  • cargo test -j 4 -p xcl --lib compute_blob_tests -- --nocapture --test-threads=1: 3 passed, 0 failed, 0 ignored, 0 SKIPPED (includes a_blob_over_the_memory_budget_still_reaches_its_caller).
  • cargo test -j 4 -p xcl --lib hle::d3d12x -- --test-threads=4: 255 passed, 0 failed, 2 ignored.
  • cargo test -j 4 -p xcl --test gpu_compute_e2e -- --test-threads=1: 7 passed, 0 failed, 0 ignored; 1 SKIPPED (heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows).
  • cargo test -j 4 -p xcl --lib -- --test-threads=4: 1309 passed, 1 failed, 27 ignored. The one failure is gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 722: res[30] = 0x1, CPU 0x7fffffff), the known AMD failure tracked in DXIL fuzz tests: fuzz_validate_and_gpu_1 fails on AMD (seed 722 and others, RDNA2-4), so the default suite is red there #2115. It is in the DXIL fuzzer, which this PR does not touch, so I did not rerun it on b49be18. Every other test passed.
  • SKIPPED lines in the lib run: 6, all "per-lane form: refused" for f16 arithmetic, f16 packed and f32 conversions (wave32 and wave64, each, citing gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426). None are in the compute-blob/driver-cache tests, and there were no no-GPU or no-wave64 skips on this adapter.

Not tested

AI use: Claude Code (Claude Sonnet 5.5) ran the tests and wrote this report, coordinated by Claude Code (Claude Opus 5.5). All counts are from the runs described.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants