perf(gpu): single-pass ask_once, binary-searched ahead ranges, Batch add caches #1278
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1278"
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-28T16:52:08Z.
Summary
Reduces write-watch lock contention and redundant per-flush/per-refresh work on the submitting thread and its worker threads:
ask_ahead/ask_ahead_donework &JOURNALwrite lock whileask_onceis active (crates/victory-gpu/src/watch.rs,crates/victory-gpu/src/host.rs):AtomicBoolmirror (KEPT/ask_once_active()) synchronized withJournal::keptunderjournal_mut().ask_oncestands (the default),Batch::refresh_frontandBatch::flush_allnow skip allocatingrangesand callingask_ahead/ask_ahead_done(~70–90 times/frame). Previouslyask_aheadranpublished()+ collected/sortedpiecesbefore checkingjournal().kept, andask_ahead_donetook the globalJOURNALwrite lock on every flush only to no-op.ask_once_end()andwrote()also fast-return viaask_once_active()without takingjournal_mut()when no submission asking is active.ask_once+ sorted/mergedJournal::aheadwith binary search (crates/victory-gpu/src/watch.rs):ask_once()into onepublished()scan, oneAsking::hold_all(), onejournal_mut()write lock, and deduplicatedask_leftover()calls instead of runningask_ahead()+ask_rest()back-to-back.Journal::aheadsorted and merged viajoin_page_ranges()and replaced linear.iter().any(...)scans inasked(),writes(), andnothing_new()withO(log n)covered_by()(partition_point).ask_rest()under#[cfg(test)]calling the sharedask_leftover()helper sothe_rest_of_the_one_asking_has_a_number_of_its_owncontinues to test it directly.nothing_new()& single-page journal lookup (crates/victory-gpu/src/watch.rs):nothing_new()to checkcopiedslice bounds andranged == 0 && taken.contains(&0)before touchingpublished()or acquiringJOURNAL.read().written_in()/ directBTreeMap::get(&first)fast-path for single-page (last == first + 1) lookups innothing_new(),asked(), andwrites().join_page_ranges_merges_and_covered_by_matches_linearandask_once_single_pass_tracks_active_and_nothing_new.Batch::add(crates/victory-gpu/src/host.rs):last_aheadandlast_indexcaches onBatch(invalidated ingive_back,flush_one,title_written,refresh_front,refresh_ahead, andflush) to avoid repeated hash lookups across consecutiveStep::Refreshentries for the sameShadowcopy.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:main(9ce3cf9)pr/watch-and-batch-perf(c834762)15.6517.7516.0617.46p90)21.3(19.2)24.4(22.7)prep/copy back)63.95 ms(46.95/18.4)56.35 ms(41.75/15.45)prep -11.1%)ASYNC_SUBMITworked61.1 ms54.45 mspresent-wait19.7 ms14.8 msWARN/ERRORcount0/00/0Verification
cargo clippy -p victory-gpu --all-targets --lockedand--all-features --locked: 0 warnings/errors inwatch.rsandhost.rs.cargo test -p victory-gpu --lib --locked -- --test-threads=1 --quiet: 456 passed, 0 failed, 36 ignored.cargo build --release --locked -p victory: exit0.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by qlfu on 2026-11-28T20:53:53Z.
Closing as superseded by \
3055afd\ (per-range \Askings\ in \watch.rs, which already improved \watch\ below this PR on current \main).Pull request closed