victory-gpu: back off RemapQueue overflow compaction under disjoint write storms #3733
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3733"
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 superhero-520 on 2026-11-30T05:28:19Z.
Summary
Bounds
RemapQueue::record()full-queue unpublished compaction under sustained disjoint write storms incrates/victory-gpu/src/descriptor/host.rs, eliminating anO(N^2 \log N)global mutex (REMAPPED) regression introduced in PR #2607 (2fe2d4cc) while preserving 100% of PR #2607's burst-compaction behavior for compressible bursts.Root Cause
REMAP_LIMITis1 << 15(32,768). During live world streaming and GPU-to-CPU landing,watch::landing()->watch::writing()->descriptor::host::remapped()records hundreds of thousands of disjoint ranges (e.g.338,000–462,884evictions in a 2-minute session onv2026.11.29.05).2fe2d4cc), onceself.ranges.len() == REMAP_LIMITwithunpub_len > 0, every subsequent disjointrecord()call allocates aVecup to 32,768 entries (512 KiB), drains the unpublished suffix, runsjoin()(sort_unstable—O(N \log N)), evicts only 1 entry, and re-pushes all entries withself.latest— leavingranges.len() == REMAP_LIMITandunpub_lenstill growing on the very next call, all while holding the globalREMAPPED: Mutex<RemapQueue>lock across all landing, write-watch, andxmemthreads.v2026.11.28.03/v2026.11.29.01:landing"opening or noting guards"=0.8–1.95 ms/frame(merging what was fetched=3.3–4.8 ms).v2026.11.29.05(41adb551):landing"opening or noting guards"jumped 12×–25× to26.5–53.9 ms/frame(merging=12.4–21.5 ms).Fix Design (
crates/victory-gpu/src/descriptor/host.rs)unpub_len < 2compactions:ranges.back_mut()fast path immediately above already checked overlap/adjacency against the sole unpublished entry whenunpub_len == 1, so draining and sorting 2 guaranteed-disjoint ranges can never shrink the queue.compact_after):needed > limit) or shrinks the unpublished suffix by< 25%(unpub.len() * 4 > unpub_len * 3), defer the next full-queue compaction byunpub.len().max(2)records (self.compact_after = self.latest.saturating_add(cooldown)).O(1)(pop_front+push_back), bounding disjoint overflow storms to amortizedO(\log N)while keepingself.evictedstrictly monotonic viaself.evicted.max(...).snapshot()resetsself.compact_after = 0so fresh bursts after a snapshot compact immediately; compressible bursts that shrink>= 25%without overflow also keepcompact_after = 0.Verification & Results
Unit & Concurrency Tests (
cargo test --locked -p victory-gpu --lib remap_history -- --nocapture --test-threads=1)remap_history_compacts_unpublished_bursts_without_evicting,refresh_remapped_advances_cursor_when_no_slots_match,remap_history_delivers_extended_ranges_and_detects_eviction).remap_history_does_not_thrash_compaction_on_disjoint_overflow_storm: 100,000 disjoint overflow writes atREMAP_LIMIT = 32,768completed in8.56 mswith only16compactions (monotonicevicted, cooldown cleared onsnapshot()).remap_history_repeated_overlapping_and_publish_cycles_never_evict: 8 repeated interleaved overlapping burst + publish cycles with multiple cursors ->0evictions and exact coalesced ranges.remap_history_concurrent_overflow_storm_keeps_lock_contention_bounded: 4 writer threads × 25,000 disjoint records (100,000 total) + concurrent snapshot reader atREMAP_LIMIT = 32,768-> completed in95.74 ms(365compactions across35snapshots), peak lock wait1.48 ms, zero panics, monotonicevicted.cargo clippy --locked -p victory-gpu --all-targets,cargo check --profile diag --locked -p victory --features diagnostics,cargo run --locked -p xtask -- policy --staged: all passed with 0 new warnings.Live Hardware Impact (RTX 3060 Laptop 6 GiB + Ryzen 7 5800H + 16 GB RAM, Series S 540p->1080p DLSS Perf K, RT OFF, warm pipeline library)
v2026.11.29.05(41adb551) vs builds including thisRemapQueuebackoff (both the 2-fix perf build and the combined#2015+#2038+perfbuild):landing"opening or noting guards":27.6 ms->2.21–2.34 ms/frame(~12× faster), restoringv2026.11.28.03(1.95 ms).landing"merging what was fetched":13.1 ms->4.53–5.08 ms/frame(~2.6–2.9× faster).copybacktime:28.6 ms->20.4–21.5 ms/frame(-7.1 to -8.2 ms/frame).landing/opening or noting guardsmetric isolateswatch::landing()->descriptor::host::remapped()lock contention directly (for comparison, disablingVICTORY_SEND_BAR=0alone without this fix still showed53.9 ms/frameinopening or noting guards).Limitations & Known Risks
snapshot(), compaction waits until the cooldown expires (falling back to the pre-PR-#2607O(1)ring-buffer eviction during cooldown, which is always sound becauseevictedadvances monotonically and forces a safe rescan on lagging cursors).AI Assistance Disclosure
AI-Assisted: Diagnosed, implemented, tested, and documented with AI assistance (Antigravity / Gemini), with all unit/concurrency tests, clippy/policy checks, and live RTX 3060 measurements verified locally.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-30T06:06:57Z.
Review: APPROVED
Tested locally merged onto
main(41adb551).crates/victory-gpu/src/descriptor/host.rs.cargo test -p victory-gpu --lib descriptor::host::tests::passed (75 passed; 0 failed; 1 ignored, including all 3 new#3666regression tests:remap_history_does_not_thrash_compaction_on_disjoint_overflow_storm,remap_history_repeated_overlapping_and_publish_cycles_never_evict, andremap_history_concurrent_overflow_storm_keeps_lock_contention_bounded) with 0 new warnings.Strong, well-tested fix for the
RemapQueueoverflow-compaction contention regression (#3666). LGTM.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Yoruiopz on 2026-11-30T07:07:20Z.
Independent Windows A/B on an RTX 5070 Laptop GPU. I ran the .05 renderer with the same binary, copied checkpoint, controller tape, and warmed cache. Both runs used Series X at 1920×1080, DLSS Performance, 2× frame generation and a 15 FPS render cap. Only the #3733 queue policy was toggled.
The comparable early draw blocks covered 768 renders per run. They held about 15 rendered FPS in both runs, with rendered-frame p95 of 79.0 and 80.0 ms. Later draw counts diverged, so those intervals cannot establish a frame-pacing gain. This independently reproduces #3666's excessive queue work and shows the backoff removes most of it on this GPU.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by ajcorrea on 2026-11-30T16:24:18Z.
Confirming this fix on an 8 GB card, with a bisect that lands on the same commit.
Setup: RTX 3060 Ti 8 GB, Ryzen 7 7800X3D, 32 GB DDR5, Windows 11, Series S profile, 1440p, DLSS Quality + FSR 3 frame generation. Same route on every run, 3–4 min from loading into the world (the streaming-heavy stretch where the hitches showed up after v2026.11.29.05). Release builds, same settings file throughout.
Metrics (from the release log):
victory_gpu::land"merging what was fetched", ms per frame summed over all threads (median / max)10161a3)41adb55)abf4fe07(#2509)9780f5c4(#2971)f37bf099(#2530)VICTORY_SMALL_COPY=0(#2116 off)223f22f0c)By elimination the regression is
2fe2d4cc(#2607), and this PR brings merge time back to the .04 level (best hitch count of all runs, no device removals). Glad to see it in v2026.11.30.01. Thanks!