Skip to content

D3D12.X: a background driver compile stays within a share of the RAM - #1924

Open
Rednaxeh wants to merge 1 commit into
xcl-dev:mainfrom
Rednaxeh:huge-compile-commit-by-size
Open

Rednaxeh wants to merge 1 commit into
xcl-dev:mainfrom
Rednaxeh:huge-compile-commit-by-size

Conversation

@Rednaxeh

@Rednaxeh Rednaxeh commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Rebased on main with #1774 in: the size-scaled headroom is #1774's, this PR keeps what that gate still lacks. Part of #232 / #505.

The headroom a background compile waits for is read when the compile starts, and says nothing about what the title takes next. On 32 GB of RAM a retail title's 13.8 MB compute program (#1332 in the form of #1321) starts at 4 s in the background with 36 GB of commit free – its #1774 headroom is 7 GB – and the AMD driver's ~15 GB for it, with the title's own 25 GB of world loading after it, ran the process into the machine's commit limit at 28–34 s in three runs (XCL_HUGE_PSO_CONCURRENCY=4 twice, defaults once: 0xc0000005 in the title's own memcpy, a page that could not be committed).

A background compile now also needs what it takes (the headroom, or 1 GB per MB of DXIL when that is more) to be within a share of the machine's RAM (a quarter; XCL_HUGE_PSO_RAM_SHARE sets the n of 1/n, 0 leaves the commit free alone to decide, as before) and within the RAM available now (under Wine ullAvailPageFile is the memory available plus the free swap and never falls, as @Royalflamejlh measured below). Such a program waits for a bind that wants it (the gate's existing way out) and is built then, on that thread, as before #1524; xcl.log says so once per program and worker. Compiles the title waits for, and small ones, are unchanged. On NVIDIA with 16 GB or more nothing changes for 1–2 MB programs.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: big_compile_takes(dxil_len), huge_pso_ram_share() (XCL_HUGE_PSO_RAM_SHARE), big_compile_may_start(headroom, takes, free, available, physical, ram_share), used by big_compile_commit_free(dxil_len) in both gate call sites, which logs a program it holds back; tests a_background_compile_starts_within_the_commit_the_ram_share_and_the_ram_available and a_graphics_bind_releases_the_background_ram_share_gate.
  • crates/xcl/src/hle/d3d12x/pso_async.rs: resolve marks a graphics pipeline wanted at its first bind, so a held graphics program gets built then (found in review by @WebIdentity1, with the test above; both taken as they are, co-author of the commit).
  • README.md: the huge-pipeline paragraph says so, with the switch.

Tested

  • AMD Radeon RX 7800 XT 16 GB (driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 Pro 26300, Rust 1.100.0 stable-x86_64-pc-windows-msvc, DXC 1.9.2602.17 (Windows SDK 10.0.26100), debug for the tests, release for the title
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4 on 2bb8e1c (20 test binaries): 1155 passed, 1 failed, 46 ignored. The failure, gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 722: res[30] = 0x1, CPU 0x7fffffff), fails identically on main on this card (direct DXIL backend, not this PR).
  • SKIPPED: gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu and f32_programs_on_the_gpu (the per-lane form refuses V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32), heap_window_out_of_memory_falls_back_to_the_switch_form.
  • The graphics-bind test fails on the tree without the want() line ("graphics bind left its compile held by the RAM-share gate") and passes with it.
  • Retail title, 600 s runs with XCL_PSO_TRACE=1 (on 689f2db-based trees, before the rebase): without the share, XCL_HUGE_PSO_CONCURRENCY=4 ended the process at 34 s twice (commit 41–43 GB, the 13.8 MB compile in flight since 4 s); with it, the same run ends at 600 s and that program is built at 97 s, when the title binds it. With the defaults, one run of main 689f2db died the same way at 29.8 s and one survived with 1 GB of commit to spare.

Regression run
A at ~13 s in both runs.

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: AMD  Radeon RX 7800 XT
title: 0da1204f
seconds: 60
exit: 0x0
frames shown: 1220 (PresentX 1220)
presents per 2 s (last 3): 0 2 1
device removals: 0
crashes: 0
peak commit: 26716 MB
xcl-smoke v1
commit: 2bb8e1cfbf5df104b66bf4fe3d234e164ac0a735
gpu: AMD  Radeon RX 7800 XT
title: 0da1204f
seconds: 60
exit: 0x0
frames shown: 1261 (PresentX 1261)
presents per 2 s (last 3): 0 12 19
device removals: 0
crashes: 0
peak commit: 24556 MB

