D3D12.X: bound wait_for_commit so big background compiles cannot deadlock #567
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!567
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/567/head"
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?
@gridoe on GitHub · 2026-11-24 01:55 UTC · original
gridoe:wait-for-commit-bound→main· +61 −8 · 1 files · 1 commits · closed without mergingBound
wait_for_commitind3d12x/real.rswith a 5 s grace timeout so big background compute PSO compiles cannot permanently deadlockBIG_COMPILES.Previously,
wait_for_commitpolledGlobalMemoryStatusExin an unbounded loop untilullAvailPageFile >= 3 GiBwhile holding the singleBIG_COMPILES(most: 1) slot. On a 32 GB Windows system with a system-managed dynamic pagefile (~47 GB initial commit limit), once a retail title commits ~41–42 GB, Windows does not expandpagefile.syswhile threads only pollGlobalMemoryStatusEx. The worker then slept indefinitely holdingBIG_COMPILES, starving every subsequent queued compute PSO behind it.Keeping
BIG_COMPILESserialized to 1 and the 3 GiB target unchanged,wait_for_commitnow waits up to 5 s (BIG_COMMIT_GRACE) before proceeding one compile at a time and logging once if the grace window expires.What is in it
crates/xcl/src/hle/d3d12x/real.rs: extractavail_pagefile_bytesandwait_for_commit_withwith a 5 sBIG_COMMIT_GRACEcap, log once when proceeding below the 3 GiB target, and add unit testswait_for_commit_returns_when_headroom_appearsandwait_for_commit_does_not_hang_forever_below_reserve.Tested
rustc 1.99.1 (58cf8f9c3 2026-10-13)(stable-x86_64-pc-windows-msvc), debug (tests) and release (smoke)..\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 682 passed, 0 failed, 41 ignored.SKIPPEDGPU tests on this adapter: 2 (no wave64—gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware).wait_for_commit_returns_when_headroom_appearsandwait_for_commit_does_not_hang_forever_below_reservepass.Regression run
Not tested
pagefile.syscannot grow past the initial commit limit.XCL_SAMPLE_*env vars.wait_for_commitpreviously wedged; that path is exercised by the new unit tests.AI use
wait_for_commit_with, unit tests, and the PR description; all builds, tests, and smoke runs were executed locally on the hardware listed above.@chadatouille on GitHub · 2026-11-24 02:43 UTC · original
A before/after on the case listed here under Not tested (a fixed page file), on an NVIDIA machine whose 32 GB run stopped in the same place. This is data on the mechanism; #567 itself was not built or run.
Setup
v0.1.0-mod.10(3a67b92) + the diff of #484 (9783066). Not upstreammain: that fork has its own limit on pipeline waits (XCL_PSO_WAIT_MS, default 4 s). Itswait_for_commitis the loop this PR replaces (the diff of #567 applies to that tree with no conflict).XCL_NETWORK=0 XCL_ACTIVITY=1, screens walked by hand. One run per configuration. Counts are from XCL's own thread dump at the stop.xcl-dxcthreads inwait_for_memoryxcl-psothread inwait_for_commitxcl-psothreads probably queued onBIG_COMPILESresolve_waitWait64BitValueX timed outlinescompute PSO with the translated console CSlines+0x23cf683)What it shows
wait_for_commitholding the oneBIG_COMPILESslot.resolve_wait. So on this machine commit is one cause of the stall, not the only one.Limits
wait_for_commit92/94,real.rs:3373). TheBIG_COMPILESframes did not match directly, hence "probably".Not tested: #567 on any build, plain
main, AMD, other titles.AI use: Claude Code (Claude Opus 5.5) read the logs, matched the stack frames, built the binary and wrote this comment, and posted it at the account owner's request. The owner did the runs. Counts and offsets only; no game data.
@MesshM on GitHub · 2026-11-24 02:46 UTC · original
Test run of
7a63914dcaf56cd930a91b3874ffcca88e80ad3con AMD RDNA4; the PR was tested on NVIDIA only. I merged it onto currentmain3db536elocally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 688 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 648 passed, 0 failed, 21 ignoredSKIPPED;wait_for_commit_returns_when_headroom_appearsandwait_for_commit_does_not_hang_forever_below_reservepass.Review:
wait_for_commit_withreturns at once whenGlobalMemoryStatusExfails (as before) or when the reserve is met, and gives up afterBIG_COMMIT_GRACE; the compile then goes ahead, still one at a time underBIG_COMPILES. That is a trade-off rather than a bug: past the 5 s, a big compile can start with less than 3 GB of free commit, which the old loop never allowed, so the title's own commits next to it have less room. The warning is logged once per process (Once), so later fallbacks are silent; a counter inreport.jsonwould show how often it happens. I found nothing to change in the code itself.Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
@mastrr9 on GitHub · 2026-11-24 04:10 UTC · original
Code audit + NVIDIA RTX 5080 test run on
7a63914dcaf56cd930a91b3874ffcca88e80ad3c:Review
Looks clean and ready to merge — bounding
wait_for_committoBIG_COMMIT_GRACE = 5 sbreaks the Windows dynamic pagefile deadlock while keeping big compiles serialized one at a time underBIG_COMPILES. Both unit tests cleanly exercise the headroom-appears and timeout paths.Tested
rustc 1.100.0(MSVC), debug build.cargo build --workspace && cargo test --workspace -- --test-threads=4: 682 passed, 0 failed, 41 ignored.wait_for_commit_returns_when_headroom_appearsandwait_for_commit_does_not_hang_forever_below_reserve: both passed.SKIPPEDGPU/D3D12 tests:gpu_geometry_wave32_prefix_count_over_a_mask/gpu_wave32_program_in_wave64_hardware(no wave64), plus 2 D3D12 debug-layer tests (no d3d12SDKLayers.dll).Not tested
scripts/smoke.ps1run (test suite only).AI use: code review and test run orchestrated with Antigravity (Gemini 4 Neon) on the hardware listed above.
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175@brainhay5 on GitHub · 2026-11-24 12:58 UTC · original
Tested merged onto
main47efa2e(clean merge), RTX 5070 Ti, driver 32.0.16.1088, Windows 11 22631,XCL_NETWORK=0,XCL_PRESS_A_ATevery 5 s, full launch.It does not change the stall here. XCL's own overlay at 95 s:
On plain
47efa2ethe same capture reads0 running, 3 done, 57516 queued. Both are a black screen at 0 fps with the queue full.The thread dump at the end shows
xcl-pso-5…xcl-pso-14all inntdll.dll+0xa49f4(a wait) and none in DXC, so the workers are blocked with ~57k pipelines queued, not busy. If that is the deadlock this PR is meant to bound, it does not show up as drained work on this title.Not tested: AMD, other titles, longer runs.
AI use: OpenCode, DeepSeek V4.1 Flash 1017.
@gridoe on GitHub · 2026-11-24 15:12 UTC · original · edited 2026-11-24 15:51 UTC
Closing as superseded by ivall's commits
25c6f7e("D3D12.X: a big pipeline build the title waits for does not wait for its turn") and9a272d4onmain, which replacewait_for_commit()with awanted()bypass that solves the deadlock cleanly without dropping the 3 GB commit reserve for un-waited speculative builds.Thanks to @chadatouille, @MesshM, @mastrr9, and @brainhay5 for testing and feedback!
AI use
25c6f7e/9a272d4against this PR and drafted this closing note.Pull request closed