D3D12.X: a background driver compile stays within a share of the RAM #1924
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1924
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1924"
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?
@Rednaxeh on GitHub · 2026-11-24 23:22 UTC · original
Rednaxeh:huge-compile-commit-by-size→main· +200 −23 · 3 files · 1 commits · openRebased on
main2898511with #1996's gate in: the size-scaled headroom is #1774's, the per-build cap and the commit wait before a slot are #1996's, and 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=4twice, defaults once:0xc0000005in the title's ownmemcpy, 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_SHAREsets thenof 1/n,0leaves the commit free alone to decide, as before) and within the RAM available now (under WineullAvailPageFileis the memory available plus the free swap and never falls, as @Royalflamejlh measured). And what the gated compiles already running take is counted: on a 4090 withXCL_HUGE_PSO_CONCURRENCY=8, @S1m0ne1997 saw four 0.76–1.06 MB compiles start on the same free commit, eachgated (waited 0 ms), while the system's free commit went 3.8 → 1.8 → 0.9 GB and the process 32.8 → 42.4 GB; the running total of theirbig_compile_takesis now taken off the commit free and added to what the next one takes for the share and the RAM available. Wanted builds (a title thread waiting) skip these checks and are not counted. A held 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.logsays so once per program and worker. Compiles the title waits for, and small ones, are unchanged.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_COMPILES_IN_FLIGHT(added when a slot is taken, taken off when itsSlotGuarddrops),big_compile_may_start(headroom, takes, in_flight, free, available, physical, ram_share), used bybig_compile_commit_free(dxil_len)at both gate call sites, which logs a program it holds back; testsa_background_compile_starts_within_the_commit_the_ram_share_and_the_ram_available,the_background_compiles_in_flight_count_against_the_next,a_background_compile_is_in_flight_until_its_guard_dropsanda_graphics_bind_releases_the_background_ram_share_gate.crates/xcl/src/hle/d3d12x/pso_async.rs:resolvemarks 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
stable-x86_64-pc-windows-msvc, DXC 1.9.2602.17 (Windows SDK 10.0.26100), debug for the tests, release for the titlecargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4onc09d376(21 test binaries): 1365 passed, 1 failed, 46 ignored. The failure,gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1(seed 722), fails identically onmainon this card (#2115).gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpuandf32_programs_on_the_gpu(the per-lane form refusesV_MUL_F16/V_PK_MUL_F16/V_CVT_F16_F32),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).want()line ("graphics bind left its compile held by the RAM-share gate") and passes with it.XCL_PSO_TRACE=1(on689f2db-based trees, before the rebases): without the share,XCL_HUGE_PSO_CONCURRENCY=4ended 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 ofmain689f2dbdied 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.
main2898511crashed in 2 of 3 smoke runs tonight at 29.5 s (0xc0000005inVCRUNTIME140.dll, a title thread'smemcpyreading0xc4901a000, 16 GB committed; not this PR: the samemainsurvived a 60 s run withXCL_TRACE_FAULTS=1andmain68a284aran 300 s), reported on #505.Not tested
XCL_HUGE_PSO_CONCURRENCY> 1): unit tests only; @S1m0ne1997's 4090 setup is where it would show.ullAvailPhyscondition follows @Royalflamejlh's reading; not run there.AI use
🤖 Generated with Claude Code
@WebIdentity1 on GitHub · 2026-11-24 23:41 UTC · original
The new permanent RAM-share cap exposes a graphics first-use gap on
6d7290d:driver_compile("graphics", ..., true, ...)enters this gate, butpso_async::resolve_for_binduses nonblockingresolvefor graphics, andresolvenever callsPending::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 graphicsPending, 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()fromresolve, 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:
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, atgraphics bind left its compile held by the RAM-share gate.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)
AI use: Codex with GPT-6 Astra inspected the path, wrote the candidate and test, ran the Windows comparison, and drafted this report.
@Rednaxeh on GitHub · 2026-11-25 00:04 UTC · original
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 on GitHub · 2026-11-25 00:35 UTC · original
A note from Linux on
224888a, not a title test: under Wine theullAvailPageFilethis 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 forwait_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 callbig_compile_commit_freemakes, run under Wine with/proc/meminforead right after it, 3 times.Tested
ullTotalPhys62.5 GBMemTotal62.5 GBullTotalPageFile118.5 GBMemTotal+SwapTotal(56.0 GB) = 118.5 GBullAvailPhys15.1, 15.1, 36.3 GBMemAvailable15.1, 15.1, 36.3 GBullAvailPageFile46.3, 46.3, 69.7 GBMemAvailable+SwapFree(31.2, 31.2, 33.5 GB) = 46.3, 46.3, 69.8 GBOn 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 -gon 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 >= neededtakesullAvailPageFileandneeded <= physical / ram_sharetakesullTotalPhys(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.needed <= ullAvailPhysbefore a background compile starts, for systems where the commit reading does not fall? I have not tried it. #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 on GitHub · 2026-11-25 00:51 UTC · original
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: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.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 #1774's gate as it is.@Royalflamejlh's Wine reading (
ullAvailPageFile= available + free swap there, so it never falls): asking forneeded ≤ ullAvailPhysas 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
ullAvailPhyscondition, and #1774 keeps the size rule. If #1774 would rather take 1–3 itself, I close this one and test there.@Parakeet-Wheat on GitHub · 2026-11-25 01:05 UTC · original
NVIDIA data point, since the description lists it as not tested: this PR merged onto
main6567c5f(clean), againstmainitself, on 32 GB of RAM.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: amainrun first to absorb the recompiles, then this PR, thenmainagain.95cc13288a27a96e) is not built in this run. Onmainits background build starts at 8.8 s and is still in the driver at 420 s (also in the firstmainrun, which never left the menus), with no crash.main). What it waits for in both is56c0cd3b82a00c6e(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.main. At 122 s it was 30.3 vs 31.4 GB.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 on GitHub · 2026-11-25 02:19 UTC · original
PR #1924 — D3D12.X background driver compile headroom
aaa093657b(fetched origin/main).What is in it
Tested
cargo build --workspaceandcargo test --workspace --no-runboth exited 0 outside the GPU lock.cargo test -p xcl --lib big_compile_tests -- --show-outputoutside the GPU lock. 11 passed, 0 failed, 0 ignored, 943 filtered out.cargo test --workspace --no-fail-fast -- --test-threads=4 --show-outputin one pass under the shared Arc lock viaL:/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.Not tested
AI use
gemini-4-neon) verified the counts againstpr1924-suite.logand published this report.@DavidM1911 on GitHub · 2026-11-25 02:33 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.@Rednaxeh on GitHub · 2026-11-25 07:28 UTC · original
Rebased on
mainwith #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 againstmain568e7dbare in the description. The conflict is gone.@S1m0ne1997 on GitHub · 2026-11-25 08:54 UTC · original
@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 withmain568e7db, 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, andXCL_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).gated (waited 0 ms), 11.0–17.9 s each in the driver.waited 0 msin 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.With the default (
XCL_HUGE_PSO_CONCURRENCYunset) 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_takesof the compiles in flight, added when a compile passes the gate and taken off when it ends, and the gate passes only whenfree − 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.
@Rednaxeh on GitHub · 2026-11-25 10:52 UTC · original
@S1m0ne1997 thank you, that is a real gap and your reading of the log is the same as mine: the gate reads the free commit once per compile, so with
XCL_HUGE_PSO_CONCURRENCY=8four compiles pass on the same number and each then grows in the driver. Please send it as a commit on this PR: a running total ofbig_compile_takesof the compiles in flight (added when one passes the gate, taken off when it ends), and the gate passing only whenfree − in flight ≥ headroomand, for this PR's two checks,takes + in flightwithin the RAM share and the RAM available. With a unit test onbig_compile_may_startfor two compiles that would each pass alone and not together, and your 4090 run with the setting in the description's Tested. I will rerun the suite and the smoke pair here (RDNA3, 32 GB) on the new head.Two data points from this card for the same gate, posted on #1442 and #1269 today: on 32 GB with ~29 GB committed by the title the 3 GB headroom is never free during world loading, so every background compile waits (as @Royalflamejlh measured on #505 and #2130 bounds); only a bind that waits gets one built, on the title's thread. The in-flight total does not change that case, it only keeps a big machine from over-committing.
@Rednaxeh on GitHub · 2026-11-25 18:00 UTC · original
Rebased on
main68a284awith #1996's gate (the per-build cap and the commit wait before a slot are #1996's now), and the compiles in flight are counted, as @S1m0ne1997 proposed: the running total of theirbig_compile_takescomes off the commit free and goes onto what the next one takes for the share and the RAM available; wanted builds are not counted. Head 43a769f, one commit; suite, SKIPPED list and a fresh smoke pair againstmain68a284aare in the description. The conflict is gone. @S1m0ne1997, if you can rerun yourXCL_HUGE_PSO_CONCURRENCY=8run on this head, the log should now show the later compiles waiting on the commit (gated (waited N ms)) instead of all starting at once.@Rednaxeh on GitHub · 2026-11-25 19:36 UTC · original
Rebased on
main2898511(the reda_bridged_mask_write…test ofmainis fixed there by #2420); headc09d376, still one commit, nothing else changed. Suite and a fresh smoke pair are in the description.main2898511itself crashed in 2 of 3 smoke runs on this card (a title-threadmemcpyread fault at 29.5 s, 16 GB committed; reported on #505), so themainblock shows that crash; the PR's head ran clean (1243 frames, 23.1 GB).@jennydeth on GitHub · 2026-11-25 23:02 UTC · original
NVIDIA data point (the description lists it as not tested): RTX 3060 12 GB / 32 GB RAM, exact head
c09d376against its basemain2898511, retail title 1.0.2.1 into its story load. No regression: no crash or device removal in either 600 s run, 94 % of the base's frames, 107 % of its peak commit. In this run the RAM share never decided anything (0is held backlines), so the pair checks for regressions and does not exercise the new condition.Tested
stable-x86_64-pc-windows-msvc); release build; DXC 1.9.2609.5 (XCL_DXC_DIR)cargo test --workspace --release --no-fail-fast -- --test-threads=4onc09d376: 1367 passed, 0 failed, 46 ignored (24 test targets incl. doc-tests). The four newbig_compile_testspass. SKIPPED (29): 21 × no wave64; 3 × per-lane form refused (V_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32); 3 × no D3D12 debug layer /d3d12SDKLayers.dll; 1 × no heap windows; 1 ×pso_measurement_compiles_an_exact_synthetic_record(cannot disable the driver cache)scripts/smoke.ps1 -Game <folder> -Seconds 600(XCL_NETWORK=0), scripted pad presses from the start screens into the story load (XCL_PRESS_AT),XCL_FRAME_DUMP=300, default settings otherwise. Head run first, then the base, both on the DXIL cache earlier runs of this title had filled.Regression run
main2898511:This PR,
c09d376:From the two logs:
main2898511c09d376a background compile … is held backXCL_HUGE_PSO_CONCURRENCYof 1 only one background compile is gated at a time, so nothing was in flight at a check; the hold-back line is logged only when the commit check passes and the share alone refuses, and it never was.Not tested
XCL_HUGE_PSO_CONCURRENCY> 1; @bmjask's cross-lane case (one compile in each of the big and giant lanes passing the check together)AI use: Claude Code (Claude Opus 5.5) built both commits, ran the suite and the two runs on my machine, read the logs and wrote this.
@DavidM1911 on GitHub · 2026-11-26 00:42 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
@bmjask on GitHub · 2026-11-25 21:27 UTC · original · reviewed
P1 cross-lane RAM-share race: BIG_COMPILES and GIANT_COMPILES serialize check/reservation under distinct Slots.n mutexes. One compile in each lane can both observe global in-flight zero/pass the same share/free decision before either fetch_adds, exceeding the RAM/commit budget this change intends to enforce. Use one shared admission lock/CAS reservation spanning read-check-add and add a synchronized BIG+GIANT race test where either alone fits but both do not.
@thehollowedone on GitHub · 2026-11-26 11:35 UTC · original
Follow-up to the cross-lane admission review on head
c09d376: I reproduced the race and tested a small candidate correction on Windows. The head was still current when checked.The test starts one BIG and one GIANT compile with separate slot locks. It synchronizes their first budget decisions after both observe zero in-flight bytes, then holds the first reservation. At 32 GiB physical RAM and share 4, each compile fits alone (3 and 6 GiB), but both require 9 GiB against an 8 GiB allowance. On the unmodified head, both lanes enter before either guard is released. The test uses synthetic budget values and does not allocate those gigabytes.
The candidate makes check plus reservation one atomic
try_updateoperation. If another lane changes the in-flight total first, the budget predicate is re-evaluated with the new total. The existing wanted-build bypass, lane caps, 50 ms retry and guard subtraction remain. This avoids a new cross-lane mutex around the OS memory query.Tested — Windows 11 build 26300, RTX 3080 Ti 12 GiB (NVIDIA 621.35), rustc 1.99.1 MSVC:
cargo test --offline --locked -p xcl --lib big_and_giant_compiles_cannot_both_take_the_last_ram_share -- --nocapture --test-threads=1: 0 passed, 1 failed, 0 ignored, 0 skips (both lanes exceeded the 8 GiB RAM share).cargo test --offline --locked -p xcl --lib big_compile_tests:: -- --nocapture --test-threads=1: 16 passed, 0 failed, 0 ignored, 0 skips.cargo build --offline --locked --workspace: passed. After that build,cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4: 1,367 passed, 1 failed, 46 ignored; 25 GPUSKIPPEDnotices are not coverage. The sole failure,console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk(DXIL not compiled yet), also reproduced with the same focused command on the untouched PR head. The foure2etests passed after building the workspace.This is a candidate patch, not a merge-readiness claim. I did not run paired clean-commit retail smoke, measure actual driver memory, or test AMD/Intel.
Candidate fix and synchronized regression diff
AI use: Codex (GPT-6.2 Sol) wrote and ran the local change and tests and drafted this report; Codex (GPT-6.2 Astra) independently reviewed the race and correction.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.