Skip to content

D3D12.X: persist slow driver blobs past the RAM cache cap (#1833) - #2574

Open
razormontana wants to merge 1 commit into
xcl-dev:mainfrom
razormontana:d3d12x/persist-driver-blobs-past-ram-cap
Open

razormontana wants to merge 1 commit into
xcl-dev:mainfrom
razormontana:d3d12x/persist-driver-blobs-past-ram-cap

Conversation

@razormontana

@razormontana razormontana commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Part of #1833. A slow translated pipeline could fail to leave a driver blob for the next run when XCL's in-memory blob cache was full. Save eligible blobs to disk independently of RAM admission so later sessions can reuse them.

What is in it

Tested

  • Windows 11 Pro build 22631, Core i7-10700K, RTX 3070 8 GB (driver 617.42), Rust 1.100.0 MSVC.
  • Seven hle::d3d12x::real::driver_cache::tests passed. The new regression failed before the fix when the same key was charged twice and prevented an unrelated blob from fitting. The saturated-cache test still checks disk persistence.
  • Debug workspace build passed. On c00f3476, cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --show-output reported 1,445 passed, 0 failed and 47 ignored. The pass count includes 26 explicit GPU skip notices.
  • cargo build --offline --locked --release -p xcl succeeded.

Regression run

Both release builds ran the same retail title offline for 60 seconds on the RTX 3070. Both used the Series S profile, direct DXIL and copies of the same starting cache. This pair uses e120925, the preceding main commit. At 8b957be, smoke reached its startup deadline during #2555 shader preparation. The PR merges cleanly into 8b957be; the combined retail run remains unverified. The initial pair showed 703 frames on main and 408 on the PR. For this repeat, both started from copies of the cache left by the first main run, after builds completed.

Main

xcl-smoke v1
commit: e120925e3abc9956a8b9bae631969d32e8ccd43c
gpu: NVIDIA GeForce RTX 3070
title: 80ea98f7
seconds: 60
exit: 0x0
frames shown: 445 (PresentX 446)
presents per 2 s (last 3): 18 18 18
device removals: 0
crashes: 0
peak commit: 17596 MB

PR head

xcl-smoke v1
commit: c00f3476dff7702dc076a783206f289d1f6a720e
gpu: NVIDIA GeForce RTX 3070
title: 80ea98f7
seconds: 60
exit: 0x0
frames shown: 434 (PresentX 435)
presents per 2 s (last 3): 16 16 17
device removals: 0
crashes: 0
peak commit: 17600 MB

Not tested

Retail cache saturation, cold compile times and other GPU vendors remain unmeasured. The isolated cache tests control the size and timing inputs.

AI use

Codex GPT-6.2 wrote and reviewed the code and tests, rebased the branch, ran the checks, and updated this description.

@razormontana
razormontana marked this pull request as ready for review November 25, 2026 23:24
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 26 ignored.

Thanks!

— Devin

@xpatfussy69x

Copy link
Copy Markdown

Test run on exact head e2aae0e (e2aae0e87df1499ddc393bec6b7b3d39adb24006, on its base e1d84b7), clean tree.

Tested

  • NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.2124, 32-lane waves only), AMD Ryzen 5 7500F, Windows 11, Rust 1.100.0; debug build for the tests, release for the smoke runs
  • cargo test --workspace -- --test-threads=4: 1425 passed, 0 failed, 46 ignored
  • SKIPPED (25): 21 × no wave64; 1 × no heap windows; 3 × per-lane form refused V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32 (on main too)
  • cargo test -p xcl --lib a_slow_pipeline_is_saved: 1 passed, 0 failed
  • This PR's new tests in the workspace run:
    • a_slow_pipeline_is_saved_for_the_next_run_after_the_memory_cache_fills: ok
    • storing_a_pipeline_still_observes_the_size_and_time_thresholds: ok

Regression run (60 s, default settings, a retail title)

main:

xcl-smoke v1
commit: 08db8020d323bf478964fcc586152cce54959cfc
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1571 (PresentX 1571)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14042 MB

this PR:

xcl-smoke v1
commit: e2aae0e87df1499ddc393bec6b7b3d39adb24006
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1582 (PresentX 1582)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14012 MB

No crash or device removal; frames 101 % of main's, peak commit 100 %. The main run is on current main (08db802), newer than this PR's base.

Not tested

  • Whether the RAM cache cap was reached in this 60 s run, and the second-run startup time: a regression check only
  • The PR merged into current main (tested on its own base; it merges into 08db802 without conflicts)
  • AMD / native wave64

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and both smoke runs on the machine above and wrote this report.

@ramon-victor

