D3D12.X: hash sparse uploads from a cached copy, not the staging ring #3164
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3164"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-28T14:43:52Z.
On
mainsince #2959, a retail title's menus run at about 12 presents per 2 s for roughly the first minute on an RTX 5070 Ti, wheremainf9a0cb80(27 Nov) ran at 60 from about 8 s on. The "looks before submits" line shows why: the submitting thread spends nearly all its time in sparse uploads with the upload gate held, about 2 s of every 2 s for ~28 MB.Since
9d08eceb("publish sparse upload hashes after queue receipt") every dirty upload hashes its bytes by reading them back from the mapped UPLOAD-heap staging ring (PreparedDirtyBatch::append_hasheson the staging pointer). That memory is write-combined, so reading it is uncached and slow. Before9d08ecebthe hashes came from title memory. I found no open PR or issue for this (searched "upload gate", "looks before submits", "write-combined", "sparse upload hash").What is in it
sparse.rs:upload_dirty_with_timeoutcopies each chunk of title memory once into a reusable buffer onState(upload_scratch), hashes that buffer and copies it into the staging ring. The hashed bytes are still exactly the uploaded bytes, which is what9d08ecebguarantees, and the staging ring is only written. +14/-5.Tested
scripts/smoke.ps1on the Newer Retail Game, release,XCL_PREPARE=0, same DXIL cache,main309c3ec5against this head: 322 against 1685 frames in 60 s, and 6723 against 8885 frames in 300 s (blocks below). With the change the same log line reads180 looks did 178 ms active work (8.9 % of the time)andupload gate submit wait/hold 0/7 ms(from a run of this change one429936c).maine429936c, alternating, two runs each of 60 s:main309 and 315 frames, the change 1677 and 1679.cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4, one run on headc9c57dba: 2138 passed, 4 failed, 48 ignored (25SKIPPEDlines). Failures: 4, the same 4 that fail onmain309c3ec5here (fuzz_validate_and_gpu_0,fuzz_validate_and_gpu_1,fuzz_validate_and_gpu_2,fuzz_validate_and_gpu_3).main309c3ec5on this machine: 2138 passed, 4 failed, 48 ignored.cargo test -p xcl --lib d3d12x::sparse -- --test-threads=4: 83 passed, 0 failed, 1 ignored.Regression run
300 s each, release builds in clean trees,
mainfirst. I use 300 s and not 60 s here because in 60 s this change takes the title about five times further thanmain, so the 60 s pair compares two different points of the title: 322 against 1685 frames, and a peak commit of 11257 against 16655 MB, which is over the 125 % line ofpr_check.py. After 300 s both have reached the same menus and commit the same.main(309c3ec5), 300 s:This PR (
c9c57dba), 300 s:Not tested
AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-29T11:05:51Z.
Closing:
mainno longer has the readback this PR removed. Since the merge ofnvidia-dev(f0e8fdd5),submit_uploadinsparse.rshashes each chunk from the title's memory and only then copies into the staging ring withrun_copies, so the write-combined buffer is written and never read. I checked this by readingmainatd8bd9a38; I have not measured frames on it.Pull request closed