D3D12.X: count only queued background pipelines as still building #1168
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!1168
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1168"
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?
@eizispark on GitHub · 2026-11-24 12:47 UTC · original
eizispark:fix/894-queued-pipeline-count→main· +137 −14 · 1 files · 1 commits · openWith
XCL_LAZY_PSO=1enabled by default,submit_lazyinserts every translated stand-in pipeline intoPENDINGwhile sending only pipelines whose shader keys are inused-pipelines.txt(or ones later bound) to the background workers.pso_async::counts()still walkedPENDINGunder its mutex and counted every!doneentry, which kept the window title stuck on"compiling shaders: 0 running, 0 done, 57587 pipelines queued"after all active compiles finished (#894) and recorded dormant stand-ins as still building inreport.json.Part of #894 (fixes the
pipelines queued/background_pipelinesaccounting and removes theO(N)PENDINGlock scan on every window-title update; the title's loading-screen progression on #894's host remains separate).What is in it
crates/xcl/src/hle/d3d12x/pso_async.rs: track a monotonicIDLE -> QUEUED -> DONEatomic state on eachPendingtogether with a globalQUEUED_BUILDScounter incremented once when a pipeline is queued toqueue(), queued topreload(), or built on the binding thread, and decremented once oncomplete(), channel-send error,preload()orphan skip, orreleased().pso_async::counts()is now lock-free andO(1).crates/xcl/src/hle/d3d12x/pso_async.rs(used_tests): addlazy_stand_ins_are_not_counted_as_still_building_until_queued(serialized across allused_testsviaCOUNT_TEST_LOCKand holding thePENDINGguard across the final zero check) covering dormantsubmit_lazyentries, release of unqueued stand-ins,resolve-triggered queueing and completion, and exact immediate-1decrement onreleased()of an in-flight pipeline without double-decrement on worker completion.Tested
32.0.32015.16001),rustc 1.100.0 (0ef1bc386 2026-11-09), debug and release.cargo test --workspace --no-fail-fast -- --test-threads=4on the head, rebased ontomain1a0bbe3(after #1782): 1249 passed, 2 failed –gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1andfuzz_validate_and_gpu_3, which fail the same way on a cleanmain426a5a7on this adapter; 46 ignored.cargo test -p xcl --lib hle::d3d12x::pso_async -- --test-threads=4, 5 consecutive runs: 11 passed, 0 failed on each run (including #1782's twoPcCallstests).lazy_stand_ins_are_not_counted_as_still_building_until_queuedfailed before the fix:counts().2reported 64 for 64 unqueued lazy stand-ins.d3d12.background_pipelinesinreport.jsonwent from[228, 0, 57595]onmainto[228, 0, 0]once the 228 preloaded pipelines were built.Regression run
main:PR head:
Not tested
XCL_SAMPLE_*sample-data tests.AI use
pso_async::counts()in #894, wrote the fix and unit test, and ran the test suite and smoke check. Antigravity (Claude Opus 5.5) – rebased it ontomain1a0bbe3(merged the newa_released_queued_pipeline_is_not_built_by_normal_workerstest next to this one and put it underCOUNT_TEST_LOCK, since it fills every worker the count test needs), and reran the suite and the smoke pair.title_memory_budget_mbis 13,824 MB regardless of the adapter's memory #1337@fromthemoonx on GitHub · 2026-11-24 13:19 UTC · original
NVIDIA run with the whole suite, since Not tested lists NVIDIA.
Tested
stable-x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug39d761715ab47392c57fc53778d3c03b9486d8a5, which is on currentmain47efa2e(so also the merged result):cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4: 742 passed, 0 failed, 41 ignored. The newpso_async::used_tests::lazy_stand_ins_are_not_counted_as_still_building_until_queuedpassed.counts()changed back tomain's scan ofPENDING(every entry whosedoneis false), the new test fails atpso_async.rs:381. So it covers thepipelines queued/background_pipelinescount from #894.pso_async+hle::d3d12x::bindtests, 10 runs: 10 of 10 passed (9 each, the pipeline-wait budget tests included)e2e+gpu_pso_e2e, 3 runs: 3 of 3 passed. The test title builds its pipelines through the background path, with stand-ins.XCL_D3D12_DEBUG=1run logs the same set of debug-layer errors and warnings as onmain.gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardwareNot tested
used-pipelines.txtand tens of thousands of stand-ins (the #894 window title); release build.AI use
@JoaoPauluu on GitHub · 2026-11-24 13:24 UTC · original
A run under Wine on Linux: the count changes the same way as in the description's AMD run.
Tested
x86_64-pc-windows-gnu.39d7617as it is (based on47efa2e) andmain47efa2e, no uncommitted changes. Retail title 1.0.2.1,scripts/linux/smoke.sh(#257) for 60 s, no input. Runs in order: main, this PR, main.d3d12.background_pipelinesinreport.json:[228, 0, 57595]on bothmainruns,[228, 0, 0]on this PR.translated_pipelines228,failed_pipelines0 andfallback_pipelines0 in all three.Regression run
main (first run):
this PR:
The second
mainrun: 1382 frames,exit: 0x0, no device removal, no crash. Under Wine,peak commitreads 0 MB, so these blocks do not check memory.Not tested
pipelines queuedtext, native Windows.AI use
@eizispark on GitHub · 2026-11-24 15:36 UTC · original
Thanks @pvfreis for catching the
BUILDINGsymbol collision with25c6f7eand the two test questions, and thanks @fromthemoonx and @JoaoPauluu for the Windows and Linux/Wine NVIDIA test reports.Rebased onto current
main(930e8b4) as47f672e:QUEUED_BUILDS(resolvingE0428against theBUILDINGthread-local).used_testssubmit/submit_lazytests underCOUNT_TEST_LOCK, updatedsubmit_asandreleasedsoQUEUED_BUILDStransitions while holdingPENDING, and kept thePENDINGguard across the final zero check.< 64check on the orphaned in-flight pipeline with an exactafter_release + 1 == before_releasecheck aroundreleased(), followed by waiting ondoneand verifying worker completion leavescounts().2 == after_release.xcl-smokerun on47f672e.AI use: Antigravity (Gemini 4 Carbon)
@pvfreis on GitHub · 2026-11-24 15:51 UTC · original
Thanks. Checked at
47f672e(read only): the counter isQUEUED_BUILDSand the PR now merges intomain930e8b4with a singleBUILDING(the thread-local), the count tests run underCOUNT_TEST_LOCK, and the release check is exact. All three points are addressed.Reply by Claude Code (Claude Opus 5.5); checked by a person before posting.
@DavidM1911 on GitHub · 2026-11-25 07:46 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.@throny on GitHub · 2026-11-25 09:20 UTC · original
Test report for exact head
ad5ff40.Tested
cargo build --workspace && cargo test --workspace -- --test-threads=4onad5ff40as it is (its own base): 876 passed, 0 failed, 42 ignored.SKIPPED: 4 lines (no wave64 on this adapter, and the like).scripts/smoke.ps1, the retail title, 60 s, release builds,main568e7dbfirst, then this head:main:
PR:
Not tested: AMD, the head merged onto current
main, a world load.AI use: Claude Code (Claude Opus 5.5) ran this and wrote the report; the diff was read for safety by a Claude Opus 5.5 sub-agent before it was built.
@eizispark on GitHub · 2026-11-25 11:45 UTC · original
Rebased onto
main426a5a7as532ee56(thanks @DavidM1911 for flagging the conflict, and @throny for the RTX 4080 run onad5ff40).The conflict came from #972's
a_released_queued_pipeline_is_not_built_by_normal_workers(b4d7482), which was added in the same spot as this PR's test. Both are kept. That test now takesCOUNT_TEST_LOCK, because it fills every normal worker and holds a stand-in in flight, which would throw off this PR'scounts()checks if the two ran together. The accounting still holds with the new orphan skip inqueue():released()already callsfinish_queued()before a worker can drop the job.On the RX 9070 XT:
pso_async, 5 runs × 9 tests, all passed. Full workspace: 1241 passed; the 3 failures also fail on a cleanmain426a5a7here. New smoke pair in the description: 1680 frames on main, 1678 on the PR.@eizispark on GitHub · 2026-11-25 11:51 UTC · original
Main moved again a few minutes after the rebase (#1782 added its
PcCallstests toused_testsright next toCOUNT_TEST_LOCK), so this is now0840ff5on top ofmain1a0bbe3. Both are kept and nothing else changed.pso_async: 5 runs × 11 passed. Full workspace: 1249 passed; the 2 DXIL fuzz failures also fail on a cleanmainhere. The new smoke pair is in the description (1679 frames on the PR, 1680 on main).@DavidM1911 on GitHub · 2026-11-26 00:26 UTC · original
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.@pvfreis on GitHub · 2026-11-24 14:17 UTC · original · reviewed
Review of
39d7617(merge base47efa2e; currentmainis930e8b4), by reading the code; nothing was built or run here. On the head itself I found no path that leaves a queued build counted after it is built or released, and no underflow.main,pso_async.rsdefinesBUILDINGtwice. The head addsstatic BUILDING: AtomicUsize(pso_async.rs:88). After this PR was opened,maingot25c6f7e, which adds a module-levelthread_local! { static BUILDING: RefCell<Option<Arc<Pending>>> }to the same file (pso_async.rs:44-46onmain). The two merge without a textual conflict, but the merged file has both items (lines 51 and 159), used asBUILDING.with(..)and asBUILDING.fetch_add/fetch_sub/load. Two items with one name in a module is E0428, so the merged tree should not compile (by reading; not compiled here). Fix: rebase and give the counter its own name (e.g.QUEUED_BUILDS), then rerun the suite and the smoke block on the new head.Questions for the author
PENDINGlock before reading the global counter; with--test-threads=4, could another test'ssubmitorreleasedin between make it fail?counts().2 < 64; would checking the count before and afterreleasedshow that?Verdict: the counting looks right on its own; it needs a rebase and a rename before it can merge.
Review by Claude Code (written by Claude Opus 5.5, second read by Claude Fable 5.2); each point checked by a person before posting.
@Prime1997 on GitHub · 2026-11-26 13:16 UTC · original · reviewed
Exact reviewed head:
0840ff5a690c564caf808b7feecd8211f02aeded.Needs an atomic accounting fix; the dormant-versus-queued distinction is useful.
Pending::note_queuedfirst changesIDLEtoQUEUED, then incrementsQUEUED_BUILDS. The submission path holdsPENDING, butresolveobtains itsArcand releases that lock before callingnote_queued.A valid interleaving is: the count is zero; resolve successfully marks the pending entry QUEUED and pauses; another thread removes it through
released, whosefinish_queuedswaps DONE and subtracts one;counts()then readsusize::MAX; finally the delayed increment returns the count to zero. The final value is correct, but the window title/report can observe an enormous queued count. Acquire/release ordering on the per-entry state does not make the later counter update part of that transition.Please make publication of the queued state and its count consistent with completion/release, and add a controlled interleaving test. Existing sequential accounting tests do not exercise this gap. Source locations at this exact head:
pso_async.rs:120–129,863–875,1019–1025,1047.Validation: independently checked the actual resolve/release lock scopes and atomic ordering; no native race test was run. Current-main integration also needs a rebase. This is separate from the older BUILDING-name collision already fixed by this revision.
AI use: Codex (GPT-6) reviewed the source and checked the stated evidence. Optional temporary Discord for coordinating contributor work, testing and comparing results.
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.