perf(host): overlap send upload copies with sync/check D3D12 recording in card_before #1403
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1403"
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 trustno1-coder/VIctory-NVIDIA. Originally posted by qlfu on 2026-11-28T19:10:28Z.
Summary
Overlaps CPU upload copies/word scatters with D3D12 command list recording inside
Host::card_before(crates/victory-gpu/src/host.rs,crates/victory-gpu/src/host/send.rs,crates/victory-gpu/src/shadow.rs):send::takeintosend::prepare+Prepared::run_job(host/send.rs):send::preparecomputes upload buffer offsets and acquires the uploadMemorybuffer upfront without copying bytes yet.< 4 MiBshadow::copy_allcalls (~1.1 MB/submissionfell below the4 MiBthreshold on almost every submission) withchunk_moves(MOVE_CHUNK_BYTES = 256 KiB), splitting large runs and grouping small runs into parallel copy jobs alongside the 4,096-run word-scatter jobs.shadow::copy_all.each_underparallel wave inHost::card_before(host.rs):CardRangeplans and pops bothsyncandcheckcommand lists before launching onecrate::land::each_underwave that executesrecord_sync(index 0),record_check(index 1), and allsend::Preparedscatter/memcpy jobs concurrently.record_synconly referencesmemory.bufferCOM handles and precomputed offsets (nevermemory.data), andself.queue.ExecuteCommandListsruns strictly on the submitting thread aftereach_underjoins (guaranteeing full memory visibility of all upload writes before GPU submission, while still holdingQUEUE_ORDER).upcheck::on()diagnostics path sequentially soupcheck::recordstill runs beforeown.record.card_beforecleanups:decl_ranges.clone()+sort_unstable()whendecl_ranges.len() <= 1.Shadowinrecord_checkto skip redundantGetGPUVirtualAddress()+SetComputeRootShaderResourceView/UAVcalls for consecutive spans of the same shadow, and updatesCARD_PASSES[2]once per list.Correctness & Safety
memory.datatarget disjoint offsets and complete beforeeach_underreturns and beforeExecuteCommandListsexecutes onself.queue.syncandcheckuse distinct free-threaded D3D12 command allocators and command lists at unique job indices (0and1).QUEUE_ORDERremains locked fromcard_dirty(sent_as)throughself.queue.ExecuteCommandLists(&[Some(sync_cmd)]).host::send::tests::chunk_moves_splits_large_and_groups_small.Verification
cargo +1.98.1-x86_64-pc-windows-msvc clippy -p victory-gpu --lib --tests --lockedand--all-features: 0 warnings in modified files.cargo +1.98.1-x86_64-pc-windows-msvc test -p victory-gpu --lib --locked -- --test-threads=1 --quiet: 455 passed, 0 failed, 36 ignored.cargo +1.98.1-x86_64-pc-windows-msvc build --release --locked -p victory: exit0.Clean Idle-PC 90s A/B Benchmark (RTX 4070 Ti 12 GB + Ryzen 7 5700X,
-FrameGen, vsorigin/main)origin/maincard_mem(copies in the card's memory) median9.70 ms(21.3 MB)8.40 ms(23.3 MB)-1.30 ms(-13.4%;-20.7%per MB)card_memmean10.13 ms8.86 ms-1.27 ms(-12.5%)fetch_wait7.10 ms6.30 ms-0.80 ms(-11.3%)land_alltotal24.75 ms22.30 ms-2.45 ms(-9.9%)sub_allmedian50.85 ms49.90 ms-0.95 ms71%/14.05 ms73%/13.40 ms+2 pp/-0.65 ms0 / 00 / 0Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Lancito01 on 2026-11-28T21:05:07Z.
Data point: RTX 3080 / 32 GB, Series S mode, main
9ce3cf9e+ #938 + this PR (cherry-picks cleanly). Prison prologue scenes (~4.1k draws, 70 frames): 66.5 ms/frame median (61-79), preparing 52.3, copies 28.5 ms / 86 MB. Without it: 65.4 ms, copies 28.3 ms. No visual problems, no crash in ~12 min, but no measurable change on this setup. One run each.AI-assisted (Claude).
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by qlfu on 2026-11-28T22:18:54Z.
Rebased onto \main\ (\
923e38c), preserving \Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by meonline42 on 2026-11-29T09:18:03Z.
Measurements from a Zen 3 + Ampere machine, in case they're useful (stacked builds, so most PRs aren't isolated, see below).
Machine: Ryzen 9 5900X (thermally limited: ~3.7 GHz average, Tctl 80-87 °C), RTX 3090 at 350 W, 64 GB DDR4-3200, Windows 11. Series X profile, 1080p rendered to 1440p, DLSS Performance, FSR 3 frame generation 2x.
Base:
mainate1f2eb6, plus a local keyboard-input patch (victory-hle only, nothing in the GPU path).Method: each build was started unattended from the same save, standing still, and measured for 150 s once the world was drawn. The scene isn't identical between runs (traffic and time of day differ), so I also bucketed the 5-second
victory_gpu::hostlines by draws per frame.maine1f2eb6VICTORY_PRESENT_QUEUE=1VICTORY_SPANS_QUICK=1, so its default flip made no difference in this run.preparing: copies of 24-28 ms for 60-70 MB per frame, and the card busy only a few ms. Copy-back dropped from ~13 ms to ~6.5 ms between923e38cande1f2eb6.Posted by Claude Code on behalf of the machine's owner.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Marsietiss on 2026-11-29T13:49:48Z.
An RTX 5080 result to go with the 3080 and 3090 tests above. It isn't a test of this PR alone.
What we tested: our tree had diverged, so we ported the idea by hand (send upload copies overlapping the sync/check recording). We turned it on and off together with a separate port of the idea in https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1400. RTX 5080 16 GB, Ryzen 9 9950X3D, Series S mode, 1080p.
Result: live on/off test at one fixed spot, 3 cycles with 5 samples each:
That's about 6% less time per draw with both on.
Limits: we can't say how much came from each change, and this is our own port, not this PR's code. The draw counts differed a little, so compare the per-draw numbers. We only tested one fairly light scene. Our notes don't include a separate picture check for these two switches.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by qlfu on 2026-11-30T00:12:50Z.
Closing as superseded by upstream
main(41adb551) and follow-up#3395:#2509replaced the< 4 MiBsingle-threaded copy path inhost/send.rswithparallel_copy_work+pack_copy_tasks.VICTORY_SEND_BESIDE=1already overlapssend::takecopies withsync/checkrecording across the submission.host.rsrecord_checkmoved to batchedcard_batch_passdispatches.send::takeoverhead (zero-alloc scoped scatter + WC 512 B burst + BAR parallel threshold) is carried in#3395.Pull request closed