D3D12.X: bound driver PSO compile concurrency and surface stage progress (#156) #214
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!214
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-214"
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?
@heretic1321 on GitHub · 2026-11-23 21:07 UTC · original
heretic1321:fix/nvidia-pso-stall→main· +379 −39 · 3 files · 1 commits · openMitigation and stage instrumentation for #156, rebased as a single commit onto
upstream/main(47efa2e, head96e68a4). Incorporates@woreksami's tested conflict resolution against#516,#634/#636, and#690and fixes the rejected-cached-blob retry edge case.What is in it
crates/xcl/src/hle/d3d12x/real.rs:DriverCompileGuardbounding background (xcl-pso-*other thanxcl-pso-urgent, covering bothxcl-pso-Nand#690'sxcl-pso-pre-N) driverCreate*PipelineStateconcurrency across all translated paths (CSaround#634/#636's cached-blob lookup + retry,VS+PSaroundretry_without_rect_gs,MS-mesh/MS-cs,GS-mesh/GS-cs):BIG_COMPILES(1,>= XCL_BIG_PSO_KB, default256KiB) → 30 s-cappedwait_for_commit()→driver_compiles()(XCL_DRIVER_COMPILE_THREADS, default2on 32-lane-only / NVIDIA,4on 64-lane). Title threads andxcl-pso-urgentbypass both semaphores andwait_for_commit().finish_psorejects a cached compute blob (hr < 0 && cached.is_some()),guard.discard()drops the cached-size guard without incrementingDRIVER_COMPILING[1]or logging twice, andDriverCompileGuard::enterre-enters withdxil.len()before the cold retry so big shaders still respectBIG_COMPILESandwait_for_commit().driver_compile_counts(), admission + compile slow logging (>= 2 sorXCL_TRACE_PSO_TIME=1), console topology/RTV/DSV translation infallback_stream(subobjects14/15/16) andtranslated_gs_pso, plus unit tests (big_compile_serialization_leaves_fast_lane_for_small_compiles,urgent_and_title_threads_are_exempt_from_background_slots).crates/xcl/src/hle/d3d12x/pso_async.rs:counts()via atomicQUEUED+mark_enqueued/finish_pending/enqueueexcluding dormant lazy stand-ins (preloadkeeps using#690's low-priority queue without inflatingQUEUED), plus isolated unit testdormant_lazy_pipelines_are_not_counted_as_queued.crates/xcl/src/hle/d3d12x/present.rs:upstream/main'sFPSwindow title (#516) and surfaces driver compile counts alongside DXC and queued counts (compiling shaders: N dxc, M done[, D driver (C done)][, Q pipelines queued][, F failed]).Overlaps
#567(boundswait_for_committo 5 s vs our 30 s cap).#267,#533,#891(bound title-thread wait durations; orthogonal to bounding worker driver compile concurrency).#628(prioritizes graphics over compute inpso_async's worker queue).Tested
1.95.0, head96e68a4onupstream/main47efa2e:AR_x86_64_pc_windows_msvc=llvm-ar cargo check --release --workspace --target x86_64-pc-windows-msvc— exit 0 (13.14s, 0 errors, 0 warnings).AR_x86_64_pc_windows_msvc=llvm-ar cargo check --tests --workspace --target x86_64-pc-windows-msvc— exit 0 (8.48s, 0 errors, 0 warnings).python3 scripts/pr_check.py --localverified all required sections and asset/model checks (failing only on the missing Windowsxcl-smokeblocks).96e68a4):@woreksamitested960162eon Windows 11 + RTX 3060 8 GB (queue drained0 driver (18 done), retail title advanced to setup/loading) and tested a local conflict resolution ontomain6025201(cargo test --release -p xcl --lib: 666 passed, 0 failed, 21 ignored).@mikebuckets171tested960162eviax86_64-pc-windows-gnullvm/ Wine on macOS (dormant_lazy_pipelines_are_not_counted_as_queuedpassed).@yous0serious(RTX 4090) and@Kalmarv(RTX 5070 Ti) testedbf2a27e; review points from both were incorporated in960162eand retained here.Regression run
96e68a4(no Windows GPU host here; Windows testers are invited to runscripts/smoke.ps1onmainvs96e68a4).Not tested
lld-link/link.exe),cargo test --workspaceexecution, GPU tests, AMD / Intel hardware, andscripts/smoke.ps1/ retail title runs on96e68a4.AI use
T3 Code / Antigravity, Orchestrator (Neon) / gemini-pro-orchestrator-neon: rebased ontoupstream/main(47efa2e), applied conflict resolution, addedDriverCompileGuard::discard()for rejected-cached-blob retries, and ran Linux-to-x86_64-pc-windows-msvccargo checkandscripts/pr_check.py --local.@yous0serious on GitHub · 2026-11-23 21:30 UTC · original
Tested on Windows + NVIDIA (RTX 4090)
The PR says it was never built or run on Windows, so here is a Windows / NVIDIA run. No retail game here, so the measurement plan above (thread dumps,
XCL_TRACE_PSO_TIME) is not covered – only build, test suite and the synthetic GPU experiments.Setup: Windows 11, i7-13700KF, RTX 4090 (driver 32.0.16.2101, wave32 only), Rust 1.100 MSVC, Agility SDK 1.620.2, Windows SDK DXC 1.8.2502 (and DXC 1.9.2609 for E2).
cargo build --release --workspace(MSVC link)cargo test --workspace --release -- --test-threads=4, branch as is (bf2a27e)SKIPPED … no wave64)main(af20b4b)pso_async::tests::dormant_lazy_pipelines_are_not_counted_as_queued,queue_tests::big_compile_serialization_leaves_fast_lane_for_small_compilesaperture_testsGPU tests (from #187)E2 (
e2_window_compile_time, 700 blocks, 19 601 instructions, median of 3):switchOn this NVIDIA card the DXC step dominates, not the driver: the heap windows cut DXC ~12× and the driver's one cold compile ~6× against the
switchform. Two of three driver compiles per form return in < 10 ms despite the random literal (the driver's cache, presumably) – the test prints them sorted, so only the cold one is meaningful. DXC 1.9 vs the SDK's 1.8 is only 10–18 % here (the big gap in #156 was against 1.7). E1b could not run (no debug layer through the Agility factory here,0x887A002D).One thing from reading the code (not measured – no game)
Title-thread compiles now wait on the background slots. Before this PR only
xcl-pso-Nworkers tookBIG_COMPILES(big compute only); a compile on the title's own thread (dev_create_*_pso→dxc::urgent(…)when there is no stand-in) or onxcl-pso-urgent(pso_async::resolve_wait, a bind waiting for its pipeline) went straight to the driver. WithDriverCompileGuard::enterevery translated compile takes adriver_compiles()slot (2 on NVIDIA), and a big oneBIG_COMPILES(1) first. Up tocores - 1workers wait on the sameCondvar(notify_one, no order or priority), so a title thread that blocks for one pipeline can wait behind several unrelated background compiles – and behind a big one holdingBIG_COMPILESthrough up to 30 s ofwait_for_commitplus its own driver compile. Letting threads that are notxcl-pso-Nworkers bypass the slots (or giving them a reserved lane) would keep the bound on background work without stalling the title.wait_for_commitalready exemptsxcl-pso-urgent; the slots don't.Minor:
dormant_lazy_pipelines_are_not_counted_as_queuedcompares the globalQUEUEDbefore / after while other lib tests may queue pipelines in parallel – passed 3 / 3 here, but it could flake.AI-assisted (GitHub Copilot); runs and numbers are from my machine.
@Kalmarv on GitHub · 2026-11-23 21:52 UTC · original
Tested on an RTX 5070 Ti, merged onto
main. The PR fixes two things that fail onmain, and it no longer merges. Three notes follow.What it fixes, shown on
main:mainand passes on the merge.mainreturnsE_INVALIDARGfor topology 19, RTV format 116, DSV format 118 and the three together. The merge creates all four. A control with PC formats succeeds on both.Notes:
The size threshold depends on the DXC version. At the default 256 KiB (
real.rs:3071), all three E2 forms below take the large-pipeline slot with the SDK's DXC 1.7. With DXC 1.9 only the four-window switch form does, because 1.9's DXIL is 2–4× smaller. The same thing happened to #156's F case, which shrank from 633 KB to 235 KB.The wait for a slot isn't timed. The compile trace starts after both semaphores are taken (
real.rs:3208). With the two small slots held, anxcl-pso-urgentthread waited 251 ms to get in, and its compile timer then read 300 ns. Timing the admission wait separately would show that part of a bind stall (#156).Rebase.
main7a033c8the stack conflicts inreal.rs.bf2a27e(+282 / −29) on its own also conflicts inpso_async.rs.8c0346d, behind its currentc74b03a.It might go in more easily as three PRs:
submit_as/resolve_wait;E2 (from #187) at 700 blocks / 19,601 instructions. Each cell is DXIL bytes, median DXC seconds, and the range of three driver times in seconds:
Tested
bf2a27emain60565c460565c4e2_window_compile_time(ignored bench) on the same merge.7a033c8: a merge check only.Not tested
🤖 GPT-6.2 Astra, Claude Opus 5.5
@heretic1321 on GitHub · 2026-11-24 00:02 UTC · original
Ready for review at
960162e, on currentupstream/main4017f8fwith no stacked PRs.Review points, one by one
xcl-pso-urgentqueueing behind background work — fixed by a reserved lane.is_background_pso_worker_name()recognisesxcl-pso-Nonly; those takeBIG_COMPILES→ bounded commit wait → driver slot. Title threads andxcl-pso-urgentbypass all three and only track/log. Unit testurgent_and_title_threads_are_exempt_from_background_slotssaturates both semaphores and asserts a caller thread and a spawned urgent thread enter immediately.lane=bg|urgent, and slow-logged at the same 2 s threshold.wait_for_commitkeeps its 30 s cap and its urgent exemption.mark_enqueued/finish_pendingtake a local counter; the assertion no longer reads globalQUEUED.XCL_BIG_PSO_KBremains the knob; noted in the body for DXC 1.9's smaller DXIL.QUEUEDaccounting + its isolated test, (c)fallback_stream14/15/16 +translated_gs_psoformat conversion + the native PSO test. Say which you want and I'll post (a) first and stack the rest, or keep one commit if you prefer to review it whole.Still missing to merge: the two
xcl-smokeblocks (main and960162e) — no Windows host here. @yous0serious @Kalmarv you both ran this branch already; would one of you do the smoke pair on960162eagainst plainmain, same package and duration, and paste both blocks?XCL_DRIVER_COMPILE_THREADS=2is the default on NVIDIA; an extra run at=1would also tell us whether 2 is the right default.@woreksami on GitHub · 2026-11-24 01:39 UTC · original
Test report on NVIDIA Ampere 8 GB, with the retail title from #156.
Tested
XCL_NETWORK=0main2b4bb43without this PR, 240 s: the window title stayed at0 running, 2 done, 58739 pipelines queuedfor the whole run (81,217 draws, no crash).main2b4bb43+ this PR at 960162e: the queue drained (0 driver (18 done), nothing queued at ~200 s) and the title went on to the account picker, its setup screens and its loading screen. That run ended at ~353 s at #232's watchdog.maina6f5f7a+ this PR (960162e) + #267 (043d1f7), withXCL_PSO_WAIT_MS=150andXCL_DXC_THREADS=4: 8,100 presents in ~370 s, 30.0 fps for the first 240 s (menus and setup), 4.9–7.8 fps on the loading screen, then 22–26 fps; no crash. The run was ended by an external watcher of mine when free RAM fell under 3 GB, not by XCL.cargo test --release -p xcl --libon the merged tree: 642 passed, 0 failed, 21 ignored.Not tested
scripts/smoke.ps1; AMD; this PR without theXCL_DXC_THREADS=4cap on the long run (31 default threads on this CPU ran the machine out of RAM earlier).AI use
@woreksami on GitHub · 2026-11-24 05:14 UTC · original
@heretic1321 this now conflicts with
main(#516's FPS window title inpresent.rs; #634 / #636's driver-blob cache around the compute PSO compile inreal.rs; #690 inpso_async.rs). In case it saves you time, here is a resolution I tested; nothing is pushed anywhere.What it does
present.rs:main's title with this PR's driver counter:compiling shaders: N dxc, M done[, D driver (C done)]….real.rs, compute PSO: keepsmain's in-memory/on-disk driver blob (compute_blob,driver_cache) and its retry without the blob, and wraps both compiles inDriverCompileGuard. A pipeline with a cached blob enters with size 0, so it is not a big compile, asmainhad it (big && cached.is_none()).guard.finish(hr)takes the finalhrafter the retry.pso_async.rs: git put #690'selse if used::known(key)preload branch into this PR's newenqueue(), wherekeyis not in scope; it is moved back tosubmit_asafterif send { enqueue(p); }. Thenew_pendingtest helper gets #690'skey/usedfields.Tested
main6025201+ this PR (960162e), merged as below:cargo test --release -p xcl --lib: 666 passed, 0 failed, 21 ignored.Not tested
scripts/smoke.ps1, the workspace suite. A cached blob the driver refuses is recompiled inside the same guard entered with size 0 (not as a big compile): rare, but noted.Resolution (
git show --remerge-diffof the merge)AI use: Claude Code with Claude Opus 5.5 resolved the conflicts, ran the tests and wrote this comment.
@mikebuckets171 on GitHub · 2026-11-24 06:22 UTC · original
A macOS/Wine check of this head, from the bench described in #258 (M5 Pro, 48 GB, CrossOver 26 + D3DMetal 3.0, DXC 1.9.2609, Wine, no Windows machine here) — and the reason I came: I had written the same fix you have here.
I was preparing a patch for the window title's "N pipelines queued" figure, because
pso_async::counts()'s third number is everyPENDINGentry whosedoneis false — which includes the lazy stand-inssubmit_lazyinserts withsent = falseand only sends to the workers at their firstresolve. A title that creates thousands of pipelines and never binds most of them therefore showed a large "queued" number next to the compile progress, in the one message that exists to explain a black screen. Then I read this PR:QUEUEDwithmark_enqueued/finish_pending, and the comment "excludes dormant lazy stand-ins" — that is the fix, done properly and with a test, so my patch is withdrawn and nothing of mine is needed here.What I ran on this host, on your head
960162e(your commits on your base4017f8f; note it is not mergeable against currentmainbeaa245at the moment, so these counts describe your head as it is, not a rebased version):cargo build --workspace --target x86_64-pc-windows-gnullvm(LLVM-MinGW 20261117 as the linker) — green, 17 s, one warning the Windows build already prints.cargo test --no-run --release→ 16 test executables. Nothing in your diff needs an MSVC-only construct.hle::d3d12x::pso_async::tests::dormant_lazy_pipelines_are_not_counted_as_queued→ passed (0 failed). So the accounting you added is correct on a host that is not Windows, which is the part I could check.gpu_*_f64family plusgpu_atomic_fcmpswap_x2,gpu_atomic_fmin_fmax_x2,gpu_clamp_and_omod_per_instruction,gpu_bvh64_intersect_ray_across_memory_windows_and_grazing,gpu_memory_windows_above_4_gib: measured today on the same host with the same binary built frommainand from two other heads, it gives 14 failures from the same families, so they belong to the host and not to this PR.If it is useful as this PR stands: I can also run your head against
mainhere and post a 60–90 s pair from a host where this title really draws frames (Ahmet's Mac port, cherry-picked), which is the one regression signal no Windows machine in this thread can produce. Say the word.@heretic1321 on GitHub · 2026-11-24 09:46 UTC · original
Rebased cleanly onto
upstream/main(6bac4b4) at8e32beaf0c6c2d53c77df637a2cf02070f42f594(0 errors, 0 warnings onAR_x86_64_pc_windows_msvc=llvm-ar cargo check --release --workspaceand--tests).Thank you @woreksami and @mikebuckets171 for the runs and detailed notes:
present.rs(#516FPS window title),pso_async.rs(#690preloadinsubmit_as+new_pendingfields), andreal.rs(#634/#636compute_blob+driver_cache). Also fixed the edge case you flagged: iffinish_psorejects a cached blob (hr < 0 && cached.is_some()),guard.discard()drops the size-0 guard without incrementingDRIVER_COMPILING[1]or logging, andDriverCompileGuard::enter(this, dxil.len(), "CS")re-enters with the full DXIL size before the cold retry so big shaders still takeBIG_COMPILES+wait_for_commit().pso_async::counts()): Thanks for checking960162eunder Wine and withdrawing the duplicate patch. Note thatis_background_pso_worker_name(starts_with("xcl-pso-") && != "xcl-pso-urgent") also covers#690's newxcl-pso-pre-Npreload threads (covered by a unit assertion) while leaving title threads andxcl-pso-urgentexempt. If you're able to run a 60–90 s macOS/Wine comparison on8e32beavsmain, that signal would be very welcome too.What is still needed to merge: a Windows
scripts/smoke.ps1pair (mainvs8e32bea) and a full Windowscargo test --workspace -- --test-threads=4run on8e32bea(no Windows GPU host here). If anyone on Windows can run8e32beaagainstmain6bac4b4and paste bothxcl-smokeblocks, we can add them directly under Regression run.@heretic1321 on GitHub · 2026-11-24 12:01 UTC · original
Rebased again onto
upstream/main47efa2e(head96e68a4), because the branch had drifted 34 commits andPendinggained a new field onmain.cargo check --release --workspaceand--tests,x86_64-pc-windows-msvc: 0 errors, 0 warnings on the new headPR descriptionis red only on the twoxcl-smokeblocks, as beforeThe
CIrun on96e68a4is sitting inaction_required(fork workflow approval) — it needs a maintainer to approve it before it can report anything. Windows/GPU testers are still wanted forscripts/smoke.ps1onmainvs96e68a4.@Toons29 on GitHub · 2026-11-25 02:52 UTC · original
Regression run of
96e68a46on the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon4178e888, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 101 % of
main's frames, 100 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; I checked the blocks before posting.@DavidM1911 on GitHub · 2026-11-25 15:19 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.@GodlyBDS on GitHub · 2026-11-26 04:04 UTC · original
Independent confirmation of the status-reporting gap on a newer build. On RTX 3090 Ti / NVIDIA 621.40 / Windows 10,
e877812efrom #2624 displayed0 running, 602 donefor an extended interval. During that same interval the recording thread passed repeatedly throughnvgpucomp64.dlland the native PSO log showed distinct cold compute builds completing every 15–25 seconds. The on-disk native cache continued to grow while the title-bar counters stayed constant.The current title-bar code reads
dxc::compile_counts(). Reading an independent native-driver counter alongside DXC would make an active compile distinguishable from a frozen application in this case. The diagnostic part of this PR covers that distinction. I have only verified the problem on the newer build and have not applied this PR. The measured foreground interval and its relation to world loading are recorded in the #2624 report.AI use: OpenAI Codex (GPT-6) correlated the display and native compilation logs.
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.