D3D12.X: a worker waiting for a big compile turn leaves the queue to a helper #2628
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!2628
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2628"
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?
@KOLESNiii on GitHub · 2026-11-26 03:10 UTC · original
KOLESNiii:d3d12x-gate-frees-worker→main· +179 −9 · 2 files · 1 commits · draftA huge driver compile on an
xcl-psoworker waits inbig_compile_turnfor one of the few slots (one at a time by default, 3 GB of free commit each), and it keeps its worker thread while it waits. When the retail title of #505 starts its world, every worker takes one of the title's huge compute programs and waits there, with only one or two of them compiling, so the rest of the queue has no worker. With this change, a pool worker that has to wait gets a helper thread in its place, up to as many helpers as the pool has workers. The helper serves the queue and leaves once the worker is back. The slots and the commit check are unchanged, so no more driver compiles run at once than before. This is not "more workers" in the sense #2088 warns against.Part of #1269, #2088 (scheduling).
What is in it
crates/xcl/src/hle/d3d12x/pso_async.rs:parked()returns a guard. On a pool worker it counts the worker as parked and starts a helper (xcl-pso-h{k}) while the number of helpers is below the number of parked workers. Off the pool, it does nothing.workers_parked_for_big_compiles_leave_the_queue_to_helpers: parks every worker and checks that a job queued behind them still runs, and that the counts return to 0. Without the change, that job never runs.parked_outside_the_pool_starts_no_helper.crates/xcl/src/hle/d3d12x/real.rs:big_compile_turntakes the guard before its first wait and holds it until it gets its slot.Tested
cargo test --workspace -- --test-threads=4on3693d9e: 1431 passed, 0 failed, 47 ignored; 25SKIPPEDchecks: 21 "no wave64", 3 f16 per-lane forms refused (#1426), 1 "no heap windows"Setup:
XCL_DXIL_CACHEShaderCacheControlcall, the same in both trees, not in this PR)XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_PSO_TRACE=1Results, one run each, the 10 min after the world load, from
xcl.log:main08db802Frames do not come back within 10 min in either run. Most of what is left on the title's threads is graphics pipelines built at a draw's first bind, which #1798 addresses. With #1798 on top of this PR, the title's threads spent 66 s in builds instead of 319 s (test report on #1798).
Regression run
main:This PR:
Not tested
mainhas moved by 4 commits since08db802(#2371). The PR merges into it without conflicts, but it was not rebased or rerun on it.AI use
🤖 Generated with Claude Code
https://claude.ai/code/session_015csBcd63KUE2T1kW2P15nC
@GodlyBDS on GitHub · 2026-11-26 03:25 UTC · original
Independent Ampere trace relevant to the worker-gate change. RTX 3090 Ti, driver 621.40, Windows 10, 32 GiB RAM. This was
e877812efrom #2624 with the local Windows startup compatibility fixes, four named PSO workers,XCL_HUGE_PSO_CONCURRENCY=1, and on-demand compilation. I have not applied #2628 to this run.For 31 gated compute compiles completing from 225 to 380 s, the median recorded gate wait was 10.441 s and the median time in the driver was 4.941 s. The longest recorded gate wait was 47.588 s, followed by 5.006 s of native compilation. Correlating the driver starts with their measured gate durations shows three of the four PSO workers waiting at the gate concurrently. The 435.403 s summed across workers is overlapping time, not wall time.
The title stopped presenting for this interval while compiles continued to finish. The trace establishes substantial worker occupancy at the gate on Ampere under the conservative compile limit. It does not establish how much of the Present gap a helper would remove. The experiment was left running while the queue progressed.
AI use: OpenAI Codex (GPT-6) correlated the log events and drafted this report.
@pickles976 on GitHub · 2026-11-26 03:26 UTC · original
Wine 11.0,
XCL_DXC_THREADS=2, exact head3693d9efe41c7f69b4f4d9a04b98c66ab6a94b7d, Windows-targetcargo test --locked --target x86_64-pc-windows-msvc -p xcl --lib parked -- --nocapture --test-threads=1: 3 pass, 1 fail.workers_parked_for_big_compiles_leave_the_queue_to_helpersstarts two helpers and executes the queued job, butpso_async.rs:1175observesPARKED=2immediately after releasing the workers, before they finish, and assertsPARKED==0. The test waits only whileHELPERS > PARKED(:1172), which is false when both equal 2. This is a test synchronization race, not evidence that the queue helper failed.Test-only diagnostic: replace the wait condition with
(PARKED.load(Acquire) != 0 || HELPERS.load(Acquire) != 0)under the existing 10 s deadline, then assert both zero. The focused test passed 1/1 in 0.26 s after this change; the temporary edit was restored. Please make that bounded wait in the PR test so a slower scheduler is not a false negative. Local logs:.compat-xcl/logs/verify-pr2628-wine-two-worker-helper{,-wait-fix}.log(not attached). No actual large driver compile or retail title was exercised; your reported ~1.1 GB higher smoke peak commit makes this unsuitable as a 16 GiB RAM reduction without a guarded A/B.@KDenKC on GitHub · 2026-11-26 06:06 UTC · original
Source review of head
3693d9ef, no run. One small thing about helper retirement inserve(pso_async.rs):A base worker waits with
rx.lock().unwrap().recv(), so an idle one keeps theINBOXmutex for as long as the queue is empty. A helper that wants to time out and reachretire_helper()first needs that mutex for itsrecv_timeout(250 ms). While a worker that came back from its turn is idle inrecv(), the helpers block onlock()instead, and they only retire once new work wakes that worker. Building is unaffected; the helpers' threads (64 MiB stack reservations) just linger through idle periods. Taking work withtry_recv/recv_timeouton the base workers too, or aCondvarqueue instead ofMutex<Receiver>, would let them leave on time.Not tested: no build or run of this head on our side.
AI use: Gemini (Antigravity) flagged it in a first-pass review; Claude Code (Claude Opus 5.5) checked it against the source at
3693d9efand wrote this.@luckyteagirl on GitHub · 2026-11-26 05:52 UTC · original · reviewed
Could helper retirement and park admission use one synchronized state? A retiring helper can read
HELPERS=1andPARKED=0, then pause before its CAS. The worker can park again, incrementPARKEDto 1, seeHELPERS=1, and start no replacement. The helper's CAS from 1 to 0 then succeeds and it exits. WithXCL_DXC_THREADS=1, the final state is one parked worker and no helper, so a queued small build is unserved until the big-compile wait ends. This is a sequentially consistent interleaving; stronger atomic ordering alone would not close it. A controlled retirement/new-park overlap should assert a helper remains available for a later job. Exact-head source review at3693d9efe41c7f69b4f4d9a04b98c66ab6a94b7d; no live stall reproduction. AI-assisted review with Codex.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.