gpu: placed-texture span lock skipped by default; texture-queue batch size tunable (VICTORY_QUEUE_BATCH_MAX) #1937
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1937"
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 danielibabet on 2026-11-29T03:30:21Z.
What
Two changes to
crates/victory-gpu/src/descriptor/host.rs, both off by default until now:1.
VICTORY_SPANS_QUICKon by defaultThe
placed: Mutex<Spans>inHostHeapis taken on every descriptor write to decide whether a slot describes a placed texture by address.spans_quick()gates a fast-path skip using thespannedbitset (already in RAM, no lock needed to read): if the slot is not inspanned, the span lock is not taken.Previously the guard read
is_some_and(|v| v != "0")— opt-in. This commit flips it to opt-out (VICTORY_SPANS_QUICK=0to disable). The semantics are unchanged: forgetting a slot that is not there does nothing — the bitset is the authoritative gate.Measured saving (from
docs/findings.md, run city4, timeline 113): 4 of the 16 ms the submitting thread waited for the records pass with six recording threads came from threads queueing behind that lock. On an RTX 4070 (fewer hardware threads than the RTX 5090 D where this was measured, so less ability to pipeline around the wait), the absolute saving is at least as large.Ported from Belobug/VIctory-Belobug-AMD
a284ca7, where this is on by default.2.
VICTORY_QUEUE_BATCH_MAX— tunable texture-queue batch sizeQueueBatchamortizes texture-queue WRITE lock acquisitions by buffering operations and flushing under one lock take. The flush threshold was a compile-time constantLIMIT = 64.VICTORY_QUEUE_BATCH_MAX=N(integer 1–4096, default 64) raises this limit.docs/findings.mdmeasures 34,000–78,591 WRITE lock acquisitions per 5-second window in the outdoor areas; a larger batch size reduces the number of acquisitions per recording thread proportionally.The bloom-filter field
seen_bits(u64, covering 64 unique slot indices) produces false positives above 64 ops, buthas_slotalready falls back to a linear scan ofself.opsto confirm — no behavioral change at any batch size.Tests
cargo test -p victory-gpu --lib --locked -- --test-threads=1: 589 passed, 0 failed, 44 ignoredcargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings: clean (pre-existingvictory-shaderclippy error onlower.rsunrelated to this change)cargo build --release -p victory --locked: cleanxtask policyfailure onvictory-shader/src/emit/lower.rs(711 KB > 655 KB limit) is onmainbefore this change.Hardware target
RTX 4070 12 GB (Wave32), i9-14900KF, 32 GB RAM, Windows 11. Build verified. 3D-world measurement requires manual game input to reach the open world; menu runs at 30 fps either way and do not exercise the descriptor-write hot path.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by amazedturnip on 2026-11-29T05:39:00Z.
Tested on 9800X3D + RTX 5070 Ti 16 GB across 20+ min sessions with VICTORY_SPANS_QUICK=1. Skipping the placed-texture span lock ran cleanly with zero descriptor races or corruption.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by meonline42 on 2026-11-29T09:18:07Z.
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 danielibabet on 2026-11-30T13:42:52Z.
Thank you both for testing!
@amazedturnip Good to hear zero descriptor races across a 20+ min session on RTX 5070 Ti — that confirms the safety argument: forgetting a slot that is not in spanned does nothing, since the bitset is the authoritative gate.
@meonline42 Thanks for the careful stacked measurements. The 1–2 ms per step figure matches expectations given your existing stack already had VICTORY_SPANS_QUICK=1 set, so the default-flip had nothing left to give there. The numbers are still useful — the per-draw-bucket breakdown is exactly the right way to compare these changes, and the direction is consistent. The main copy cost (24–28 ms, 60–70 MB/frame) is what PR #3514's VICTORY_QUEUE_HEAP=1 targets on the read path, and the larger batch default (256) reduces WRITE lock acquisitions which shows up mostly in scenes with many descriptor updates. Worth re-running that stack with VICTORY_QUEUE_BATCH_MAX=256 VICTORY_QUEUE_HEAP=1 once #3514 is merged — the gains should compound with the copy-back reduction already in your base.