Repository navigation
Conversation
|
Independent verification, merged onto current Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti + Radeon iGPU; Rust stable MSVC, debug.
AI use: test runs by Devin (Cognition, SWE-2); no code changes. |
|
Test report on AMD (RX 6900 XT, RDNA2): no new failures, and the sparse-window GPU test runs (not skipped) and passes here. Tested
Not tested
AI use: Claude Code (Claude Opus 5.5) fetched the branch, ran the suites and wrote this report; the runs are real, on the hardware above. |
There was a problem hiding this comment.
Review of 8fd5921 against its merge base 6efdabc, by reading the code; nothing was built or run here. The change is small and the lock side is clean: wait_all_on is reached with no XCL lock held (real.rs:5101, list_x.rs:2805 after the LISTS guard is dropped), sparse::contains and readback_now take only STATE, and nothing under STATE takes LISTS or SYNC_GRAPH, so I found no lock-order deadlock. The problem is in what readback_now does while it holds STATE, which this PR now runs every 10 ms on the waited cell.
-
CONFIRMED: a poll can overwrite a CPU write to the waited cell with the old VRAM value (
crates/xcl/src/hle/d3d12x/sparse.rs:1293-1303, copy at:1032, hash at:1037).readback_nowfirst scans the page and uploads what the CPU changed (:1293,:1301), then submits the copy back, waits for the sparse queue (:1018) and writes the 8 bytes from the staging buffer into the cell (:1032). Nothing stops a title thread from storing to the cell between the scan and the copy; that takes a GPU round trip. Scenario: aWait64BitValueXfalls back to the CPU because noWrite64was recorded for the address (list_x.rs:1803,None => FallbackCpu), and the producer is a title thread that stores the counter on the CPU. If its store lands inside the window, the copy puts the old value back andsync_sent_rangerecords that as sent, so the write is gone for the CPU and never reaches VRAM. Onmainthe same window exists inres_mapandreadback_after_execute, but only for ranges the title asked to read or the GPU just wrote, once; here it is every 10 ms on the cell a writer is expected to hit. Fix: after the copy back, do not store over a cell whose CPU bytes changed since the scan (compare with the value read before the round trip, or compare-exchange for a 4/8-byte range), or copy into a local and only use it for the comparison. -
CONFIRMED (minor): the cost is not measured, and the regression run does not reach the code. Every readback is a synchronous submit + fence wait on the sparse queue under the global
STATElock, plus allocator and list resets; the first one runs before the 512 spins (list_x.rs:239-244), so a sparse-window wait that another thread would have satisfied within microseconds now pays a GPU round trip. The description says under Not tested that no CPU-fallback wait landed in a sparse window in the 60 s smoke run, so the twoxcl-smokeblocks show only that the fast path is unchanged. Lists that recordWrite32/64into a sparse window are already copied back after execution onmain(list_x.rs:2794,:2817,real.rs:5105), so this PR only adds writes XCL does not record (a shader, a copy). -
CONFIRMED: the tests cover the first readback on a real sparse window, not the polling.
pending_wait_reads_back_gpu_write_in_sparse_window(list_x.rs:4084-4170) does go throughsparse::alloc,contains, a realCopyBufferRegioninto the window buffer and the realreadback_now, and checks that the CPU view is still zero before; that part does what the description says, and two reports on the PR say it ran unskipped (NVIDIA, AMD RDNA2). But the copy has completed before the wait starts (:4150), so only the readback before the spin runs on a GPU. The 10 ms loop and the readback on expiry are covered with a closure only (:4041-4081), and nothing runs a wait while another thread writes the cell (finding 1). The skip reason"no sparse UMA"(:4093) is new; CONTRIBUTING lists the reasons used so far.
Question: wait_for gives up after 5 s and readback_ranges then copies the staging buffer whether or not the copy ran (sparse.rs:811-820, :1018, :1032; that part is main's). With the sparse queue held behind a title queue (the case #433 is about), is it intended that this wait's readbacks block on it under STATE and then use those bytes?
Against CONTRIBUTING: Regression run, Not tested and AI use are there and the description check is green. AI use names the tool but says the exact model is not known; CONTRIBUTING asks for the exact model, so that is the maintainer's call. Related: #433 (open) changes readback_after_execute and removes rb_fence; #795 / #797 (merged) and #1045 (open, diagnostics) touch the same wait path in list_x.rs but not these lines.
Verdict: not ready to merge as it is; the idea is right and the locking is sound, but the poll should not store over a concurrent CPU write (1), and that is not tested.
Review by Claude Code (written by Claude Fable 5.2, checked and edited with Claude Opus 5.5); each point checked by a person before posting.
When a
Wait32/64BitValueXfalls back to CPU polling (PendingWait::wait_until_satisfied) for a counter inside a sparse VRAM window, CPU memory only holds the last uploaded/copied-back value while GPU writes live in sparse VRAM. This reads back[va, va + width)from sparse VRAM (sparse::readback_now) before spinning and at 10 ms intervals during the sleep loop (plus a final readback on timeout). Addresses item #2 measured in#505(and keeps coherent-window / heap addresses lock-free on the fast path viauma::is_sparse). Part of #505.What is in it
crates/xcl/src/hle/d3d12x/sparse.rs:sparse::contains(va): checksgpu::uma::get().is_some_and(|u| u.is_sparse(va))before takingSTATEto verify an active sparse window coversva.crates/xcl/src/hle/d3d12x/list_x.rs:PendingWait::wait_until_satisfied/wait_until_satisfied_with: preserves the zero-overhead fast path when CPU memory already satisfies the wait; for unsatisfied sparse-window addresses, runssparse::readback_now(va, width)before spinning, throttled at 10 ms intervals while polling, and once on timeout expiry.pending_wait_sparse_readback_pulls_gpu_writes_and_skips_coherentverifying coherent waits never call readback and sparse waits pull delayed writes cleanly.pending_wait_reads_back_gpu_write_in_sparse_windowverifying a realCopyBufferRegioninto a sparse window buffer (invisible to CPU-only polling) is read back and satisfiesPendingWait::wait_until_satisfied.Tested
stable-x86_64-pc-windows-msvc), debug (scripts/test.ps1) and release (cargo build --release -p xcl).cargo test --workspace -- --test-threads=4(scripts/test.ps1): 729 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 (no wave64:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware)).cargo test -p xcl --lib pending_wait_ -- --test-threads=4: 3 passed, 0 failed (run 3 consecutive times with 0 flakes). Inpending_wait_reads_back_gpu_write_in_sparse_window, CPU-only polling (wait_until_satisfied_with(..., false, ...)) fails on the real GPU sparse-VRAM write beforewait_until_satisfiedpasses with sparse readback enabled.Regression run
main:
PR:
Not tested
Wait64BitValueXcounter explicitly lands in a sparse window on main (not yet triggered during our 60 s retail smoke run).AI use
#505and the D3D12.X sync/sparse implementation, wrote the fix and tests, and ran the test suite and retail smoke runs.