Repository navigation
D3D12.X: a slow graphics pipeline waits at most 4 s once per build (#232) - #267
heretic1321 wants to merge 1 commit into
Conversation
e31d30f to
b5c9057
Compare
|
Review of b5c9057 against main 9ab7d76. The limit does what the description says in a synthetic frame (numbers below). Five things I would change or settle before it goes in. 1. The 4 s default is not tied to a known threshold.
2.
3. Merged with #214 (f007d4a) the tests do not compile.
4. The limit is one budget per present interval for the whole process, not per draw or per thread.
5. A draw past the limit is lost, not delayed.
Tested Synthetic frame, the same test on both trees (
Not tested
🤖 Claude Fable 5.2 |
|
Tested on an NVIDIA RTX 3080 Ti (Windows 11 10.0.26300, driver 32.0.16.2124, DXC 1.9.2602.17, package 1.0.2.1 verified by hash). Built this branch on top of Result: the run still dies at the early assert before any frame — this PR does not change it here.
Two data points that may matter for the hypothesis:
Happy to run any revision of this PR on the 3080 Ti and return reports/traces. AI-assisted (Claude Code CLI via a model proxy). |
b5c9057 to
043d1f7
Compare
|
All five review points are addressed at
What is still missing to merge: the two @Kalmarv @vladbondarenko97 @yous0serious — would one of you run the smoke pair on |
qinrxx
left a comment
There was a problem hiding this comment.
Review of 043d1f7, on correctness and tests only. The diff was read against main 2997c9a.
What I ran: cargo test -p xcl --lib d3d12x:: -- --test-threads=4
- on the PR head (base 4017f8f): 81 passed, 0 failed, 1 ignored;
- on the PR head merged into
main2997c9a (merges without conflicts): 90 passed, 0 failed, 1 ignored. The three new tests pass. - Not run: the whole workspace suite, any GPU test beyond this filter, the retail title.
1. The limit applies per draw, so a thread that records several draws is still held for about the whole build.
resolve_within gives every draw the full XCL_PSO_WAIT_MS, and each_draw_waits_… asserts exactly that ("every draw gets the whole limit"). Take a 17 s NVIDIA build (#156) and a thread that records 5 draws with that pipeline: the draws wait 4 + 4 + 4 + 4 + 1 s, so the thread is held about 17 s, much the same as with resolve_wait. The limit only shortens the hold when each draw of a still-building pipeline comes from a different recording. Would a budget per pipeline work better? Once one draw has given up on a pipeline, later draws of it would not wait (resolve) until it is built. The test would then assert that the second draw returns at once.
2. The new execute_indirect path is tested only with a failed build, not one that timed out.
execute_indirect_with_a_stand_in_binds_the_titles_root_signature_first uses submit(standin, false, Box::new(|| 0)), so the pipeline is done and has failed, and the 4 s limit is never reached. A test with a build that is still running and a short limit would cover the case the PR is for: the stand-in returned at the deadline, then the root signature, then ExecuteIndirect. graphics_bound past the limit has no test either. (From the code, the bind test would fail on main, whose path doesn't bind the root signature, so it does cover that half. I didn't run it there.)
3. XCL_PSO_WAIT_MS is read once into a OnceLock.
The tests get around this by calling resolve_within directly, which is fine. Parsing the variable (0 = no limit, junk = the default) has no test. That's minor and could stay as it is.
Overlap with a change I'm preparing (for #232, compute pipelines):
- I plan to send lazy compute pipelines to the
xcl-psoworkers when the title creates them, so that the first bind usually finds them built. This PR keeps compute onresolve_wait, and nothing here would change. - The workers have one FIFO queue. With compute builds sent when they are made, a graphics pipeline sent at its first draw can sit behind them, and under this PR's limit its draws would time out and be lost more often. My change will have to handle that (for example graphics ahead in the queue). I'm noting it here so the two PRs are not judged separately on it.
- Both PRs change the module doc of
pso_async.rs(lines 3–8), and mine also changes thelazy()doc. Whichever lands second rebases. Mine changessubmit_as, which this PR doesn't touch.
AI use: Claude Code (Claude Opus 5.5) read the diff, ran the tests above and wrote this review. I checked each point myself before posting.
qinrxx
left a comment
There was a problem hiding this comment.
Review of 043d1f7, on correctness and tests only. The diff was read against main 2997c9a.
What I ran: cargo test -p xcl --lib d3d12x:: -- --test-threads=4
- on the PR head (base 4017f8f): 81 passed, 0 failed, 1 ignored;
- on the PR head merged into
main2997c9a (merges without conflicts): 90 passed, 0 failed, 1 ignored. The three new tests pass. - Not run: the whole workspace suite, any GPU test beyond this filter, the retail title.
1. The limit applies per draw, so a thread that records several draws is still held for about the whole build.
resolve_within gives every draw the full XCL_PSO_WAIT_MS, and each_draw_waits_… asserts exactly that ("every draw gets the whole limit"). Take a 17 s NVIDIA build (#156) and a thread that records 5 draws with that pipeline: the draws wait 4 + 4 + 4 + 4 + 1 s, so the thread is held about 17 s, much the same as with resolve_wait. The limit only shortens the hold when each draw of a still-building pipeline comes from a different recording. Would a budget per pipeline work better? Once one draw has given up on a pipeline, later draws of it would not wait (resolve) until it is built. The test would then assert that the second draw returns at once.
2. The new execute_indirect path is tested only with a failed build, not one that timed out.
execute_indirect_with_a_stand_in_binds_the_titles_root_signature_first uses submit(standin, false, Box::new(|| 0)), so the pipeline is done and has failed, and the 4 s limit is never reached. A test with a build that is still running and a short limit would cover the case the PR is for: the stand-in returned at the deadline, then the root signature, then ExecuteIndirect. graphics_bound past the limit has no test either. (From the code, the bind test would fail on main, whose path doesn't bind the root signature, so it does cover that half. I didn't run it there.)
3. XCL_PSO_WAIT_MS is read once into a OnceLock.
The tests get around this by calling resolve_within directly, which is fine. Parsing the variable (0 = no limit, junk = the default) has no test. That's minor and could stay as it is.
Overlap with a change I'm preparing (for #232, compute pipelines):
- I plan to send lazy compute pipelines to the
xcl-psoworkers when the title creates them, so that the first bind usually finds them built. This PR keeps compute onresolve_wait, and nothing here would change. - The workers have one FIFO queue. With compute builds sent when they are made, a graphics pipeline sent at its first draw can sit behind them, and under this PR's limit its draws would time out and be lost more often. My change will have to handle that (for example graphics ahead in the queue). I'm noting it here so the two PRs are not judged separately on it.
- Both PRs change the module doc of
pso_async.rs(lines 3–8), and mine also changes thelazy()doc. Whichever lands second rebases. Mine changessubmit_as, which this PR doesn't touch.
AI use: Claude Code (Claude Opus 5.5) read the diff, ran the tests above and wrote this review. I checked each point myself before posting.
|
Test report on NVIDIA, together with #214 (the stall it times out needs #214 to drain at all on this card). Tested
Not tested
AI use
|
|
@heretic1321 we have a Windows host with an RTX 5080 and the retail title, and we'll run the smoke pair for
We'll post the blocks here with the stand-in draw counts and long-wait lines from the logs. AI use: Claude Code (Claude Opus 5.5) drafted this comment. |
|
Test report on the retail title and an NVIDIA card – the run listed under What the reporter must verify. Machine: Intel Core i7-7700K (4 cores / 8 threads), 16 GB RAM, NVIDIA GeForce RTX 5080 16 GB (driver 610.47, 32-lane waves), Windows 10 22H2 (19045), rustc 1.100.0. With this PR the title still ends by its null write (#232; at 190 s, 29 s after its last frame) – but not in a draw:
How long those compute builds are – the same build with the title's null write stepped over (a local change, not a fix, so that the compiles finish and the run goes on), cold driver cache for these programs, 4 title threads building at once from ~165 s:
In that 15-minute run: 318 compute pipelines built (24.4 MB of DXIL), 438 DXC compiles (the DXIL cache had none of the world's programs), 39 stand-in draws (this PR at work, with the "not built after 4.0 s" lines), and no frame after about 150 s. For its last nine minutes mostly one title thread built compute pipelines one after another – 125 KB to 222 KB of DXIL each, DXC and then the driver, 4 to 8 a minute – with the other cores and the Not tested: AMD; AI use: Claude Code with Claude Fable 5.2 ran the builds and runs and wrote this report; every number is from a run on the machine named. No game files are attached. |
|
Smoke pair for Setup: NVIDIA GeForce RTX 5080 16 GB, driver 32.0.16.2124; AMD Ryzen 7 9800X3D; 31.6 GB RAM; Windows 11 Pro 26200; rustc 1.100.0; release builds; title 1.0.2.1.
Regression run Against From the PR run's logs:
What it does not cover: neither run got to world loading, where #232 stops.
So this is a regression check of the menus and loading before the world (nothing broke there). It doesn't test the draw waits this PR bounds: none reached the limit, or even 2 s. Not tested: together with #214; world loading; AMD; other cards; a cold DXIL cache. AI use: Runs: OpenCode with GLM (Z.ai) GLM-5.3, which executed the runs on the hardware above and extracted the numbers. Drafts: Claude Code (Claude Opus 5.5), which built XCL (both trees), checked the figures against the logs and |
|
@heretic1321 this now conflicts with What it does
Tested
Not tested
Resolution (
|
Part of xcl-dev#232. Bounds graphics pipeline waits at draws/ExecuteIndirect to XCL_PSO_WAIT_MS (default 4000 ms, 0 = no limit) and runs builds on workers rather than the title thread. Latches each timed-out pipeline as late so later draws while it is still building return the stand-in immediately instead of waiting N * limit, counts skipped draws in report.json (d3d12.standin_draws), composes with xcl-dev#574's pending ExecuteIndirect skip, and adds unit tests for the per-pipeline latch, timed-out ExecuteIndirect, and env parsing. Assisted-by: Antigravity (Claude Opus 5.5) and T3 Code / Antigravity (gemini-pro-orchestrator-neon)
043d1f7 to
ef98154
Compare
|
Rebased onto Thank you @qinrxx, @Chrysana, @imnicho, @woreksami, and @Kalmarv for all the reviews, test runs, and conflict notes! Review points addressed in
Note on overlap with |
|
Closing as superseded by #891 ( Thanks to @qinrxx, @Chrysana, @imnicho, @woreksami, and @Kalmarv for all the reviews and Windows/GPU test runs. |
Part of #232. Rebased cleanly onto
upstream/main(6bac4b4, headef98154), integrating#574and#690and addressing@Kalmarv's and@qinrxx's review findings.Root cause & change
main, graphics pipelines created lazily are sent toxcl-psoworkers atSetPipelineState, andbind::graphics_bound/execute_indirectthen callpso_async::resolve_wait, holding the title's recording thread without limit (and compiling on the title thread itself if no worker has taken the job yet). On NVIDIA GPUs where big translated shaders can take > 10 s, that stalls watched threads long enough to trip the title's watchdog (title+0x2215c35,*(int *)0 = 0, Retail title: null write at +0x2215c35 (#159) still hits on NVIDIA RTX 4070 Ti, with and without XCL_NETWORK=0 #232).crates/xcl/src/hle/d3d12x/pso_async.rs:resolve_for_draw/resolve_withinwithXCL_PSO_WAIT_MS(parse_wait_limit, default4000ms as a safety margin under NVIDIA (RTX 5070): graphics pipelines never finish – nvgpucomp64 stalls on large translated shaders (+ 2 fixes: chad.dll XDsp, XMemMapPhysicalPagesScatter) #156's 23 s one-call watchdog trigger;0= unbounded).Pending::late): once one draw times out waiting for a graphics pipeline still building on a worker,p.lateis set so subsequent draws of that pipeline while it is still building return the stand-in immediately (incrementingSTANDIN_DRAWS) instead of holding a thread forN * limit.p.note_use()is called inresolve_withinso#690tracks used graphics pipelines, andresolve_waitlogs waits>= 2 s.draw_wait_tests(a_graphics_pipeline_waits_at_most_once_up_to_the_limit_and_never_builds_on_the_title_thread,compute_pipelines_and_no_limit_wait_as_before,wait_limit_parses_env_values).crates/xcl/src/hle/d3d12x/bind.rs:execute_indirectandgraphics_boundthroughpso_async::resolve_for_draw(keeping#574'sis_pendingskip inexecute_indirectandrs_gfxroot-signature binding for failed/PC pipelines, and usingpso_async::resolveinsidetrace_frame).execute_indirect_with_a_stand_in_binds_the_titles_root_signature_firstand addsexecute_indirect_skips_when_a_still_building_graphics_pipeline_times_outcovering a timed-out pending graphics stand-in.crates/xcl/src/hle/d3d12x/real.rs:standin_draws: usizetoD3d12Stats(report.json → d3d12.standin_draws).Overlaps
#891(Sr-0w) implements opt-inXCL_PSO_WAIT_MSacross both compute and graphics binds viaPending::late, and#533(XaviFortes) bounds compute waits.@imnicho's RTX 5080 retail run on043d1f7showed compute pipeline binds can also trip#232's watchdog when graphics waits stay under 4 s. Keeping this PR cleanly rebased and review-complete for the graphics-only path (where draws are safe to drop without corrupting compute state) unless maintainers prefer#891/#533.Tested
1.95.0, headef98154onupstream/main6bac4b4:AR_x86_64_pc_windows_msvc=llvm-ar cargo check --release --workspace --target x86_64-pc-windows-msvc— exit 0 (15.16s, 0 errors, 0 warnings).AR_x86_64_pc_windows_msvc=llvm-ar cargo check --tests --workspace --target x86_64-pc-windows-msvc— exit 0 (17.72s, 0 errors, 0 warnings).python3 scripts/pr_check.py --localverified all required sections and asset/model checks (failing only on the missing Windowsxcl-smokeblocks foref98154).b5c9057/043d1f7, NOT coveringef98154):@qinrxxtested043d1f7merged onto2997c9aon RTX 5080 (d3d12x::90/0/1;scripts/smoke.ps1 -Seconds 300: 5116 vs 5099 frames, 14991 vs 15011 MB; menus/pre-world only, 0standin_draws).@Chrysanatested043d1f7on RX 9070 XT (cargo test --workspace: 655/0/40, plus 60 ssmoke.ps1merged onto9ce2070: 1526 vs 1536 frames).@imnichotested043d1f7merged onto508a0c7on RTX 5080 (standin_draws: 0at 190 s watchdog; 4 title threads waiting inresolve_waitfor compute).@woreksamitested043d1f7on RTX 3060 (together with#214, plus conflict resolution onto6025201).@Kalmarvreviewedb5c9057and043d1f7on RTX 5070 Ti and WARP.Regression run
ef98154(no Windows GPU host here; earlier043d1f7smoke blocks from@qinrxxand@Chrysanado not coveref98154).Not tested
cargo test --workspaceexecution, GPU tests, andscripts/smoke.ps1/ retail title runs onef98154.AI use
Antigravity with Claude Opus 5.5: wrote the original change, initial tests, and root-cause notes.T3 Code / Antigravity, Orchestrator (Neon) / gemini-pro-orchestrator-neon: rebased ontoupstream/main(6bac4b4), added thePending::lateper-pipeline latch,execute_indirecttimeout test,parse_wait_limittest,p.note_use()call inresolve_within, and ran Linux-to-x86_64-pc-windows-msvccargo checkandscripts/pr_check.py --local.