Remap queue: compact a full queue at most every quarter of it (copy-back CPU cost since #2607) #3877
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3877"
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 tikD1337 on 2026-11-30T10:04:46Z.
What
Since #2607 a full
RemapQueuesorts and joins its whole unpublished suffix (up to 32,768 ranges) at every recorded range, under the queue's lock. Outdoors the queue stays full of disjoint unpublished ranges (~300 landing pieces a frame, each its own 64 KiB block), so a compaction frees no room and the very next range compacts again.This PR keeps #2607's compaction but spaces it out: a full queue compacts at most every quarter of its length (
VICTORY_REMAP_COMPACT_EVERY, defaultlimit / 4;1restores compacting at every range). In between, a full queue drops its oldest range, as it did before #2607.VICTORY_ABcan flip the switch within one run.One file,
crates/victory-gpu/src/descriptor/host.rs, plus a unit test (remap_history_compacts_a_full_queue_at_most_every_quarter). #2607's own tests still pass unchanged.Measured
RTX 4070 Ti SUPER (driver 621.01), Ryzen 5 7600, 32 GB, Windows 11; diagnostics build of
41adb551. Unattended runs standing in the open world from the same save, ~6-8k draws per frame, warm pipeline cache. The stage timers came from a local diagnostics patch, not part of this PR.Per frame, on the thread that copies back (landing):
41adb551remapped_rangesfrom landing jobsBefore #2607 (commit 1b84c02) the landing guard figure was 0.39 ms, so this brings it back to where it was. Compactions now run ~0.1 times per frame.
What it does not do
No FPS change. An in-run A/B (
VICTORY_AB=20,VICTORY_REMAP_COMPACT_EVERY, 17 alternating 20 s phases, same scene) gave a median frame-time ratio of 1.009, which is noise. Outdoors the copy-back thread runs beside the submitting thread and is not on the frame's critical path; the render threads' list calls and the title's own CPU work are. So this is a CPU and lock-time saving (about one core's 10 ms a frame), not an FPS gain. It may matter more on CPUs with fewer cores.Tests
cargo test --release --locked -p victory-gpu: 921 passed, 2 failed, both also failing on main without this change:shader_cache::tests::every_switch_of_the_translator_is_in_the_keystill listsVICTORY_SCALAR_SPLITS, which1b4b6cd4removed from the translator.host::card_steps::tests::places_written_after_sending_are_learnedfails only in the parallel run (passes 3/3 alone); unrelated to this file.cargo clippy -p victory-gpu --all-targets(with and without--all-features): no warning in the changed lines. main has ~25-30 existing warnings, so-D warningsfails without this change too.AI-assisted (Claude Code): the measurements, the diagnosis and the change were made with an AI agent and checked on the machine above.
🤖 Generated with Claude Code
Update (interleaved-writes edge case)
c0e1710, original commit99e2a92, preserving authorship): while compaction is on cooldown,RemapQueue::recordchecks up to the last 8 unpublished entries and coalesces overlapping/touching unpublished ranges instead of evicting published history.remap_history_keeps_published_ranges_during_interleaved_writes.cargo test --locked -p victory-gpu descriptor::host(both default and--features diagnostics: 82 passed, 0 failed, 1 ignored) andcargo clippy --locked -p victory-gpu --all-targets.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tikD1337 on 2026-11-30T10:11:00Z.
Note on the CI failure:
victory-gpu(the only crate touched by this PR) compiles cleanly under clippy. The workspace clippy failure is the pre-existingdead_codeerror onunwind_copyincrates/victory-loader/src/crash.rs:804onmain41adb551.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tyr0nsur on 2026-11-30T10:15:26Z.
I reproduced one case where throttling can discard useful remap history at
3d3d9a8. Fill most of the queue with ranges already seen by a fast heap, then alternate writes to two unpublished ranges. When the newer write overlaps the second-to-last entry and the sort is on cooldown, it can evict a published range. A lagging heap then falls back to rescanning every placed slot.The companion patch looks among the last eight entries while throttling is active. It only joins unpublished overlapping or touching ranges and moves the result to the tail with the latest sequence. The
1setting still runs the original compaction path for the A/B comparison.Using the real 32,768-entry limit and 8,193 synthetic alternating 64 KiB writes, history drops went from 8,191 to 0 and the lagging snapshot remained available. An equally long disjoint trace still ran two full compactions before and after. The regression test covers both a lagging and a current cursor. Diagnostics descriptor tests passed 74 checks, with 7 targeted checks also passing on WARP. These are queue measurements from a synthetic fixture.
Companion commit
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tikD1337 on 2026-11-30T13:57:58Z.
Thank you @tyr0nsur for catching that interleaved-writes edge case and writing the fix! Cherry-picked your commit
99e2a92(c0e1710on this branch, preserving authorship) into #3877. Verified bothcargo test --locked -p victory-gpu descriptor::host(default and--features diagnostics) andcargo clippy --locked -p victory-gpu --all-targetspass cleanly on the updated branch.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tikD1337 on 2026-11-30T16:59:35Z.
Closing as superseded by
223f22f0onmain(superhero-520addedcompact_aftercooldown backoff for the sameRemapQueuecompaction storm). Thank you again @tyr0nsur for catching the interleaved-writes edge case and writing99e2a92!Pull request closed