Recompiler: title-thread lazy compute builds bypass BIG_COMPILES/GIANT_COMPILES caps, dxc::wait_for_memory TOCTOU race, and pso.rs compact/validation cache gaps #2463
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#2463
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@microwave805 on GitHub · 2026-11-25 19:30 UTC · original
Static audit on
main @ c7e1799found three compile-gating / cache-safety bugs on the shader pipeline compilation path. Part of #1269, Part of #1566. (Note: open PR #2424 separately covers inline split helperparent = Noneinpso_async::build_pieces, and #1409 already coversXCL_SAFE_BARRIER=0.)1. Title-thread lazy compute builds completely bypass
BIG_COMPILES/GIANT_COMPILESOOM capscrates/xcl/src/hle/d3d12x/real.rs:3976-3986, 4047(driver_compile_identified),5909(finish_two_pass);crates/xcl/src/hle/d3d12x/pso_async.rs:1032-1056(resolve_wait_for)driver_compile_identified(real.rs:4047) andfinish_two_pass(real.rs:5909) only gate threads whose name starts with"xcl-pso": Under default settings (XCL_LAZY_PSO=1,XCL_PSO_WAIT_MSunset →wait_budget() == None),resolve_wait_for(pso_async.rs:1043-1046) runsjob()synchronously on the calling title thread (not named"xcl-pso*"). Thushuge == falseand concurrent title-thread lazy builds (or a title-thread giant build alongside a worker's giant build) completely bypass bothBIG_COMPILES(wanted_most = 2) andGIANT_COMPILES(wanted_most = 1), allowing unbounded concurrent giant driver compiles → OOM.starts_with("xcl-pso")exemption atreal.rs:4047, 5909and passwanted = !pso_async::building_here() || pso_async::build_is_wanted()tobig_compile_turn(so title threads bypass background commit waits while still respectingwanted_most).2.
dxc::wait_for_memoryTOCTOU race admits bursts of compiles pastWANTED_AT_ONCEand commit-headroom capscrates/xcl/src/gpu/recomp/dxc.rs:399, 444-462(wait_for_memory)451-456loadWORKING.load(Ordering::Acquire)to checkplentyandWORKING < WANTED_AT_ONCE, then unconditionally executeWORKING.fetch_add(1, Ordering::AcqRel)outside any lock or CAS loop (unlike line 457'scompare_exchange(0, 1, ...)). When a burst of worker threads wakes up simultaneously under tight commit headroom, every thread seesWORKING == 0and entersfetch_add(1)at once, spiking commit past OOM.WORKINGincrement with aMutexor CAS loop.3.
pso.rstranslated / refusal cache (#1474):direct_output()omitscompact_nest_tag(), and productioncached_rerouted/store_inskip container validationcrates/xcl/src/gpu/recomp/pso.rs:263-266, 344-363(store_in),456-458(cached_in),491-506(direct_output),535-554(cached_rerouted)identity()(pso.rs:263-266) includescompact_nest_tag()(XCL_DIRECT_COMPACT_NEST) only whenBackend::current() != Backend::Hlsl, whiledirect_output()(pso.rs:491-506) omitscompact_nest_tag()completely. Under default HLSL mode,enormous(> 8 MiB HLSL) compute shaders auto-rerouted todirect_compute(pso.rs:602-617) collide on the samererouted.binand.errpaths across differentXCL_DIRECT_COMPACT_NESTsettings.cached_rerouted(pso.rs:540-547) omits thevalid_dxil_container(&c.dxil)guard enforced incached_in(pso.rs:456-458), andstore_in(pso.rs:345-363) validates only&c.dxiland notchain.pieces(whereasload_inatpso.rs:334rejects invalid pieces).compact_nest_tag()indirect_output(), and enforcevalid_dxil_containeronc.dxiland alldispatch_chain.piecesin bothcached_reroutedandstore_in.AI use
main @ c7e1799and issue drafting.@itsSio on GitHub · 2026-11-25 22:26 UTC · original · edited 2026-11-25 22:51 UTC
Completed item 1 of
#2463on my fork (itsSio/xcl#4, branchd3d12x/title-thread-compile-gate, commit5a60764a), ready as a fork draft PR pending paired retailscripts/smoke.ps1runs before upstream submission.Implemented (
5a60764a)crates/xcl/src/hle/d3d12x/pso_async.rs(+7/-0 runtime, +22/-0 tests): addedpub(super) fn wanted_compile() -> bool { !building_here() || build_is_wanted() }and unit testtitle_threads_always_report_wanted_compile_while_workers_follow_demand.crates/xcl/src/hle/d3d12x/real.rs(+6/-6 runtime, +102/-14 tests): removed thestarts_with("xcl-pso")thread-name exemption indriver_compile_identifiedandfinish_two_pass, wiredwanted_compileintobig_compile_turn, updatedgate_note, and replacedsmall_and_title_thread_compiles_bypass_the_gatewith unit tests verifying small/cached bypasses, title-thread gating/caps acrossBIG_COMPILES/GIANT_COMPILES, and commit-wait bypass.Tested (debug build, clean commit
5a60764a7526e14aa7d49ba82539b25248c87e03)32.0.16.1088, rustc 1.97.0, DXC 1.9.2609.5):cargo test --workspace -- --test-threads=4: 1426 passed, 0 failed, 46 ignored (26SKIPPED: 22 wave64, 3#1426f16/cvt per-lane refused, 1 no heap windows).big_compile_tests&pso_async: 13 passed, 0 failed, 0 ignored and 15 passed, 0 failed, 0 ignored (0SKIPPED).XCL_ADAPTER=radeon, driver32.0.21043.5001):big_compile_tests(13/0/0),pso_async(15/0/0),gpu_pso_e2e(7/0/0),gpu_compute_e2e(6/0/0, 1SKIPPED: no heap windows).cargo test --workspace -- --test-threads=4: 1426 passed, 0 failed, 46 ignored (29SKIPPED: 22 wave64, 3#1426per-lane refused, 1 no heap windows, 2 no debug layer DLL, 1 no developer mode for driver-cache disable).big_compile_tests(13/0/0),pso_async(15/0/0),gpu_pso_e2e(7/0/0).Not tested
scripts/smoke.ps1regression runs (not yet available), AMD RDNA4 / discrete AMD GPUs, Intel GPUs.AI use
Ran via Samaritan:
@KOLESNiii on GitHub · 2026-11-26 00:52 UTC · original
Related admission issue on
amd-devat6a0bb5b4f294b0729771ed457af1f96c01f5c06b. The new 16-per-frame deferred-dispatch limit checkshas_slotunder the mutex, drops the lock forsplit, and records the allocation afterward under a second lock. At a count of 15, two recording threads can both pass the check before either records its allocation. If both splits succeed, the count reaches 17. The existing unit test checks the serial path. Admission and allocation, current test.A standalone test using the branch's
FrameDeferCapand a barrier between the check and increment reached 17 with two threads. The narrow fix would reserve under the first lock and give back the reservation on failedsplitfor that same present, leaving driver calls outside the lock. This demonstrates a cap overshoot. Windows allocator behavior and the effect on memory or presents remain unmeasured.The same AMD head has a separate offline admission problem.
Pipelines::make_oneincrements the sharedrunningcount before taking the 900 KiB cold-compile mutex. With four driver slots and four cold giant jobs, one can be in the driver while three hold the remaining shared slots waiting for the giant mutex. A fifth, small job then cannot reach the driver. This scheduling consequence follows from the lock order. Whether it explains any reported offline stall is unmeasured. For #2179 or the branch equivalent, hold shared slots only for jobs ready to issue the native call. Slot acquisition, giant lock and release.AI use — OpenAI Codex (GPT-6, exact serving variant unavailable) traced the code, ran the standalone probe and drafted this comment.
@KOLESNiii on GitHub · 2026-11-26 01:34 UTC · original
Follow-up on
mainb49be18. There is also a shared commit-budget gap even when both native calls run on a gated worker. The 256 KiB-class and 4 MiB-class builds use separate counters and mutexes. Each checks the current free-commit snapshot before taking its own slot. Both can enter while that snapshot still looks good, before either driver call has grown its commit. The counters enforce their class limits. They carry no combined reservation. An extracted-code test with a fake commit snapshot admitted both classes when each estimate fit individually and their sum exceeded the snapshot. This establishes the admission behavior, with no inference about an actual compiler's peak. Classes · Admission and estimate#1924 already proposes counting background builds in flight. The useful regression for that direction is concurrent cross-class admission with the same budget snapshot. Check and charge the shared reservation together, while preserving the per-class count limits. A separate test should cover the reserved foreground allowance across both classes. Related to #2508 and #2608.
Static review and standalone Linux probe. Windows behavior remains unmeasured. AI use was OpenAI Codex (GPT-6, exact serving variant unavailable) for review, probe and drafting.
@oni-swr on GitHub · 2026-11-26 08:21 UTC · original
Claiming an independent amd-win test report on PR #2652 at
88d7b0a1, covering the synthetic DXC admission tests and an RX 7800 XT workspace run against the exact parent.AI use: Codex (gpt-6.2-sol) coordinated this claim. Claude Code (Claude Sonnet 5.5) is planned for verification.
@oni-swr on GitHub · 2026-11-26 08:31 UTC · original
Report posted for the claim above: #2652 (exact head
88d7b0a1vs parentb49be183on RX 7800 XT: 1438 passed / 1 failed / 47 ignored vs 1434 / 1 / 47; the one failure, fuzz seed 722, is the same on both). The RX 7800 XT slot is released. Claude Code (Claude Sonnet 5.5).