Copy link
Copy Markdown
Contributor

Independent NVIDIA (wave32) full-suite + retail smoke test report on exact PR head e2aae0e87df1499ddc393bec6b7b3d39adb24006 (clean detached checkout, no local changes).

Tested

  • Hardware & toolchain: NVIDIA GeForce RTX 3070 8 GiB (wave32, driver 621.24), AMD Ryzen 7 5700X, 32 GiB RAM, Windows 11 Pro (build 26300), Rust 1.99.0 (x86_64-pc-windows-msvc), DXC/DXIL 1.8.2502.11 (Windows SDK 10.0.26100.0); debug tests, release smoke.
  • Targeted PR tests (cargo test -p xcl --lib driver_cache::tests): 6 passed, 0 failed (including the 2 new tests a_slow_pipeline_is_saved_for_the_next_run_after_the_memory_cache_fills and storing_a_pipeline_still_observes_the_size_and_time_thresholds).
  • Full workspace (.\scripts\test.ps1): 1425 passed, 0 failed, 46 ignored (25 GPU skips expected on this wave32 adapter: 21 no wave64, 1 no heap windows, 3 wave32 per-lane refused for #1426 f16/f32 semantics).
  • Release build (cargo build --release -p xcl) and 60 s retail smoke run (XCL_NETWORK=0, compared against main @ 08db802 baseline on the same machine today: 1605 frames, 15009 MB peak commit, 0 crashes, 0 device removals):

Regression run

xcl-smoke v1
commit: e2aae0e87df1499ddc393bec6b7b3d39adb24006
gpu: NVIDIA GeForce RTX 3070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1624 (PresentX 1625)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14972 MB

Not tested

  • AMD / Intel GPUs and wave64-only GPU tests (skipped on RTX 3070); XCL_SAMPLE_* tests (unset).

AI use

  • Antigravity (Gemini 4 Neon) ran the build, test suite, and smoke run and drafted this report.

@pickles976

Copy link
Copy Markdown

Wine/NVIDIA cross-check of the focused tests — all pass. Head e2aae0e87df1499ddc393bec6b7b3d39adb24006, Linux + Wine 11.0, vkd3d-proton 3.2.0 (2576c0b4adfae4a), NVIDIA 590.48.1, RTX 4060 Laptop GPU 8 GiB, --locked --target x86_64-pc-windows-msvc, one test thread, fresh Compiling xcl .../xcl-pr2574/... provenance, DXVK_CONFIG='dxgi.hideNvidiaGpu = False'.

cargo test --locked --target x86_64-pc-windows-msvc -p xcl --lib hle::d3d12x::real::driver_cache::tests:: -- --nocapture --test-threads=1 → 6/6 pass on the real adapter, including the new a_slow_pipeline_is_saved_for_the_next_run_after_the_memory_cache_fills (the log shows the late blob recovered through the disk path after the RAM map is dropped: "2 driver blobs kept on disk for the next run (this one: 250 ms…)") and the unchanged a_kept_blob_is_read_back_and_a_refused_one_is_dropped (its kept-on-disk reload and the refused-foreign-adapter branch both behave). The four pre-existing tests pass unmodified.

Scope: synthetic fixtures with a small cache and controlled timing inputs — no retail cache saturation or cold-compile timing measured here, and no title run. On this 16 GiB host the change is relevant exactly as scoped: a saturated RAM blob cache no longer silently loses slow translated pipelines between sessions.

Log: .compat-xcl/logs/verify-pr2574-wine-blob-cache.log (local). AI-assisted verification and report (OpenAI Codex).

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
…nvalidation (port upstream xcl-dev#2574 + xcl-dev#2614)

(cherry picked from commit a37262db59ac82c615618b034d149e7c54a23ff6)
bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 26, 2026
Capture and persist the exact successful uncached pipeline result whose driver build crossed the slow threshold, even when bounded RAM-cache admission fails. Same-key builders reserve capture/publication, and disk-path turns prevent distinct RAM identities from racing one pathname.

Publish disk before RAM visibility, remember cap-refused persisted keys, clear that marker on cached-blob rejection, and preserve exact-generation invalidation plus AMD default-off policy. Adapted from xcl-dev#2574 after prerequisites xcl-dev#2577 and xcl-dev#2614.

Locally cross-checked with the GNU Windows target; Windows filesystem and driver execution remain untested here.

Assisted-by: Codex (GPT-5.6-sol)
@throny

throny commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Two contributors checked independently and found that #2740 solves the same problem (for #1833) in a different way: #1607, group D127. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

@Prime1997 Prime1997 mentioned this pull request Nov 26, 2026
bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 26, 2026
Capture and persist the exact successful uncached pipeline result whose driver build crossed the slow threshold, even when bounded RAM-cache admission fails. Same-key builders reserve capture/publication, and disk-path turns prevent distinct RAM identities from racing one pathname.

Publish disk before RAM visibility, remember cap-refused persisted keys, clear that marker on cached-blob rejection, and preserve exact-generation invalidation plus AMD default-off policy. Adapted from xcl-dev#2574 after prerequisites xcl-dev#2577 and xcl-dev#2614.

Locally cross-checked with the GNU Windows target; Windows filesystem and driver execution remain untested here.

Assisted-by: Codex (GPT-5.6-sol)

@gut0to gut0to left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-assisted review (OpenAI GPT-6). I inspected the changed cache path and verified the lock sequence; I did not run tests.

Comment thread crates/xcl/src/hle/d3d12x/real.rs Outdated
let mut guard = cache.lock().unwrap();
let (map, total) = guard.get_or_insert_with(|| (HashMap::new(), 0));
if blob.len() <= limit.saturating_sub(*total) {
*total += blob.len();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this recheck map.get(&key) while holding guard before incrementing total? Two concurrent builds for the same cache key can both observe existing == None at line 4777, read their blobs, then serialize here and each add its length even though the second insert replaces the first entry. That overcounts the RAM budget and can reject unrelated blobs before the cache actually reaches its limit. I traced both lock scopes; I did not run tests. AI-assisted review (OpenAI GPT-6).

Save an eligible driver blob even when the bounded in-memory cache
cannot retain it. The RAM caps, disk identities and eligibility stay.

Recheck cache insertion under the lock so overlapping builds of a
single key retain and charge only the first blob. Regression tests
cover both a full cache and an interleaved pair of misses.

Assisted-by: Codex (GPT-6.2 Astra)
Assisted-by: Codex GPT-6.2
@razormontana
razormontana force-pushed the d3d12x/persist-driver-blobs-past-ram-cap branch from e2aae0e to c00f347 Compare November 26, 2026 17:42
@Decodere

Copy link
Copy Markdown
Contributor

Independent desktop NVIDIA verification of PR #2574 at head c00f3476dff7702dc076a783206f289d1f6a720e (1 commit; exact parent & merge-base: e120925e3abc9956a8b9bae631969d32e8ccd43c, pre-#2555 ancestor of main).

Environment

  • 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 (6C / 12T), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200 (Developer Mode off)
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC 1.9.2609.5, --release

Targeted release tests & build (c00f3476)

Command Result
cargo test --release -p xcl --lib a_slow_pipeline_is_saved_for_the_next_run_after_the_memory_cache_fills -- --nocapture 1 passed; 0 failed; 0 ignored; 1344 filtered out (0.00s)
cargo test --release -p xcl --lib overlapping_builds_charge_a_driver_blob_only_once -- --nocapture 1 passed; 0 failed; 0 ignored; 1344 filtered out (0.00s)
cargo test --release -p xcl --lib storing_a_pipeline_still_observes_the_size_and_time_thresholds -- --nocapture 1 passed; 0 failed; 0 ignored; 1344 filtered out (0.00s)
cargo test --release -p xcl --lib hle::d3d12x::real:: (3 consecutive runs) 66 passed; 0 failed; 0 ignored; 1279 filtered out × 3 (0.39s, 0.36s, 0.36s)
cargo build --release -p xcl --bin xcl Clean build (1m 12s, exit 0)

Paired quiet 60 s retail smoke (title: 29640639)

Exact parent & merge-base (e120925e3abc9956a8b9bae631969d32e8ccd43c, cached baseline on the same machine):

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

PR #2574 (c00f3476dff7702dc076a783206f289d1f6a720e):

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

Runtime log observations (xcl.log)

  • 9221 log lines, 0 [ERROR] / device-removal / panic lines.
  • Disk driver-blob reuse observed live: D3D12.X: 1 pipelines made from the driver's blob of an earlier run (kept on disk).
  • Final draw/memory telemetry in log: 19471 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample 14009 MB committed by the process; video memory 6116 MB local, 4683 MB non-local.

Limits of coverage

  • Full-RAM-cache disk persistence, overlapping-build single charging, and size/time thresholds were verified through the 3 new driver_cache::tests and 3× hle::d3d12x::real:: runs (66/0/0).
  • The 60 s retail smoke ran on the warm shader/driver cache and did not saturate the in-memory driver-blob cache cap (XCL_DRIVER_CACHE_MB), so it serves as an end-to-end non-regression check on title: 29640639 rather than a cold cache-overflow stress test.

AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).

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.

8 participants