Repository navigation
D3D12.X: a bind that waits long on a pipeline's build makes a second copy - #754
abilliontokens wants to merge 3 commits into
Conversation
Test report: #754 under Wine (Linux, NVIDIA): GTA VI regression pairA retail-title run of this PR's head Setup
(The first pair. Not tested
AI use: Claude Code (Claude Opus 5.5) built the commits, ran every run above on the machine above and wrote this report. The blocks and counts are pasted from those runs. The account owner asked for test reports to be posted while they were away and has not reviewed this one. |
|
Review + test run on 1. super::pso_async::submit_second(*ppv as usize, compute, job, lazy, if lazy { key } else { 0 }, second);so with lazy creation on (the default) every pipeline goes to the workers when it is made, and with 2. 3. The first build to finish wins even if it failed. If one copy fails ( Question: why does a second copy of the same build finish sooner than the worker's? The unit test models a worker that is slow for its own reasons (a 3 s sleep). If the worker is slow inside the driver compile itself (#156), the title's thread now runs that same compile, which is what the draw path tried to keep off the title's thread. If the cdb dumps show the worker parked somewhere else (e.g. the DXC memory gate), saying so in the description would help. Tested
Not tested
|
|
In let lazy = super::pso_async::lazy();
super::pso_async::submit_second(*ppv as usize, compute, job, lazy, if lazy { key } else { 0 }, second);On
That matches the table in the description: 50,987 pipelines built in the background, against 121 on Suggested: Checked by reading the code (two independent reads against AI use: found by Claude Code (Claude Opus 5.5) while scouting PRs; I checked the call and both |
|
I ran #754 against the retail title on an NVIDIA laptop GPU to see whether it gets past the What I ran. Your commit cherry-picked onto
Free physical RAM never dropped below 7.8 GB in any of these runs (sampled every 5 s), so on Why I think it doesn't help here. The second copy runs on the title's render thread, and it There's also a lock-scope detail worth a look. In Test suite and setup
Not tested: AMD, other NVIDIA drivers, runs longer than 10 minutes, #754 on its own base AI use: Claude Code with Claude Opus 5.5 ran the builds and runs, read the dumps and drafted this; |
…s own Review of xcl-dev#754 found three faults in building the second copy on the waiting title thread: - the thread was inside the build when the worker finished, so a bind whose worker was computing returned at max(worker, 250 ms + copy) instead of the worker's own time: slower, not faster, in the common case; - the one-big-driver-compile-at-a-time slot and the 3 GB commit gate take only threads named xcl-pso* (real::translated_compute_pso), so a copy on a title thread ran a ~1.5 GB driver compile outside both; - translation recurses deeply and a title's thread may have a 1 MiB stack, while XCL's own build threads get 64 MB. The copy now goes to an xcl-pso-help thread with a 64 MB stack: the gates take it for one of theirs, and the waiting thread goes back to the condvar, so the worker finishing first still wakes it at once. Two more from the same review: XCL_PSO_HELP_MS=0 is documented as off and now is (it used to help without waiting at all), and a copy that fails no longer finalises the pipeline as failed - the worker's build still decides, instead of every later dispatch of it being skipped. Its test is new. Assisted-by: Claude Code (Claude Opus 5.5)
…copy A compute pipeline's first bind waits for its build. When a worker is already building it, the title's thread waited on that one build for as long as it took: on a retail title's world loading (RTX 5060 Ti, main f4ce27c) cdb showed 10 of 11 DXC threads and 10 of 11 pipeline workers parked, one build in flight, and the render thread in resolve_wait's condvar. Frames stopped, and the title's watchdog crashed it at +0x23cf683 at 93-101 s on four runs (xcl-dev#232, xcl-dev#581), with and without xcl-dev#690's preloading. After a grace period (250 ms; XCL_PSO_HELP_MS, 0 = off) the waiting thread builds a second copy itself, and the first of the two to finish is the pipeline (complete: the later one is released). go_background supplies the second copy's build; the descriptor is shared read-only (SharedDesc). A pipeline no run used still waits for its worker as before. Measured, same input and caches, 300 s runs that reach world loading: crash at 152.6 s instead of 93.4 / 100.4 s; 2669 frames instead of 1324 / 1443; background pipelines built 50987 against 121 / 866 on main. It does not reach gameplay: the next wait on the title's thread is the title-texture write-watch refresh (xcl-dev#551) and XMemMapPhysicalPagesScatter (xcl-dev#156). Assisted-by: Claude Code (Claude Opus 5.5)
…s own Review of xcl-dev#754 found three faults in building the second copy on the waiting title thread: - the thread was inside the build when the worker finished, so a bind whose worker was computing returned at max(worker, 250 ms + copy) instead of the worker's own time: slower, not faster, in the common case; - the one-big-driver-compile-at-a-time slot and the 3 GB commit gate take only threads named xcl-pso* (real::translated_compute_pso), so a copy on a title thread ran a ~1.5 GB driver compile outside both; - translation recurses deeply and a title's thread may have a 1 MiB stack, while XCL's own build threads get 64 MB. The copy now goes to an xcl-pso-help thread with a 64 MB stack: the gates take it for one of theirs, and the waiting thread goes back to the condvar, so the worker finishing first still wakes it at once. Two more from the same review: XCL_PSO_HELP_MS=0 is documented as off and now is (it used to help without waiting at all), and a copy that fails no longer finalises the pipeline as failed - the worker's build still decides, instead of every later dispatch of it being skipped. Its test is new. Assisted-by: Claude Code (Claude Opus 5.5)
|
A data point for the case this PR's second copy covers, from thread dumps on a retail title's world loading (not a run of this PR). Release build with full symbols, Who holds the pipeline the title waits for: one of #690's
With On So on this machine both shapes are there: a bind behind a starved build-ahead thread (what a second copy at normal priority gets past) and binds behind builds that are just long (#156, as you say). Whether the build-ahead one was slow because of its priority or because of the pipeline itself these dumps cannot tell. Written with Claude Code (Claude Opus 5.5) from runs on this machine. |
970c79e to
3cca433
Compare
Three faults found in review of xcl-dev#754: - go_background passed `send = lazy` to submit_second, inverting lazy creation: with it on (the default) every pipeline a title made went to the workers at once, and with XCL_LAZY_PSO=0 none did until its first bind. A retail title makes ~51 000 pipelines in its first 30 s and uses few, which is what `lazy` exists to avoid, so the measurements in the description carried that cost rather than the second copy's effect. It is `!lazy` now. - The copy was kept for the life of the pipeline, holding the descriptor its build reads; `complete` drops it once there is a pipeline. - A build that failed could win over a success still being built. The first build that *succeeds* is the pipeline now; a failure no longer takes its place, and the later result is released. The test pins submit_second's own contract: a pipeline with a second copy is built on its first use, not before, and an eager one is built without a use. It does not cover go_background's call (that needs a device). Thanks to bstillbstill and CowboyBingus for the inverted `send`, and to bstillbstill for the other two. Assisted-by: Claude Code (Claude Opus 5.5)
|
Confirmed: at AI use: checked with Claude Code (Claude Opus 5.5); I read the diff. |
|
Closing per the author's note withdrawing / marking this PR do-not-merge. |
Please do not merge this as it stands: the measurement that motivated it does not survive review. Details below — I would rather withdraw the claim than have it taken on trust.
A compute pipeline's first bind waits for its build. When a worker already has it, the title's thread waits for that one build however long it takes. On a retail title's world loading cdb showed the DXC threads and pipeline workers parked, one build in flight, and the render thread in
resolve_wait's condvar. The idea here: when the worker is still not done after a grace period (250 ms;XCL_PSO_HELP_MS, 0 = off), build a second copy on a thread of its own and let the first build that succeeds be the pipeline.Why the original numbers were wrong
go_backgroundpassedsend = lazytosubmit_second, which inverted lazy pipeline creation: with it on (the default) every pipeline the title made went to the workers as soon as it was created. The "93 s → 152 s" and "50,987 background pipelines" in the first version of this description were produced by that, not by the second copy — the costlazy()'s own comment warns about (~51,000 pipelines, ~400 KB each in the driver). Found independently by @bstillbstill and @CowboyBingus; thank you both.With
send = !lazyrestored, one fresh pair onmainbeaa245(same input, same warm caches, the same background load in both, one run each):mainbeaa245614f2ccSo the second copy shows no benefit here, and this pair is slightly worse. That agrees with the two independent runs posted on this PR: @Celegans12 measured 105.9 s on
mainagainst 108.9 s with the PR, and @JoaoPauluu's six 60 s runs under Wine show no separation. One run each and a contended machine, so the difference itself is noise — but there is no longer evidence for the benefit the PR was opened on.What the three commits are now
Pending.second,submit_second,resolve_wait's grace period).xcl-pso-helpthread with a 64 MB stack, so the big-driver-compile slot and the 3 GB commit gate take it (they only takexcl-pso*threads), the waiter stays interruptible, andXCL_PSO_HELP_MS=0really is off.send = !lazy; the copy is dropped once a pipeline exists (it held anArcto the descriptor for the pipeline's life); and the first build that succeeds wins, so a failure no longer displaces a success still being built.Commits 2 and 3 are corrections to commit 1. If the maintainer wants the mechanism dropped, commit 1 goes with it and nothing is lost; if it is kept, it needs a case where a worker is blocked rather than compiling — @Anon64's dumps on this PR show one (a
xcl-pso-pre-*thread atTHREAD_PRIORITY_LOWESTholding a build for over 100 s while the title waits on it), which is the shape this would get past.What the stall actually is. Measured on an RTX 5060 Ti: single compute pipelines take 68 s, 95 s and 204 s in NVIDIA's driver for 0.7–1.0 MB of translated DXIL (
compute PSO with the translated console CS (997968 B DXIL, 94926 ms)). An audit of the title's whole shader pack translated 26,698 of 26,698 programs with 0 errors, so the recompiler is not the cost; of 1,815 compute programs compiled, 654 exceed 256 KB of DXIL, 515 exceed 512 KB and 169 exceed 1 MB, and the title has not yet built one over 1 MB. That is #156, and no scheduling change in this PR addresses it.What is in it
crates/xcl/src/hle/d3d12x/pso_async.rs:Pending.second;resolve_wait's grace period and thexcl-pso-helpthread;completepicks the first successful build, releases the other and drops the copy.crates/xcl/src/hle/d3d12x/real.rs:go_backgroundsupplies the copy's build (!lazy);SharedDescshares the descriptor read-only.a_bind_waiting_on_a_slow_worker_builds_a_second_copy,a_second_copy_that_fails_leaves_the_workers_build_to_decide,a_lazy_pipeline_with_a_second_copy_waits_for_its_first_use. The last pinssubmit_second's contract; it does not covergo_background's call site, which needs a device — that is how the invertedsendgot past me.Tested
cargo test --workspace -- --test-threads=4on614f2cc: 716 passed, 0 failed, 41 ignored. SKIPPED:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64).Regression run
Main
beaa245:This PR
614f2cc:Not tested
AI use
Claude Code (Claude Opus 5.5) wrote the change and the tests, ran the tests and runs above on my machine, and drafted this description. The three faults corrected in commits 2 and 3 were found by reviewers on this PR, not by me.