perf(gpu): dedup GpuWrite/declared in Batch, reuse front_spans, zero-copy Arc card_dirty, 1-pass send::take #1345
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1345"
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-28T17:42:28Z.
Summary
Eliminates redundant
Step::GpuWritework, per-submission hash-table reallocations, and largeVec<(usize, usize)>clones/multi-pass scans in the card-copy submission path:Step::GpuWrite(shadow.writing) inBatchand reuse fordeclared(crates/victory-gpu/src/host.rs):gpu_writes_seen,declared, anddeclared_atonBatch(capacity retained across submissions viaSPARE_BATCH).HostList::run_deferrednow callsshadow.writing(*address, *len)once per unique(shadow, address, len)in a submission (avoiding thousands of redundantpending/flightslock acquisitions) and handsbatch.take_declared()directly toHost::card_before, eliminating the extra 25,000-step walk + freshHashSetallocation indeclared_writes(runs).Batch::flush_onewhenself.refreshes.is_empty()to skip hashingself.indexon empty refresh batches.front_at,front_spans, andfront_givenscratch buffers onBatchviafront_spans_into()instead of allocating a freshByCopy<usize>map and two vectors on everyrefresh_front().joined()and zero-copyArcsharing incard_dirty()(crates/victory-gpu/src/shadow.rs,crates/victory-gpu/src/host/upcheck.rs):joined()to merge overlapping/touching ranges in-place (skippingsort()whenranges.is_sorted()), avoiding a second full-sizeVecallocation across 80,000–120,000 dirty ranges/frame.DirtyRanges = Arc<Vec<(usize, usize)>>betweencard_dirty()andSentRuns::note_joined(), replacing the per-submissionranges.clone()deep copy with anArc::clone.joined_in_place_handles_sorted_and_unsorted_ranges.send::take()and piece fast-skip incard_before()rehash loop (crates/victory-gpu/src/host/send.rs,crates/victory-gpu/src/host.rs):send::take()'s three passes overdirtyranges (long runs, short word counts, and chunk slicing) into a single pass.card_before()'s rehash loop whenjoinsis active, avoiding tens of thousands of repeatedshadow.card_run(a, b)calls for consecutive small runs inside the same 64 KiB piece.Benchmark (GTA VI, 90s steady gameplay, 1440p Series X, DLSS Quality, Ryzen 7 5700X + RTX 4070 Ti 12 GB)
Paired A/B on
main(9ce3cf9) with-FrameGen(idle PC, D3D12 VRAM budget ~10,450 MB):main(9ce3cf9)pr/submit-batch-and-card-dirty-perf(57bf736)for copies in the card's memory(per frame)11.7 – 12.6 ms8.7 – 11.4 mswhich pieces to fetch(reducedCARD_WORKstall)6.00 – 7.05 ms3.06 – 3.86 mscopy-back(back)16.7 ms14.0 ms53.8 ms52.9 ms18.618.9present-wait14.05 ms13.5 msWARN/ERRORcount0/00/0Verification
cargo clippy -p victory-gpu --all-targets --lockedand--all-features --locked: 0 warnings/errors in modified lines (host.rs,host/send.rs,host/upcheck.rs,shadow.rs).cargo test -p victory-gpu --lib --locked -- --test-threads=1 --quiet: 455 passed, 0 failed, 36 ignored.cargo build --release --locked -p victory: exit0.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Aniseto on 2026-11-28T19:38:56Z.
Ran the full victory-gpu library suite at
57bf736on an NVIDIA Blackwell desktop part with an updated driver.System
rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5Results
VICTORY_D3D12_ADAPTER=NVIDIA cargo test -p victory-gpu --lib --locked -- --test-threads=1 --quiet: 455 passed, 0 failed, 36 ignored.What this adds
The count matches the author's run. This covers the deduplicated
Step::GpuWrite, reused front spans and zero-copyArccard-dirty path. The PR has no comments yet, so this is the first datapoint in the thread and the first from an RTX 5070 Ti. It is a correctness run on the new driver, not an FPS measurement.Not tested
A retail title, FPS/latency A/B, a paired smoke run, the whole workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - ran the commands above on this machine and wrote this report; no game data was used.