perf(gpu): restore MANY_CHUNK = 8 in Batch::flush_all for 6-core work-stealing #1556
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!1556
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1556"
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?
@steven-seagull27 on GitHub · 2026-11-28 21:40 UTC · original
steven-seagull27:perf/batch-noop-refreshes→main· +7 −5 · 1 files · 1 commits · openReduces submitting-thread and concurrent-landing CPU overhead on large no-op refresh flushes (e.g. heap buffer views where
VICTORY_ASK_ONCEis already active) via four surgical changes incrates/victory-gpu/src/{watch.rs, shadow.rs, host.rs}:watch::asking_kept()fast path (watch.rs,host.rs):Journal::keptinstatic KEPT: AtomicBool(updated underJOURNAL.write()inask_restandask_once_end).watch::ask_aheadreturns immediately whenasking_kept()is true instead of walkingpublished(), allocating, and sortingpiecesonly to discard them after locking.watch::ask_ahead_donereturns immediately whenasking_kept()is true instead of taking an exclusiveJOURNAL.write()lock on every flush.Batch::flush_allandBatch::refresh_frontskip allocating/populatingrangeswhenasking_kept()is true.Journal::aheadwith binary search (watch.rs):j.ahead = merged(...)inask_aheadandask_restand replaces linear.iter().any(...)scans withahead_covers(partition_point).nothing_newpass (watch.rs,shadow.rs,host.rs):watch::with_journal/JournalView/watch::is_publishedandShadow::prepare_nothing_new/Shadow::nothing_new_in_journal(usingself.copied.try_lock()to guarantee no lock-order inversion withcopy_stale -> parts_written, falling back conservatively tofalseon contention).<= 64-item sub-chunks, checkspublished()bits before taking a singleJOURNAL.read(), partitions dirty indices into a stack[usize; 64], drops theJournalguard beforeBatch::update, and flushesFLUSHES[2]once per sub-chunk.len > 256) throughshadow::wide_chunks(..., wide_chunk().max(64), ...)while keeping small dirty flushes (len <= 256) on single-journal in-placeretain+wide_chunk()so small dirty flushes remain parallelized. Also reusesself.refreshesVeccapacity viaArc::try_unwrap.Shadow::rangedintoShadow::copied'sMutex(shadow.rs):self.rangedalready heldself.copied.lock(); folding it removes one redundantMutexlock/unlock per refresh.Synthetic Benchmark (
host::refresh_tests::frame_of_refreshes,--release --locked)Three consecutive runs before and after on Windows 11 x64, Rust 1.98.1 MSVC (pure CPU synthetic workload, 30 submissions × 4,400 copies + 174 MiB heap + concurrent landing thread):
923e38c4eea8beSynthetic Unit Tests & Checks
watch::ask_holds::ahead_covers_merged_adjacent_disjoint_and_boundaries,watch::ask_holds::asking_kept_fast_path_guards_ask_ahead_and_done, andhost::refresh_tests::chunked_nothing_new_matches_individual(3/3 passed).watch::(53 passed),shadow::CPU suites (16 passed),host::CPU suites (16 passed).cargo checkandcargo clippy --locked -p victory-gpu --all-features --lib --tests: zero warnings inwatch.rs,shadow.rs, and all touched lines inhost.rs.cargo xtask policy: zero violations in any touched file (pre-existinglower.rssize check untouched).AI-assisted. Synthetic verification only.
@domx4q on GitHub · 2026-11-29 00:47 UTC · original
Tested this on Linux, so another kind of host.
main(d4b5d51): 21.6 fps, 49 ms a frame, 36 ms preparing.d4b5d51: 22.1 fps, 48 ms a frame, 37 ms preparing.There were no crashes and no Xid faults, and the picture looked the same. On this machine the difference is within run-to-run noise (about ±1 fps), so nothing is lost. A gain may show more on CPUs with fewer cores, where the refresh contention in #1521 was measured.
4eea8bee6ftoda8e9461a7@steven-seagull27 on GitHub · 2026-11-29 00:51 UTC · original · edited 2026-11-29 08:01 UTC
Rebased cleanly onto
f9dfb76(da8e946): dropped ourShadow::rangedfold since #1463 (0174844) already merged sharedCopiedlocking, and added a#[cfg(test)]watch::nothing_newwrapper for59e7a01's test.Re-verified on Windows 11 x64 / Rust 1.98.1 MSVC (
--locked):cargo test --locked -p victory-gpu --lib -- watch:: --test-threads=1: 55 passed, 0 failedcargo test --release --locked -p victory-gpu --lib -- host::refresh_tests::frame_of_refreshes --exact --nocapture: 13.82 ms (down from 19.00 ms baseline)Synthetic tests only.
@amazedturnip on GitHub · 2026-11-29 05:38 UTC · original
Tested in a combined submit-thread perf stack on 9800X3D + RTX 5070 Ti 16 GB (Series X 1440p DLSS). Ran cleanly across 20+ min sessions with zero races/crashes; combined stack brought preparing time from ~39.8 ms down to ~17.2-20.0 ms and refreshes from ~13.2 ms to ~5.3-8.6 ms.
da8e9461a7tof79b22c56e@steven-seagull27 on GitHub · 2026-11-29 08:45 UTC · original
Rebased cleanly onto latest
main(829188e9, commitf79b22c5).Superseded pieces cleanly dropped
Waves 1–6 (notably
#1094/27d312d3) already landed:WRITTEN_EPOCHS, atomicShadow::copied, SeqLockranged_lockfree, andShadow::nothing_new_withwatch::is_kept()(called inrefresh_frontandflush_all)Journal::ahead+ahead_containsbinary searchshadow::wide_each_scopedThe earlier
JournalView/wide_chunks/ duplicateasking_kept/ahead_coverswrappers were dropped in favor of those upstream primitives.What remains & is fixed on top of
829188e9Shadow::nothing_new_with+ 64-item chunking acrossBatch(crates/victory-gpu/src/host.rs):ahead_snap,MANY_CHUNK, andnothing_new_withorphaned/unused inhost.rs, causingBatch::refresh_front,Batch::refresh_ahead,Batch::flush_all,sift_front, andsift_refreshesto fall back toShadow::nothing_new(acquiring theJOURNALread lock per span).watch::ahead_snapshot_into(&mut self.ahead_snap)once per pass and filter spans lock-free viaShadow::nothing_new_with.> 256refreshes) and parallel sifting (sift_spans, shared byVICTORY_FRONT_SIFTandVICTORY_FLUSH_SIFT) use 64-item scoped chunks (MANY_CHUNK = 64), reducing cross-core atomic contention onscoped_remandFLUSHES[2]and reusingVeccapacity in place; the non-wide fallback also filters no-ops vianothing_new_with.ahead_snap,MANY_CHUNK,Shadow::nothing_new_with, andwatch::nothing_new_with.is_kept()fast path inwatch::ask_ahead/ask_ahead_doneandahead_containsinwould_wait(crates/victory-gpu/src/watch.rs):ask_aheadandask_ahead_donenow short-circuit onis_kept()before bit checks, allocations, or takingjournal_mut().would_waitusesahead_containsinstead of a linear scan overj.ahead.watch::ask_holds::asking_kept_fast_path_guards_ask_ahead_and_donehost::refresh_tests::chunked_nothing_new_with_matches_individualVerification
cargo test --locked -p victory-gpu --lib -- watch:: --test-threads=1: 63 passed, 0 failedcargo test --locked -p victory-gpu --lib -- host::refresh_tests:: --test-threads=1: 6 passed, 0 failed (2 ignored)cargo clippy --locked -p victory-gpu --lib --tests: 0 new warnings (and 4 pre-existing warnings eliminated in touched code)git diff --check: cleancargo test --release --locked -p victory-gpu --lib -- host::refresh_tests::frame_of_refreshes --exact --ignored --nocapture):main(829188e9):14.04 ms/16.12 msmean (all copies3.74–4.14 ms, 29 others10.30–11.98 ms)f79b22c5, 3 runs):13.25 ms,13.01 ms,12.82 ms(median13.01 ms; all copies3.37–3.48 ms, 29 others9.45–9.82 ms)@Yuanzer on GitHub · 2026-11-29 11:04 UTC · original
Independent A/B on the reporter's Windows 11 machine (i7-14700KF, 20C/28T, RTX 5060 Ti 8 GB, driver 621.40), using the same release test executable and default
VICTORY_WIDE_THREADS. I alternated main829188e9and this PRf79b22c5for 5 pairs:--exact host::refresh_tests::frame_of_refreshes --ignored --nocapture.829188e9f79b22c5Raw frame means, main / PR by pair:
14.68/15.06,15.07/14.20,15.12/15.01,14.12/14.96,15.12/14.38. The distributions overlap heavily.On this CPU the isolated synthetic refresh path is effectively neutral (the 0.11 ms median difference is within run-to-run noise), and the all-copies sub-path is slightly slower. This does not contradict the positive combined-stack gameplay result above, but I would not use this microbenchmark alone as evidence of a frame-time win across CPUs. A game A/B on the same save/scene remains the decisive check.
Tested locally on behalf of the reporter.
@Yuanzer on GitHub · 2026-11-29 14:26 UTC · original
Three-pair in-game A/B on the reporter's Windows 11 machine (AI-assisted local run):
829188e9; PR:f79b22c5.Per-run medians:
All 180 one-second samples per build:
829188e9f79b22c5The three paired deltas straddle zero. The PR has the lower P99 in these runs, but it also sampled scenes with about 3.8% fewer draws; a per-1000-draw normalization is correspondingly worse. I would treat the isolated refresh path in this opening scene as neutral, not as a general frame-time win. The scene was not camera-locked, so draw count and in-game time are the main limitation.
There were no crashes or startup failures in the six runs. The earlier synthetic five-pair A/B already showed a similarly neutral result on this machine; this game-level run confirms that the benefit needs a scene/CPU condition that was not present here.
Runs and readings are from the reporter's machine; analysis and wording are AI-assisted.
Eliminate per-submission `Arc<Shadow>` clones/drops and scratch `Vec` allocations in `Batch::refresh_front`, and honor `shadow::wide_chunk()` in `wide_each_scoped` dispatches: 1. Zero-`Arc`, single-pass pre-filtering in `Batch::refresh_front` (`refresh_front_spans`): - `self.spans` already keeps every `Arc<Shadow>` alive across the submission, and `wide_each_scoped` is scoped. Store `(span_idx, from, to)` in a reusable `Batch::front_dirty` `Vec` instead of allocating a fresh `Vec<(Arc<Shadow>, usize, usize)>` and cloning/dropping `Arc<Shadow>` for every span (most of which are immediately filtered out as no-ops). - Default path resolves `(key, from, to)`, inserts into `self.ahead` for all spans (clean and dirty alike), and filters lock-free via `Shadow::nothing_new_with(&self.ahead_snap, ...)` in a single pass. - `VICTORY_FRONT_SIFT` (`sift_indexed`, 64-item scoped chunks) and `VICTORY_NEW_BATCH` (`nothing_new_all`) also operate on `front_dirty` with zero `Arc<Shadow>` clones. 2. Honor `crate::shadow::wide_chunk()` (`VICTORY_WIDE_CHUNK`): - `refresh_front_spans` keeps texture `due` items at grain `1` while chunking buffer copy spans by `wide_chunk()` in one scoped wave (`due.len() + dirty.len().div_ceil(chunk)`). - Also wire `wide_chunk()` into `Batch::flush_all` (`!check_noop`) and switch `Batch::refresh_ahead` from `wide_each` to zero-alloc `wide_each_scoped(..., wide_chunk(), ...)`. - Eliminates the `wide_chunk` dead-code warning in `shadow.rs`. 3. Add synthetic unit test `refresh_front_zero_arc_matches_and_runs_due` and synthetic benchmark `frame_of_refresh_front` (`#[ignore]`).@steven-seagull27 on GitHub · 2026-11-29 14:40 UTC · original
Thanks
@Yuanzerfor running the i7-14700KF A/B onf79b22c5!Pushed a follow-up commit (
05052950) toperf/batch-noop-refreshestargeting two remaining overheads directly inBatch::refresh_front(plusBatch::refresh_ahead/Batch::flush_all):Changes (
crates/victory-gpu/src/host.rs)Arc-clone, single-pass pre-filteredBatch::refresh_front:refresh_frontallocated a freshVec<(Arc<Shadow>, usize, usize)>, atomically clonedArc<Shadow>for every span, inserted intoself.ahead, and then dropped the ~83% clean spans inretain(...).self.spansalready keeps everyArc<Shadow>alive across the submission andwide_each_scopedis scoped,refresh_front_spansnow resolves(key, from, to)->(span_idx, from, to), inserts every span intoself.ahead, and filters lock-free vianothing_new_with(&self.ahead_snap, ...)into a reusedBatch::front_dirtyscratchVec— zeroArc::clone/Arc::dropand zero per-submissionVecallocations (including forVICTORY_FRONT_SIFTviasift_indexedandVICTORY_NEW_BATCH).shadow::wide_chunk()(VICTORY_WIDE_CHUNK) instead of hardcodedgrain = 1:refresh_front_spansnow dispatches texturedueitems 1-per-claim and buffer copy spans inwide_chunk()chunks within a singlewide_each_scopedwave (due.len() + dirty.len().div_ceil(chunk)).wide_chunk()intoBatch::flush_all(!check_noop) and movedBatch::refresh_aheadfromwide_eachto zero-allocwide_each_scoped(..., wide_chunk(), ...)as well.wide_chunkdead-code warning inshadow.rs.host::refresh_tests::refresh_front_zero_arc_matches_and_runs_due(checksself.aheadcoverage, unchangedArc::strong_count,front_dirtycapacity reuse,sift_indexed, and empty + non-emptydue).host::refresh_tests::frame_of_refresh_front(#[ignore], 30 submissions × 200 spans = 6,000 spans/frame, 83% clean no-op / 17% dirty).Verification (5-run medians in
--release)host::refresh_tests::frame_of_refresh_front(6,000 spans/frame, 83% no-op / 17% dirty):f79b22c5):3.354 ms/framemean (3.526, 3.329, 3.262, 3.595, 3.354, best2.799 ms); 100%-no-op pass0.218 ms/frame05052950, defaultVICTORY_WIDE_CHUNK=1):3.270 ms/framemean (3.311, 3.270, 3.249, 3.388, 3.250, best2.715 ms, -2.5%); 100%-no-op pass0.187 ms/frame(-14.2%)VICTORY_WIDE_CHUNK=4:3.205 ms/framemean (best2.630 ms)host::refresh_tests::frame_of_refreshes:f79b22c5): median13.16 ms/frame(13.16, 13.49, 13.33, 13.05, 13.00)05052950): median13.09 ms/frame(13.09, 12.95, 13.03, 13.33, 13.42, best all-copies2.87 ms)cargo test --locked -p victory-gpu --lib -- watch:: --test-threads=1: 63 passed, 0 failedcargo test --locked -p victory-gpu --lib -- host::refresh_tests:: --test-threads=1: 7 passed, 0 failed (3 ignored)cargo clippy --locked -p victory-gpu --lib --tests: 0 new warnings (wide_chunkwarning eliminated)git diff --check: clean@CopiiDeco on GitHub · 2026-11-29 19:42 UTC · original
Measured a large regression with this PR on Windows.
Rig: Ryzen 5 5600X (6C/12T), RTX 3080 10 GB (driver 616.92), 32 GB DDR4-3600, B450 (PCIe 3.0), Windows 11 26200.
Setup: diagnostics build (
--profile diag --features diagnostics),scripts/bench.ps1 -Dlss performance -FrameGen off -RayTracing off, Series S profile,VICTORY_WC_BAR=1 VICTORY_WINDOWS_BAR_MB=2048, the same save and opening cutscene for every run, 30 s warm-up then 120 s measured, pipelines precompiled (0 being made in the window). Each run is main at829188e9+ this PR merged, nothing else.One run each; same-config runs on this rig vary by about ±0.4 fps, so a 40 % drop is far outside the noise. No shader, pipeline or crash differences (0 refused, 0 crashes). Note that the submitting thread's "preparing" time is not worse (40.9 vs 42.8 ms), so the loss seems to be somewhere else in the frame (waits, or another thread).
Happy to rerun with a timeline (
VICTORY_TIMELINE) or other switches if that helps narrow it down.(Side note for anyone benchmarking:
scripts/bench.ps1on current main never detects the world, because its frame-line regex expectsdropped N without a host pipelineand the line now readsdropped N draws or dispatches; and thediagnosticsbuild of main does not compile (timingshadowed inhost.rs,mbmissing incopystat.rs). I patched both locally for these runs.)05052950f2to8bc654b7b2@steven-seagull27 on GitHub · 2026-11-29 20:48 UTC · original
Thanks
@CopiiDecofor the detailed Ryzen 5 5600X / RTX 3080 measurement — that's a very useful data point, and your observation thatpreparingactually improved (42.8 -> 40.9 ms) while total frame time jumped (~55 -> ~92 ms,+38.7 msoutsidepreparing) narrows things down a lot.I audited the full
829188e9..05052950diff (watch.rsandhost.rs) line by line:preparing(except the equivalent binary search inwatch::would_wait), and none of the changes touch GPU shaders, VRAM/descriptor allocation,settleconditions, or non-preparing thread locks.Batch::flush_all:MANY_CHUNKhad been raised from8to64. Unlike the pure-filterSIFT_CHUNK = 64loops,flush_all's closure performs actualSelf::updatedata copies (includingVICTORY_WC_BAR=1PCIe BAR copies and largetake_allcopies), so a 64-item grain on a 6-core CPU (wide_threads = 4) can serialize clustered dirty spans onto a single worker and hurt tail latency.Updated PR (
8bc654b7, rebased ontocec481f4)MANY_CHUNK = 8inBatch::flush_all(keepingSIFT_CHUNK = 64for pure-filter sifts) so combined check+copy flushes preserve fine-grained work-stealing across 6-core CPUs.origin/main(cec481f4), picking up the post-829188e9GPU/VRAM fixes (5c262d7bwave64 folding off by default,1b4b6cd4idle list trimming / scratch release / fetch buffer shrinking,4ffb47bb,b214e008,d7c2d8a7, and1082df39input replay) — particularly relevant on a 10 GB card withVICTORY_WINDOWS_BAR_MB=2048where VRAM headroom swings can push non-preparing wait time sharply.Verification on
8bc654b7cargo test --locked -j 3 -p victory-gpu --lib -- watch:: --test-threads=1— 63 passed, 0 failedcargo test --locked -j 3 -p victory-gpu --lib -- host::refresh_tests:: --test-threads=1— 7 passed, 0 failed (3 ignored)git diff --check origin/main..HEAD— clean, 0 new warnings inwatch.rs/host.rsIf you're up for re-testing on
cec481f4vs8bc654b7(ideally an interleaved A/B/A), sharing the frame breakdown lines (on the GPU,copying back,the card's clock per frame,submissions sent ahead per frame, andvideo memory/the texture queue's room) would immediately show which bucket outsidepreparingabsorbed the+38.7 ms.8bc654b7b2to25950d3818@steven-seagull27 on GitHub · 2026-11-30 00:20 UTC · original
Rebased cleanly onto
origin/main(41adb551,v2026.11.29.05).Superseded hunks dropped
crates/victory-gpu/src/watch.rschanges already merged by#2604(5c604fec):is_kept()fast-path guards inask_ahead/ask_ahead_doneandahead_containsbinary search inwould_wait.Remaining improvements (
crates/victory-gpu/src/host.rs)Arc, single-pass pre-filteredBatch::refresh_front_spansbacked by reusableBatch::front_dirty(eliminates per-submissionArc<Shadow>clones/drops and scratchVecallocation), plus 64-item scoped parallel sifting (sift_indexed/sift_spans) reusingVeccapacity.Shadow::nothing_new_with(&self.ahead_snap, ...)acrossrefresh_front_spans,refresh_ahead,flush_all,sift_indexed, andsift_spans(avoiding per-span journal locks, redundant snapshots, emptyask_aheadcalls, and zero-countFLUSHES[2]atomics).crate::shadow::wide_chunk()acrossrefresh_front_spans,refresh_ahead(migrated fromwide_eachtowide_each_scoped), andflush_all(!check_noop), while keepingflush_allMANY_CHUNK = 8for even check+copy work-stealing.chunked_nothing_new_with_matches_individual,refresh_front_zero_arc_matches_and_runs_due) and ignored synthetic microbenchmark (frame_of_refresh_front).Verification
cargo test --locked -j 3 -p victory-gpu --lib -- watch:: --test-threads=1: 65 passed, 0 failed.cargo test --locked -j 3 -p victory-gpu --lib -- host::refresh_tests:: --test-threads=1: 7 passed, 0 failed (3 ignored).cargo check --locked -j 3 -p victory-gpu --lib --features diagnostics: passed.cargo clippy --locked -j 3 -p victory-gpu --lib --tests: 0 new warnings in touched files (and clears 5 pre-existing unused/dead-code warnings onahead_snap,MANY_CHUNK,wide_chunk, andnothing_new_with).git diff --check origin/main..HEAD: clean.perf(gpu): batch no-op refreshes, lock-free ask_once fast path, and binary-search Journal::aheadto perf(gpu): zero-Arc pre-filtered refresh_front, lock-free ahead_snap checks, and wide_chunk wiringperf(gpu): zero-Arc pre-filtered refresh_front, lock-free ahead_snap checks, and wide_chunk wiringto perf(gpu): restore MANY_CHUNK = 8 in Batch::flush_all for 6-core work-stealing25950d3818to4a33459221@steven-seagull27 on GitHub · 2026-11-30 18:35 UTC · original
Since
05052950already landed onmainvia90159db7, this PR has been narrowed and rebased cleanly onto latestmain(e1251c31->4a334592) with just theMANY_CHUNK = 8follow-up inBatch::flush_all(crates/victory-gpu/src/host.rs,+7/-5).Lowering
MANY_CHUNKfrom64back to8(while keeping pure-filterSIFT_CHUNK = 64) avoids serializing clustered dirty spans onto a single worker on 6-core hosts (wide_threads = 4, reported by@CopiiDecoon Ryzen 5 5600X) — and is now on the default submission path whenever write-watch is kept since#3762(30911195) fused refresh sifting intoflush_all'scheck_nooploop.Verification
cargo test -p victory-gpu --lib -- refresh_front&chunked_nothing_new_with_matches_individual— passed.cargo clippy -p victory-gpu --lib— 0 warnings inhost.rs.cargo run -p xtask -- policy --staged&git diff --check origin/main..HEAD— clean.4a33459221toe4ab39fddfView command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.