Repository navigation
D3D12.X: a copy back after a submission does not wait for the title - #1993
Ariorh1337 wants to merge 1 commit into
Conversation
`readback_after_execute` made the sparse queue GPU-wait for the title's queue and then waited on the CPU for the copy, on the thread that was submitting. The title's queues can wait for work that same thread submits next (four compute queues waiting for a Write64 on q1 whose list is recorded but not submitted yet). So the copy waited its 5 s on every such submission, and the uploads queued behind it on the sparse queue waited too (`before_execute` waiting for ring room). In thread dumps of a retail title on an RTX 5090, the submitting thread is in `readback_ranges` -> `wait_for` while another title thread waits for the sparse state's lock in `commit_range`. lucsoft found the same cycle on RDNA3 / Linux (xcl-dev#505). The copies now run on a queue of their own, which GPU-waits for the title's queue, and the submitting thread returns. Readback buffers are sized to the copy (64 KiB and up) and reused. Without a readback queue (it could not be made), the old path runs. The data lands in the title's memory once the copy is done, before the title can see the work it follows is done: - on the next submit, and from a thread that looks every 0.5 ms; - before Map's readback and in the CPU memory waits of Wait64BitValueX (`settle_readbacks`), which wait for the copy once the title's lists it follows are done; - in the title's fence observations: `GetCompletedValue` settles the copies first. `SetEventOnCompletion` hands the fence an event of XCL's own, and a thread-pool wait on it settles them, then sets the title's event. The new test `a_copy_back_does_not_wait_for_the_title_queue` waits 5.0 s on the old path and under 1 s with this change. Without the fence hooks, the e2e test title read 0 for its Write32BitValueBottomOfPipeX after its fence wait. With them, both e2e tests pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
A caution from a local change of the same design: with the copy back asynchronous, the shared What happened in my tree, which had the same idea (copies back on their own queue, landed by a thread):
So it may be worth giving each title queue its own fence here (or checking Setup of the runs above (not this PR): Not tested: this PR itself, current AI use: Claude Code (Claude Fable 5.2 coordinating, Claude Opus 5.5 for the journal and the probe) ran the measurements; I read this PR's diff and drafted the comment. |
|
Full-suite run, since this PR has no test report yet. Tested exact head Tested
Not tested
AI use
|
|
Code review on
Remaining before merge: Addressing the multi-queue |
|
Correction (retracting this report): these four runs are not valid. A test script I had stopped kept running and launched the title in parallel with these runs: each launch ended the other's run, and log copies were overwritten. The fourth row's log actually holds a device removal at 171 s, not "none". I have no clean A/B of #1993 on this machine. I'll post a new one if I rerun it. Sorry for the noise. Test report for #1993 at head Tested
Not tested
AI use: Claude Code (Claude Opus 5.5) built both trees, ran the runs and wrote this report. |
PR #1993 verification on STOR-WINLABPR head
Tested
Set-ExecutionPolicy -Scope Process Bypass -Force
& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test { cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output }One full workspace run exited 101. Libtest reported 965 passed, 26 failed, 45 ignored across 19 test binaries and one doc-test target. The log recorded 26
Failures
SkipsRaw logs in Not testedThis run covered the PR head on STOR-WINLAB. No AI useT3 Code / Codex (gpt-6.2-sol) ran the build and tests and drafted this report. Coordinator #2 (T3 Code / Antigravity, |
|
Verification on RTX 3060 Ti (Windows 11): merge conflict with current |
… commits is looked at (local test) From a review of the local changes: - The fence cells the title reads (`fence_x`) are stored after the copies back a value covers have landed (a value the title waits for promises the memory behind it), read and stored one refresh at a time. - A copy back (and a stored immediate) lands 64-byte chunk by chunk, never over a chunk the CPU wrote since it was last sent: those bytes are newer and go up with the next look. - `settle_readbacks_within` waits for the state's lock up to a bound; GetCompletedValue no longer spins 2 ms per copy back. - Memory the title commits, and the memory of a texture it places, is looked at for a while (`mark_hot`): a write made right after the commit was seen up to 20 ms late. - A copy back that finds no readback buffer still signals its queue's fence; at most 32 finished readback buffers are kept; `pagelog::counts` takes no blocking lock in the exception filter. Loading: - The watched ranges are made of 16 MiB blocks of the textures' sources, not from all textures (tens of thousands of them, each submit while a title loads). - A DirectStorage destination in a sparse window is written without a VirtualQuery (a query there walks the whole committed heap: 3-5 ms a request, with a 2 GB heap). A part the title gave back fails the write (`write_title`). The unit test of xcl-dev#1993 waits for the per-queue fences now. `submit_cost` also counts ranges, re-checks and texture uploads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent native Windows test of #1993 (
Both stopped at world loading. The later run logged no asynchronous-copy timeout. In both runs the queue watchdog eventually released waits for a submitted producer fence whose completion was one value behind. This pair did not reproduce a reduction in queue timeouts or prevent the title error. It does not isolate or disprove the readback cycle addressed in the PR. On the adapted tree, |
|
A parallel-test hang this PR's change brings in, found through #2057, which carries it as A first-parent bisect of #2057 named
In the hung runs, the new test and older On #2057 the same hang shows on all three heads ( AI-assisted (Claude Code). Synthetic tests only. |
readback_after_executemakes the sparse queue GPU-wait for the title's queue, then waits on the CPU for the copy back, on the thread that is submitting. A title's queues can wait for work that thread submits next. In the retail title of #505, four compute queues wait for aWrite64on q1 whose list is recorded but not submitted yet. So every such submission waited 5 s for its copy back, and the uploads queued behind it on the sparse queue waited as well (before_executewaiting for ring room). lucsoft hit the same cycle on RDNA3 / Linux and found it was the whole stop there (#505 comment). This PR moves the copies back to a queue of their own and makes them asynchronous.Part of #505.
What is in it (one commit,
crates/xcl/src/hle/d3d12x/)sparse.rs:rbq), which GPU-waits for the title's queue. Readback buffers are sized to the copy (64 KiB and up) and reused. If the queue cannot be made, the old path runs.drain_readbacks): on the next submit, and from a thread that looks every 0.5 ms.settle_readbacksruns beforeMap's readback and in the CPU memory waits. It also waits for a copy whose title work is already done.real.rs: the title's fence observations settle copies back first.GetCompletedValuesettles them before it returns.SetEventOnCompletionwith an event gives the fence an event of XCL's own. A thread-pool wait on that event settles them, then sets the title's event.list_x.rs: the CPU wait ofWait64BitValueX/Wait32BitValueXsettles copies back between its polls.sparse::tests::a_copy_back_does_not_wait_for_the_title_queue(GPU, or WARP). A title queue is blocked on a fence nobody has signalled and then copies into a tile. The copy back must return at once and land once the queue goes on. On the old path it waits 5.0 s (checked by switching the readback queue off in the test).gpu_sparse_vram_descriptors_buffers_and_xmemsettles before its CPU reads, as its fence wait is not one of the title's.Tested
cargo test --workspace -- --test-threads=4(debug,--no-fail-fast):4df0a2d): 987 passed, 4 failed, 45 ignored;main(8e87fc7): 986 passed, 4 failed, 45 ignored.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3,CreateComputePipelineState: … (0x8007000E)at seed 70.pso_measurement_compiles_an_exact_synthetic_record(no Developer Mode) andheap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).Write32BitValueBottomOfPipeX: 0x0after its fence wait. With them,cargo test -p xcl --test e2e: 3 passed (also 3 passed onmain).mainb9b6ea6plus open PRs, D3D12.X: the committed window gets a copy in video memory #1329, and a local switch that puts the title's two large GPU heaps in the sparse windows, so most of the title's GPU memory goes through readbacks. Before this change, the submitting thread sat inreadback_ranges→wait_forand the title stopped after the world load. With it, the title reached the in-game HUD and ran 465 s after the first#101, with 0 draws and 0 dispatches skipped. One run.Regression run
scripts/smoke.ps1 -Game <retail title> -Seconds 60(start screen, no input),XCL_HEAP_WINDOWS=1for both, same machine. An earliermainrun peaked at 16 883 MB (1183 frames); in that run the title stopped loading in the background before the 60 s were up. The run below has the same commit growth after 40 s as this PR's.Not tested
main+ this PR alone. With the title's heaps in the coherent window (the default), its lists write little into the sparse windows. The smoke run above does not reach the world.ID3D12Fence1, or a wait throughWaitForMultipleObjectson an event it shares with another fence. The 0.5 ms thread lands the data there.AI use
🤖 Generated with Claude Code