Not tested

  • NVIDIA / Intel; machines with less than 16 GB, where programs of 4 MB and more are no longer built ahead in the background (they are built at their first bind, as before Shaders: speed up translated pipeline compiles and add PSO measurements #1524).
  • Whether "1 GB per MB of DXIL" fits other drivers: it is a floor taken from the AMD measurement, not a model of the compilers.
  • Wine: the ullAvailPhys condition follows @Royalflamejlh's reading; not run there.

AI use

  • Claude Code (Claude Fable 5.1) wrote the change, the tests (one with @WebIdentity1's), the commit message and this description from the runs' logs; the runs and the tests were mine.

🤖 Generated with Claude Code

@Rednaxeh
Rednaxeh marked this pull request as ready for review November 24, 2026 23:35
@WebIdentity1

Copy link
Copy Markdown

The new permanent RAM-share cap exposes a graphics first-use gap on 6d7290d: driver_compile("graphics", ..., true, ...) enters this gate, but pso_async::resolve_for_bind uses nonblocking resolve for graphics, and resolve never calls Pending::want(). A graphics program above the fixed RAM-share limit therefore stays held even when bound. Its stand-in can remain indefinitely, also retaining its gate slot. The wait-based compute escape path does not help it.

I reproduced the scheduling failure on native Windows with the actual big_compile_turn, a graphics Pending, and your policy evaluated at 13,823,000 bytes DXIL / 36 GiB free commit / 32 GiB RAM / share 4. The fixture simulates the budget and compiler closure; it allocates no huge shader and performs no GPU draw.

A small candidate fix calls p.want() from resolve, keeping the graphics bind nonblocking. It promotes actual first use to demand, including raising a preload worker's priority through the existing mechanism.

Tested — Windows 10 19045, Ryzen 7 7800X3D, Rust 1.98.1 MSVC, debug:

  • Head + test only: cargo test --locked -p xcl --lib a_graphics_bind_releases_the_background_ram_share_gate -- --test-threads=1 --show-output: 0 passed / 1 failed / 0 ignored, at graphics bind left its compile held by the RAM-share gate.
  • Head + candidate and same test: 1 passed / 0 failed / 0 ignored. It checks deferral before use, immediate stand-in return, and gate release after bind. The worker is released before assertions on both paths.
  • Candidate: cargo test --locked -p xcl --lib -- pso_async:: big_compile_tests:: --test-threads=4 --show-output: 17 passed / 0 failed / 0 ignored. No skips in these runs. Both initial builds recompiled; 310-file source manifests matched before/after each run.

Not tested: full workspace suite, retail smoke, actual driver memory use, or visual output. This is a candidate for your PR, not a merge-readiness claim. Our #572 DXC worker-count change is a different layer and does not solve this demand-propagation gap.

Candidate fix and deterministic regression (39 added lines)
diff --git a/crates/xcl/src/hle/d3d12x/pso_async.rs b/crates/xcl/src/hle/d3d12x/pso_async.rs
index 3bc4ad2..4667622 100644
--- a/crates/xcl/src/hle/d3d12x/pso_async.rs
+++ b/crates/xcl/src/hle/d3d12x/pso_async.rs
@@ -517,6 +517,9 @@ fn entry(pso: usize) -> Option<Arc<Pending>> {
 pub fn resolve(pso: usize) -> usize {
     let Some(p) = entry(pso) else { return pso };
     p.note_use();
+    // Used graphics pipelines must escape background-only admission limits too,
+    // while the bind still returns immediately with the stand-in.
+    p.want();
     match p.real.load(Ordering::Acquire) {
         0 => {
             // a lazy one is wanted now: to the workers
diff --git a/crates/xcl/src/hle/d3d12x/real.rs b/crates/xcl/src/hle/d3d12x/real.rs
index 43f40be..ba1d815 100644
--- a/crates/xcl/src/hle/d3d12x/real.rs
+++ b/crates/xcl/src/hle/d3d12x/real.rs
@@ -3725,6 +3725,42 @@ mod big_compile_tests {
     use std::sync::atomic::AtomicBool;
     use std::time::{Duration, Instant};
 
+    /// A pipeline over the RAM share is held indefinitely until first use. Graphics
+    /// binds must release that gate while still returning the stand-in immediately.
+    #[test]
+    fn a_graphics_bind_releases_the_background_ram_share_gate() {
+        use super::super::pso_async;
+        use std::sync::{Arc, mpsc};
+        static S: Slots = Slots { n: Mutex::new(0), cv: std::sync::Condvar::new(), most: 1 };
+        let cleanup = Arc::new(AtomicBool::new(false));
+        let release = cleanup.clone();
+        let (started_tx, started) = mpsc::channel();
+        let (finished_tx, finished) = mpsc::channel();
+        let standin = 0x7E57_B024usize;
+        pso_async::submit(standin, false, Box::new(move || {
+            started_tx.send(()).unwrap();
+            let _slot = big_compile_turn(&S, || {
+                release.load(Ordering::Acquire)
+                    || big_compile_may_start(big_compile_commit_needed(13_823_000), 36 << 30, 32 << 30, 4)
+            }, pso_async::build_is_wanted);
+            finished_tx.send(()).unwrap();
+            0x5424
+        }));
+        started.recv_timeout(Duration::from_secs(10)).unwrap();
+        let held_before_bind = finished.recv_timeout(Duration::from_millis(100)).is_err();
+        let bound = pso_async::resolve_for_bind(standin);
+        let released_by_bind = finished.recv_timeout(Duration::from_secs(1)).is_ok();
+        // Always release the worker before assertions, including on the unfixed tree.
+        cleanup.store(true, Ordering::Release);
+        if !released_by_bind { finished.recv_timeout(Duration::from_secs(10)).unwrap(); }
+        let real = pso_async::resolve_wait(standin);
+        let _ = pso_async::released(standin);
+        assert!(held_before_bind, "oversize background compile escaped before first use");
+        assert_eq!(bound, standin, "graphics bind must return the stand-in without waiting");
+        assert_eq!(real, 0x5424);
+        assert!(released_by_bind, "graphics bind left its compile held by the RAM-share gate");
+    }
+
     #[test]
     fn the_commit_a_background_compile_needs_grows_with_its_dxil() {
         const GB: u64 = 1 << 30;

AI use: Codex with GPT-6 Astra inspected the path, wrote the candidate and test, ran the Windows comparison, and drafted this report.

@Rednaxeh

Copy link
Copy Markdown
Contributor Author

Thanks, that is a real gap: with the fixed 3 GB rule a held graphics program got its turn once the commit was there, with the share it never did. I took your one-line fix and the test as they are, in 224888a (you are a co-author of the commit); the test fails on the tree without the line ("graphics bind left its compile held by the RAM-share gate") and passes with it, as you reported. Suite and smoke are rerun on the new head in the description.

@Royalflamejlh

Copy link
Copy Markdown
Contributor

A note from Linux on 224888a, not a title test: under Wine the ullAvailPageFile this gate reads was the memory available plus the free swap, 46.3 GB with 15.1 GB of memory available. #1660 describes the same reading for wait_for_memory.

Setup: Fedora 44 (kernel 7.2.9), Wine 11.21 Staging, Ryzen 9 9950X3D, 62.5 GB RAM, 56.0 GB of swap. A ten-line program that prints GlobalMemoryStatusEx, the call big_compile_commit_free makes, run under Wine with /proc/meminfo read right after it, 3 times.

Tested

under Wine Linux right after
ullTotalPhys 62.5 GB MemTotal 62.5 GB
ullTotalPageFile 118.5 GB MemTotal + SwapTotal (56.0 GB) = 118.5 GB
ullAvailPhys 15.1, 15.1, 36.3 GB MemAvailable 15.1, 15.1, 36.3 GB
ullAvailPageFile 46.3, 46.3, 69.7 GB MemAvailable + SwapFree (31.2, 31.2, 33.5 GB) = 46.3, 46.3, 69.8 GB

On Windows that field is the commit left, page file included, so the pull request reads the right number there. Under Wine it follows memory in use, and Linux does not refuse a commit at that number, so it never falls below the free swap, however little memory is left. At 12:52 today free -g on this machine showed 0 GB of memory available with 18 GB of the 56 GB of swap in use (another job beside a title run). By the table that reads as about 38 GB of commit free, so the gate would have let a background compile start; that is arithmetic, not a run.

Read

  • real.rs:3687 (big_compile_may_start): free >= needed takes ullAvailPageFile and needed <= physical / ram_share takes ullTotalPhys (both passed at :3708). The second is a true number under Wine. On this machine it does not hold the description's 13.8 MB program back either: that needs 9.6 GB and a quarter of 62.5 GB is 15.6 GB; the share would stop it on less than 39 GB of RAM.
  • Would it be worth also asking for needed <= ullAvailPhys before a background compile starts, for systems where the commit reading does not fall? I have not tried it. Shaders: size-based admission for big compute driver compiles #1774 changes the same function.

Not tested: a title run with or without the change; a Linux machine with less than 39 GB of RAM; what running out of memory looks like under Wine with this gate; the giant lane with the preload of #690 on; Windows.

AI use: Claude Code (Claude Fable 5.2) read the diff, wrote and ran the small program and wrote this note.

Posted without review by a person: the account owner was away and reads replies later.

@Rednaxeh

Copy link
Copy Markdown
Contributor Author

Two things, one of them on me.

#1774 came first. @brandostrong's "size-based admission" (opened 20:34 UTC yesterday, part of #1269's A19) scales the same gate's headroom with the DXIL size – max(3 GB, 512× DXIL) – which is the core of this PR too; my search did not find it. So the size rule belongs to #1774. What this PR has that #1774 does not, from the runs in the description:

  1. The RAM share. On a 32 GB machine the 13.8 MB program's background compile starts at 4 s with 36 GB of commit free – Shaders: size-based admission for big compute driver compiles #1774's 7 GB headroom lets it start as well – and the title's own 25 GB of world loading arrive while the driver holds its ~15 GB: the process died at 28–34 s in three runs. The share (needed ≤ RAM / 4, XCL_HUGE_PSO_RAM_SHARE) is what kept the later runs alive; the commit reading at the start of a compile cannot see what the title takes next.
  2. A graphics bind marks its pipeline wanted (pso_async::resolve, found by @WebIdentity1 with its test): without it a graphics program the gate holds stays a stand-in for good. That applies to Shaders: size-based admission for big compute driver compiles #1774's gate as it is.
  3. The log line when a program is held back.

@Royalflamejlh's Wine reading (ullAvailPageFile = available + free swap there, so it never falls): asking for needed ≤ ullAvailPhys as well is cheap and I would add it.

Proposal, unless the maintainer or @brandostrong prefers otherwise: I rebase this PR on #1774 as a stacked follow-up with only points 1–3 and the ullAvailPhys condition, and #1774 keeps the size rule. If #1774 would rather take 1–3 itself, I close this one and test there.

@Parakeet-Wheat

Copy link
Copy Markdown

NVIDIA data point, since the description lists it as not tested: this PR merged onto main 6567c5f (clean), against main itself, on 32 GB of RAM.

  • Setup: NVIDIA GeForce RTX 3070 8 GB (driver 610.88, 32-lane waves), Ryzen 5 5600X, 32 GB RAM, Windows 11 26300, Rust 1.95.0, DXC 1.8.2502, retail 1.0.2.1, release. XCL_NETWORK=0, XCL_RUN_SECONDS=420, defaults otherwise. A pressed a few times at the start screen, no other input. Warm caches: a main run first to absorb the recompiles, then this PR, then main again.
  • The gate fires as described: at 8.3 s, "a background compile of 13823000 B DXIL is held back: it would take 9 GB of commit, more than a 1/4 of the 31 GB of RAM". That program (record 95cc13288a27a96e) is not built in this run. On main its background build starts at 8.8 s and is still in the driver at 420 s (also in the first main run, which never left the menus), with no crash.
  • Same outcome either way: the world load starts and the title stops presenting at ~120 s in both runs (14,074 draws with this PR, 14,308 on main). What it waits for in both is 56c0cd3b82a00c6e (29,215,776 B). It is bound at ~99 s, so it is built on the title's thread despite the gate, as intended, and does not finish within 420 s.
  • Memory: peak private bytes of the process (5 s samples) 35.8 GB with this PR, 38.3 GB on main. At 122 s it was 30.3 vs 31.4 GB.
  • Both runs: exit 0x0, 0 crashes, 0 device removals, 0 ERROR lines.

One run each. Not tested: the test suite, the smoke pair, this PR with #1316. AI-assisted (Claude Code, Claude Opus 5.5); run on my machine.

@JJAutoCompare

Copy link
Copy Markdown

PR #1924 — D3D12.X background driver compile headroom

  • PR head: 224888a (live refs/pull/1924/head, clean detached checkout).
  • Main: aaa0936 (fetched origin/main).
  • git merge-tree --write-tree origin/main HEAD exited 1 with a content conflict in crates/xcl/src/hle/d3d12x/real.rs. The merge check left the checkout clean.

What is in it

  • Background driver PSO admission scales the required free commit with the DXIL byte count and applies a configurable physical RAM share. A graphics bind marks the build wanted while returning its stand-in.

Tested

  • STOR-WINLAB. Intel Arc A770 16 GiB, driver 32.0.101.9175, wave sizes 8–32, DoublePrecisionFloatShaderOps=0. AMD Ryzen 7 3800X. Windows 11 Enterprise Evaluation build 26200.9974. DXC/DXIL 1.9.2609.5.
  • rustc 1.100.0 (0ef1bc386 2026-11-09). Debug profiles, with debug info and incremental compilation disabled.
  • cargo build --workspace and cargo test --workspace --no-run both exited 0 outside the GPU lock.
  • cargo test -p xcl --lib big_compile_tests -- --show-output outside the GPU lock. 11 passed, 0 failed, 0 ignored, 943 filtered out.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output in one pass under the shared Arc lock via L:/XclTooling/Invoke-ArcTest.ps1. Cargo exit 101. Across 20 test targets, libtest reported 953 passed, 25 failed, 45 ignored, 0 measured, and 0 filtered out.
  • Library target: 24 failures. Twenty reported CreateComputePipelineState error 0x80070057. Four were assertions for fused FMA overflow, implicit-LOD sampling, the v_add_f16 high half, and wave64 pixel reductions.
  • End-to-end target: test_title_runs_and_game_folder_is_untouched failed the dynamic depth bias check. RSSetDepthBiasX(-1000.5) produced a blue top-right pixel where the test expected green.
  • Full output is in pr1924-suite.log in the same directory.
  • Explicit SKIPPED lines: 25. Libtest can include these early returns in its passed total. They do not count as coverage.
SKIPPED gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 arithmetic, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::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))
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 compares, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::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))
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer arithmetic, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 rounding, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer carries, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 transcendentals, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 three-source, wave64: no wave64
SKIPPED gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64
SKIPPED gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64
SKIPPED shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D)
SKIPPED placed_title_textures_share_vram_and_preserve_pixels: tiled tier < 2
SKIPPED test_title_draws_with_a_root_signature_under_the_debug_layer: no d3d12SDKLayers.dll
SKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows
SKIPPED uploads_start_from_each_subresources_state: no D3D12 debug layer (The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D))

Not tested

  • Retail-title smoke runs on main and the PR head, and real driver compile commit pressure during retail world loading.
  • A baseline suite on main. This run does not establish whether the failures reproduce on main.
  • The merged tree, AMD and NVIDIA GPUs, and GPU cases listed as skipped above.

AI use

  • T3 Code / Codex (gpt-6.2-sol) ran the build and tests and drafted this report. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified the counts against pr1924-suite.log and published this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

The huge-pipeline gate (xcl-dev#1524, headroom by size since xcl-dev#1774) lets a compile on an
xcl-pso worker start when its commit headroom is free. That reading at the start
of a compile says nothing about what the title takes next: a retail title's
13.8 MB compute program (xcl-dev#1332 in the form of xcl-dev#1321) started at 4 s in the
background with 36 GB of commit free - its headroom is 7 GB - and, with the
title's own 25 GB of world loading after it, the AMD driver's ~15 GB for that
compile ran the process into the machine's commit limit at 28 - 34 s on 32 GB of
RAM, three times (twice with XCL_HUGE_PSO_CONCURRENCY=4, once with the defaults:
a title thread's page could not be committed).

A background compile now also needs what it takes (the headroom, or 1 GB per MB
of DXIL when that is more) to be within a share of the machine's RAM (a quarter;
XCL_HUGE_PSO_RAM_SHARE sets the n of 1/n, 0 leaves the commit free alone to
decide, as before) and within the RAM available now (under Wine the commit
reading is the memory available plus the free swap and never falls, as
Royalflamejlh measured in review). Such a program waits for a bind that wants
it (the gate's existing way out) and is built then, as a title thread would,
and the log says so once per program and worker. Compiles the title waits for,
and small ones, are unchanged.

A graphics bind resolves without waiting and did not mark its pipeline wanted,
so a graphics program the share holds back would have stayed a stand-in with
its worker in the gate: `resolve` now calls `want()` too (found, with the test
a_graphics_bind_releases_the_background_ram_share_gate, by WebIdentity1 in
review).

Measured on an RX 7800 XT, 32 GB: with the share the same runs end at 600 s, the
13.8 MB program built at 97 s when the title bound it, and a 60 s smoke's peak
commit goes from 84 GB (main) to 27 GB.

Co-Authored-By: WebIdentity1 <WebIdentity1@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Rednaxeh
Rednaxeh force-pushed the huge-compile-commit-by-size branch from 224888a to 2bb8e1c Compare November 25, 2026 07:27
@Rednaxeh Rednaxeh changed the title D3D12.X: a background driver compile needs the commit its size takes D3D12.X: a background driver compile stays within a share of the RAM Nov 25, 2026
@Rednaxeh

Copy link
Copy Markdown
Contributor Author

Rebased on main with #1774 in, as proposed: the size-scaled headroom is #1774's now, and this PR keeps only what that gate still lacked – what a compile takes (its headroom, or 1 GB per MB of DXIL) within a share of the RAM and within the RAM available (@Royalflamejlh's Wine reading, thank you), the graphics bind marking its pipeline wanted (@WebIdentity1's fix and test, co-author of the commit), and the log line. Head 2bb8e1c; suite, SKIPPED list and a fresh smoke pair against main 568e7db are in the description. The conflict is gone.

@S1m0ne1997

Copy link
Copy Markdown

@Rednaxeh a gap next to what this PR closes, found in a title run with several huge compiles at once: the commit a background compile waits for is checked when it starts, but nothing counts the compiles already running. Compiles that start together all see the same free commit and all go.

Run: RTX 4090 24 GB (driver 621.40), Ryzen 9 9950X3D, 47 GB RAM, 52.4 GB commit limit, Windows 11 26300, release. Tree: #2057 at 4df1e6e (merged with main 568e7db, so #1774's size-scaled headroom is in, this PR is not), retail title of #505, XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_UMA_SHADOW=1 XCL_COHERENT_HEAPS=sparse:16 XCL_LOOK_SKIP=1 XCL_PSO_TRACE=1, and XCL_HUGE_PSO_CONCURRENCY=8. Second run after one with the default, so the DXIL cache was warm and XCL's driver blobs partly (438 compiles got a blob, 1 160 did not, by 230 s).

  • From ~15 s, background compiles of 0.76–1.06 MB of DXIL start four at a time, each gated (waited 0 ms), 11.0–17.9 s each in the driver.
  • Process commit, sampled every 10 s: 32.8 GB → 40.5 → 42.4 GB. System free commit: 3.8 GB → 1.8 → 0.9 GB.
  • Background compiles kept starting with waited 0 ms in that window, although the free commit was below the 3 GB floor of each of them. I read that as several compiles passing the check at the same moment and then each growing by a few GB in the driver. I don't have a sample of free commit at the exact instant each compile started, so that last step is my reading of the log, not a measurement.
  • No crash and no device removal: the world load started at 88.6 s, the background compiles ended and commit held at 42.4 GB with ~1 GB free.

With the default (XCL_HUGE_PSO_CONCURRENCY unset) the same machine never got close: one huge compile at a time, but background ones waited up to 62 s for the slot (40 of them, 858 s of waiting in total over 700 s).

What would close it, if you want it here: a compile counts what the ones already running take. For example, a total of the big_compile_takes of the compiles in flight, added when a compile passes the gate and taken off when it ends, and the gate passes only when free − in flight ≥ takes (the same for the RAM share and RAM available checks of this PR). Then several at once is safe on a big machine, and a small one stays at one, without a fixed count. I haven't written or run it; I'm glad to test it here on your head with the same setup, or to send it as a commit on this PR if you prefer.

Not tested: this PR's head itself (the run above has #1774's gate only), AMD, other titles, more than one run with the setting.

AI use: Claude Code with Claude Opus 5.5 made both runs, sampled the memory, read the log and the gate's code, and wrote this at my request.

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