Repository navigation
Conversation
|
AMD run, since Not tested lists AMD: Tested
Not tested
AI use
|
|
Test report on AMD RDNA3: RX 7800 XT (16 GB), driver 32.0.32015.7029, Ryzen 7 9800X3D, Windows 11 Pro 10.0.26300, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug build. No retail data was used. Tested: the PR head
Not tested: a regression run on a title, a release build, and the head merged onto current AI use: Claude Code ran the commands and drafted this comment; the runs are real runs on the hardware above. |
|
From a static review (no builds or runs) of
Keep the submitted resources alive until GPU completion is confirmed, and require that confirmation before copying back. xcl/crates/xcl/src/hle/d3d12x/sparse.rs Lines 1001 to 1010 in 7709697 xcl/crates/xcl/src/hle/d3d12x/sparse.rs Lines 1297 to 1313 in 7709697 Review by Claude Code (Claude Opus 5.5) with a gpt-6.2-sol audit subagent; I checked each point against the code. |
After a title's ExecuteCommandLists whose lists write sparse windows on the GPU, readback_after_execute made XCL's queue wait for the title's queue (through one rb_fence shared by all title queues) and then waited on the CPU for the copy, inside the title's call and under the sparse lock. A queue may GPU-wait for a fence that a later submit signals (async compute): the CPU wait then never ends, and the later submit never comes. Values of the shared fence signalled from several queues could also complete out of order. The copy back is now recorded on the title's queue after its lists (a list of the queue's type, into a readback buffer of its own), followed by a signal of a fence of that queue's own. It is still waited for in the call, so the bytes are in the CPU's view when the title's own fence after the work completes - unless a wait the queue was given has not completed (Wait is noted, from the PC method and from the console's queue slots; XCL's own waits are not), or an earlier copy back of that queue is not landed yet. Then a worker thread lands it, in submission order, once the GPU is there. The fence exists before anything is submitted, and a copy back is landed only once its fence has reached the value (looking again every millisecond when there is no event to wait on), so its buffer and list live until the GPU is done with them; if the Signal after the copy fails, nothing can tell when it is done and they are never released (review on xcl-dev#433). Tests (own processes, the device adopted as the title's): - sparse_readback_waits: queue A waits for F, runs a list writing 8 bytes of a sparse window and is read back; queue B then submits and signals F. Main hangs (A not done after 5 s); here A finishes and the bytes land. - sparse_readback_lands: 20 times a list writes 8 bytes, the title waits for its fence and reads them at once. Passes on main and here; fails in round 0 when every copy back goes to the worker. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
7709697 to
7184866
Compare
|
Thanks, both points were right. They're fixed in
No test covers these paths: the failures of 🤖 Claude Opus 5.5 |
|
Regression run on a retail title, as asked under Regression run. Tested
Regression run
this PR's head:
Not tested
AI use
|
After a title's ExecuteCommandLists whose lists write sparse windows on the GPU, readback_after_execute made XCL's queue wait for the title's queue (through one rb_fence shared by all title queues) and then waited on the CPU for the copy, inside the title's call and under the sparse lock. A queue may GPU-wait for a fence that a later submit signals (async compute): the CPU wait then never ends, and the later submit never comes. Values of the shared fence signalled from several queues could also complete out of order. The copy back is now recorded on the title's queue after its lists (a list of the queue's type, into a readback buffer of its own), followed by a signal of a fence of that queue's own. It is still waited for in the call, so the bytes are in the CPU's view when the title's own fence after the work completes - unless a wait the queue was given has not completed (Wait is noted, from the PC method and from the console's queue slots; XCL's own waits are not), or an earlier copy back of that queue is not landed yet. Then a worker thread lands it, in submission order, once the GPU is there. The fence exists before anything is submitted, and a copy back is landed only once its fence has reached the value (looking again every millisecond when there is no event to wait on), so its buffer and list live until the GPU is done with them; if the Signal after the copy fails, nothing can tell when it is done and they are never released (review on xcl-dev#433). Tests (own processes, the device adopted as the title's): - sparse_readback_waits: queue A waits for F, runs a list writing 8 bytes of a sparse window and is read back; queue B then submits and signals F. Main hangs (A not done after 5 s); here A finishes and the bytes land. - sparse_readback_lands: 20 times a list writes 8 bytes, the title waits for its fence and reads them at once. Passes on main and here; fails in round 0 when every copy back goes to the worker. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
7184866 to
19004e1
Compare
|
A small leak in
The usual cross-queue sync, Nothing crashes, but there's no upper bound. Possible fix: run the same AI-assisted (Claude Code), read-only review. |
|
Independent Windows validation on an RTX 5060 Ti (driver 616.92), Windows 11 build 26200, and Rust 1.100.0 MSVC. I ran both synthetic fixtures three times per revision, comparing PR head 19004e1 with base cb868b2. A separate probe verified the adapter selected by XCL’s device-creation path.
|
|
Test report: Build: Result: compared with #533 alone (details and table in my comment on #533), the title went from an abort at 107.8 s to 118.8 s. The stall before the abort is the same kind, though: 5 ×
So the Map readback ( I tried that locally: a change that lets Tested
Not tested: this PR without #533; AMD / Intel; Linux. Test runs, analysis and this comment by Claude Code (Claude Opus 5.5); I checked the logs it is based on. |
|
Written by an AI agent (Claude Code, Claude Opus 5.5) on this account, from runs on this machine. A Linux / RDNA3 data point where this PR removes a stall the title hits there. One run per configuration, so treat the times as indicative. Setup: RX 7900 XTX, Mesa 26.3.1 RADV, CachyOS (kernel 7.3.5), Wine 11.22 (kernel write watches), vkd3d-proton v3.1 with #257's patch and dxil-spirv What stalls without this PR (measured with local timing logs, not in any PR): under Wine #871 places the title's overflow graphics heaps in the sparse windows, so the small GPU-written counters there go through With this PR (cherry-picked; the conflict with #867's fence wrapping resolved by hand:
The abort still comes ~40 s after the first ListX #101 call, as described in #505, and no title thread was inside XCL at that point. With #891 and Tests (release, Wine, headless gamescope): Not run: Windows, NVIDIA, the full suite on this tree, more than one run per configuration. |
|
Test report: this PR on an NVIDIA RTX 3060 (Windows), retail title of #505. The sparse-queue stall is gone in this run; the run then ends in a device removal instead. Build: Tested
The two runs differ in the console profile as well (I had switched to Series S for the run without this PR and back to Series X for this one), so the table is not a clean A/B. On
Not tested: more than one run of this tree; the same profile with and without this PR; whether this PR plays any part in the device removal (the Series X run on AI use: Claude Code (Claude Opus 5.5) merged and built the tree, ran the tests, read the logs and wrote this report; the title runs were made by hand on my PC. |
|
I checked deferred readback order at 19004e1 on Windows 11, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC. The offline workspace build and both stock sparse readback tests passed. The scratch fixture queued two different writes to the same sparse address on one direct queue, each behind a separate fence value. Both readback submissions returned before either value was signaled. After the compute queue signaled the first value, the CPU view showed the first write while the second was still held. After the second signal it showed the second write. The fixture sampled under the sparse-state lock and passed in all three processes, with no device removal. Synthetic coverage only. AI-assisted. Codex (GPT-6) extended the fixture and ran the tests. |
|
An independent repro of this on Linux, and an alternative fix. Setup: RTX 5080 (NVIDIA 620.73.04), proton-cachyos-slr Wine, vkd3d-proton master What happened: at ~150 s the whole process froze for ~28 s, until the title's watchdog ( Alternative fix tried locally: After: much rarer, not gone. In 12 runs since, 10 logged no Not tested: Windows, AMD, this PR's own approach. AI use: Claude Code (Claude Opus 5.5) diagnosed this, wrote the local change and this text; the user approved posting it. |
|
A retail data point for this PR and #262: retail title 1.0.2.1 on NVIDIA, with thread dumps of the stall. The PR's tests do what they say on today's Setup
Tests (
On the title (4 runs with this PR, 2 without, same inputs)
When it happens, the sequence matches the issue:
What the stuck operation was, from the timeout log in the 243 s run:
So a plain copy list on XCL's queue, which has no In the 288 s run the title slows to 8 → 1 presents per 20 s instead. In every run about 180 compute pipelines are built after world entry, single builds 43–148 s in the driver, and ~30 Not tested: AMD; more runs to say how often the lock-up happens; the synthetic case of a copy on one queue reading a reserved buffer while another queue using it is held. AI use: Claude Code, Claude Opus 5.5. It rebased the PR, ran the tests and the title runs, read the thread dumps and wrote this report. The runs were on the hardware above. |
19004e1 to
83bb744
Compare
After a title's ExecuteCommandLists whose lists write sparse windows on the GPU, readback_after_execute made XCL's queue wait for the title's queue (through one rb_fence shared by all title queues) and then waited on the CPU for the copy, inside the title's call and under the sparse lock. A queue may GPU-wait for a fence that a later submit signals (async compute): the CPU wait then never ends, and the later submit never comes. Values of the shared fence signalled from several queues could also complete out of order. The copy back is now recorded on the title's queue after its lists (a list of the queue's type, into a readback buffer of its own), followed by a signal of a fence of that queue's own. It is still waited for in the call, so the bytes are in the CPU's view when the title's own fence after the work completes - unless a wait the queue was given has not completed (Wait is noted, from the PC method and from the console's queue slots; XCL's own waits are not), or an earlier copy back of that queue is not landed yet. Then a worker thread lands it, in submission order, once the GPU is there. The fence exists before anything is submitted, and a copy back is landed only once its fence has reached the value (looking again every millisecond when there is no event to wait on), so its buffer and list live until the GPU is done with them; if the Signal after the copy fails, nothing can tell when it is done and they are never released (review on xcl-dev#433). A noted wait is kept only while it has not completed: a queue's completed waits go when it is given the next one, of the waits for one fence only the highest value is kept, and a queue the title releases is forgotten. A queue that waits every frame and never reads back otherwise kept one entry, and a reference on the title's fence, per frame (review on xcl-dev#433). Tests (own processes, the device adopted as the title's): - sparse_readback_waits: queue A waits for F, runs a list writing 8 bytes of a sparse window and is read back; queue B then submits and signals F. Main hangs (A not done after 5 s); here A finishes and the bytes land. - sparse_readback_lands: 20 times a list writes 8 bytes, the title waits for its fence and reads them at once. Passes on main and here; fails in round 0 when every copy back goes to the worker. - noted_queue_waits_stay_one_per_fence (unit): 1,000 waits on one fence keep one entry; fails without the bound. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Rebased onto @upipibi (WAITS leak): fixed as you read it. @requiemsnkrp, @bstillbstill: the merge conflicts you described (the doc comment above @bstillbstill, @maephisto666: the lock-up that remains goes through @Ali-AbdulHadii (alternative fix): we keep this approach for two reasons. Titles read GPU-written sparse memory on the CPU as soon as their own fence after the work completes; with every copy back on a worker the bytes land later, and @freemanovec, @requiemsnkrp (faults / removal on Linux and with #891): what we checked: the readback buffer, allocator and list live until their fence completes, and we found no path that frees them earlier. One ordering change: the copy now runs on the title's queue, so a later tile unmap on XCL's queue is not ordered after it. On a held queue the copy can read a tile already unmapped, which D3D12 defines as zero (tiled resources tier 2); the title's own lists on that queue read the windows with the same ordering. What we can't tell: we have no RADV machine and didn't check what RADV does on such a read, and the reports have no faulting address. The amdgpu fault lines (VA, client) next to the XCL log, or a run of this head and of AI use: Claude Code (Claude Opus 5.5) |
|
Checked AI-assisted (Claude Code). |
After a title's ExecuteCommandLists whose lists write sparse windows on the GPU, readback_after_execute made XCL's queue wait for the title's queue (through one rb_fence shared by all title queues) and then waited on the CPU for the copy, inside the title's call and under the sparse lock. A queue may GPU-wait for a fence that a later submit signals (async compute): the CPU wait then never ends, and the later submit never comes. Values of the shared fence signalled from several queues could also complete out of order. The copy back is now recorded on the title's queue after its lists (a list of the queue's type, into a readback buffer of its own), followed by a signal of a fence of that queue's own. It is still waited for in the call, so the bytes are in the CPU's view when the title's own fence after the work completes - unless a wait the queue was given has not completed (Wait is noted, from the PC method and from the console's queue slots; XCL's own waits are not), or an earlier copy back of that queue is not landed yet. Then a worker thread lands it, in submission order, once the GPU is there. The fence exists before anything is submitted, and a copy back is landed only once its fence has reached the value (looking again every millisecond when there is no event to wait on), so its buffer and list live until the GPU is done with them; if the Signal after the copy fails, nothing can tell when it is done and they are never released (review on xcl-dev#433). A noted wait is kept only while it has not completed: a queue's completed waits go when it is given the next one, of the waits for one fence only the highest value is kept, and a queue the title releases is forgotten. A queue that waits every frame and never reads back otherwise kept one entry, and a reference on the title's fence, per frame (review on xcl-dev#433). Tests (own processes, the device adopted as the title's): - sparse_readback_waits: queue A waits for F, runs a list writing 8 bytes of a sparse window and is read back; queue B then submits and signals F. Main hangs (A not done after 5 s); here A finishes and the bytes land. - sparse_readback_lands: 20 times a list writes 8 bytes, the title waits for its fence and reads them at once. Passes on main and here; fails in round 0 when every copy back goes to the worker. - noted_queue_waits_stay_one_per_fence (unit): 1,000 waits on one fence keep one entry; fails without the bound. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
83bb744 to
c20dd22
Compare
|
Retail-title A/B on NVIDIA for this PR. GTA VI 1.0.2.1, RTX 3080 Ti 12 GB (driver 610.88), i7-12700KF, Windows 11, release build, main main
( So on this title the PR removes the sparse-queue stall. Correction (edited): I first read what is left as a wait cycle among the title's queues; the thread dumps say otherwise. Symbolised with the release PDB, all three dumps (155.3, 170.1, 176.6 s) show:
The 5 s GPU-wait releases (141.9–150.1 s) had stopped by then. Local VRAM use was 14.1–14.4 GB on this 12 GB card from ~106 s (inferred cause of the slow driver call). That is #505's deadlock, which #1697 addresses; a run of main + this PR + #1697 is queued. Not tested: AMD; this PR together with #1385 (they conflict in AI use: Claude Code (Claude Opus 5.5) ran the box, read the log and wrote this report. |
After a submission with GPU writes into sparse windows, the sparse queue waited for the title queue and the submitting thread waited for the copy, up to 5 s per flush with the sparse lock held. On a queue still held by a gate that is a stall until the gate's release: the thread cannot submit the producer, and every title queue waits for the sparse queue in before_execute. The rule from xcl-dev#708 only covered sparse lists at or after the gated one in the same call. Two cases were left: - KickoffX of a split list: a gate armed for an earlier segment was followed by the active segment's readback. The active segment's sparse flag now reaches the earlier segments' waits (execute_with_waits_before), which keep the bounded CPU wait. - A later submission to a queue whose gate is still closed. wait_gate now counts the gates the CPU has not opened per queue (closed_on). For such a queue the copy back is recorded on the title queue itself, followed by a signal of a fence of its own, and a worker lands it in the CPU view once the GPU is there, in order (from xcl-dev#433, which does this for any queue with an unfinished wait). Later copies of that queue take the same way until the earlier ones landed. Other queues keep the synchronous readback. A CPU read right after the title's own fence can see the old bytes of such a copy until the worker lands it; before, the call stalled there instead. Found in review (integ-review.md W2). Not run. Assisted-by: omp (Claude Opus 5.5)
|
Test report from macOS (CrossOver + D3DMetal): #433 at Merge notes (local, not pushed):
On this host the tests need two other changes to run at all: #1789 (D3DMetal releases on a thread of its own, where the first read of Tested (MacBook Pro M5 Pro, macOS 27.2.1, CrossOver 26.3 with D3DMetal 3.0, Rosetta 2, Rust 1.100.0
Not tested: Windows, the whole suite, a title, @CharlyRien's per-queue variant. AI use: Claude Code, Claude Opus 5.5 merged the trees, ran the tests above on this machine and wrote this report. |
|
Closing in favour of @Ariorh1337's #1993. It fixes the same stall more fully: copies back run asynchronously on queues of their own, so a submit no longer waits on the CPU while holding the sparse lock. @lucsoft confirmed on #505 that with #1993 the submit thread no longer waits on the sparse Thanks to everyone who tested this PR. AI use: Claude Code (Claude Opus 5.5) wrote this note. |
|
Verification on RTX 3060 Ti (Windows 11): merge conflict with current |
After a title's
ExecuteCommandListswhose lists write sparse windows on the GPU (Write32/64BitValue…X,FillMemoryWith32BitValueX,CopyMemoryToMemoryX),sparse::readback_after_executecopies those bytes back to the CPU's view. It waited on the CPU for the title's queue to get there, inside the title's call and while holding the sparse lock. A queue may GPU-wait for a fence that a later submit signals; async compute does this. The wait then never ends, the later submit never comes, and every other submit stops at the sparse lock. Part of #262, which covers the other half of the sparse windows' cross-queue problem: the CPU-write uploads.What is in it
crates/xcl/src/hle/d3d12x/sparse.rs:rb_fencethat all title queues signalled is gone. Its values could complete out of order across queues.Signalfails they are never released (from review).crates/xcl/src/hle/d3d12x/real.rs: the queue'sWaitis noted, both from the PC method (a new override) and from the console's queue slots. XCL's own waits, made inside its own uploads, are not noted. A queue the title releases has its noted waits forgotten (sparse::forget_queuefromq_release).cpu_writes.rs: it does bottom-of-pipe writes outside unified memory always on a worker, after the GPU. So there a CPU read right after the title's fence wait can always see the old value, and the worker writes anyway after 10 s. This PR keeps that window to the case where main hangs.crates/xcl/tests/, each in its own process, with the device adopted as the title's:sparse_readback_waits.rs: queue A waits for F, runs a list writing 8 bytes of a sparse window, and is read back; queue B then submits and signals F. A must finish within 5 s, and the bytes must land.sparse_readback_lands.rs: 20 times, a list writes 8 bytes, the title waits for its own fence and reads them at once.noted_queue_waits_stay_one_per_fenceinsparse.rs: 1,000 waits on one fence keep one entry, a second fence makes two, completed waits go, a released queue has none. It fails without the bound (1,000 entries).Tested
c20dd22on mainb7aa9f3: rebased over D3D12.X: the late-release drain gets the sparse queue without the sparse state's lock #968, with two conflicts insparse.rs(D3D12.X: the late-release drain gets the sparse queue without the sparse state's lock #968'squeue()doc and body kept, this PR's doc stays onreadback_after_execute; D3D12.X: the late-release drain gets the sparse queue without the sparse state's lock #968's testthe_queue_is_answered_while_the_state_is_lockedkept beside ours). D3D12.X: the late-release drain gets the sparse queue without the sparse state's lock #968 only changes how the late-release drain gets XCL's sparse queue; this PR doesn't callqueue(), drops its readback jobs outside the sparse lock, and puts its copy lists on title queues the drain already waits on, so the merge adds no lock order. Before that,83bb744on930e8b4was19004e1rebased (one conflict, in the doc comment abovereadback_after_execute; two test constructors main added moved torb_fences), plus the bound on noted waits.19004e1was7184866(the review fix to7709697, on9ab7d76) rebased onto9ce2070. The runs by @nullmarsh and @TheHoracio below were on7709697, and @srcamarda's on7184866.9ab7d7619004e1)cargo test -p xcl --test sparse_readback_waitscargo test -p xcl --test sparse_readback_landshle::d3d12x::sparse::tests, inside the whole suite onc20dd22: 15 passed, 1 ignored.cargo test --workspace -- --test-threads=4:c20dd22: 773 passed, 0 failed, 41 ignored.83bb744: 754 passed, 0 failed, 41 ignored.19004e1: 686 passed, 0 failed, 41 ignored.7709697: 653 passed, 0 failed, 40 ignored. A first run of it hung in the deadlock of D3D12.X: replacing the sparse state deadlocks when the old state still holds placed buffers #344.gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware(no wave64).7709697merged ontomaina6f5f7a.scripts/test.ps1: 0 failed, no SKIPPED GPU tests; both new tests pass. Withreal.rsandsparse.rsback onmain,a_readback_behind_a_wait_for_a_later_signal_does_not_hangfails after 5.4 s.scripts/smoke.ps1 -Seconds 90, each binary run twice.main508a0c7: 2343 / 2361 frames, peak commit 15764 / 15674 MB. This PR at7184866: 2356 / 2383 frames, peak commit 16491 / 16373 MB. No crash or device removal in any run. He puts the higher peak commit down to that head's base,9ab7d76, 55 commits behindmain;c20dd22is onb7aa9f3.7709697on9ab7d76.cargo test --workspace --no-fail-fast -- --test-threads=4: 653 passed, 0 failed, 40 ignored, no SKIPPED GPU tests; both new tests pass.Regression run
Our own runs, one after the other on the machine under Tested (RTX 5070 Ti, AMD Ryzen 9 9950X), release builds, no uncommitted changes:
mainatb7aa9f3(this PR's base), then this PR's head. 98 % ofmain's frames, 101 % of its peak commit.main:
PR:
Not tested
cpu_writeshas the same property.Size: 499 changed lines (+457 / -42), 245 of them tests. Over the ~400 target because of the tests: the fix and its review changes are about 250 lines in two files, and splitting the tests from the fix would leave the fix without the test that shows the hang.
AI use
🤖 Generated with Claude Code