perf(gpu): use pre-snapshotted ahead list in refresh sift paths (~7900 journal lock acquisitions/frame → ~48) #2504
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2504"
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 erax4193 on 2026-11-29T13:43:55Z.
Problem
In
flush_allandrefresh_front, the light-refresh "few" path (len ≤ 256)already calls
watch::ahead_snapshot_into(&mut self.ahead_snap)before theretain loop — but then immediately calls
shadow.nothing_new(from, len)perresource, which acquires
journal()internally, ignoring the snapshot justcaptured.
From the logs on a Core Ultra 9 275HX + RTX 5070L running the game's prologue:
7917 resources × 48 flushes/frame ≈ 7920
journal()lock acquisitions perframe, all on the submission thread, to answer "nothing changed" for 87.7% of
them. The lock is uncontested but not free: each acquisition reads an RWLock,
branches on the ahead list, and touches the per-page epoch array.
Fix
Two-line change per site: pass
&self.ahead_snaptonothing_new_with—the lock-free version that uses the pre-snapshotted ahead list — instead of
calling
nothing_newwhich re-acquires the journal.flush_all(line ~12680): snapshot is already taken at the top of thebranch; just pass it to
retain.refresh_front(line ~12498): no snapshot taken before the sift; addone
ahead_snapshot_intocall, then usenothing_new_withinretain.Result: ~48 snapshot acquisitions/frame instead of ~7920 per-resource ones.
Expected impact
The 28.6 ms/frame refresh time comes almost entirely from the per-resource
journal lock overhead — the 974 resources that actually copy data take far
less time. With the lock removed from the sift loop, the refresh cost should
drop close to the actual copy time of those ~12% dirty resources.
Notes
nothing_new_withis semantically equivalent when the snapshot is fresh:the snapshot is taken on the same thread, immediately before the loop, with
no yield points between.
batchpath (usesnothing_new_all) is unchanged — italready batches the journal read.
many/flush_siftpath (> 256 resources per flush) is unchanged;that path uses
wide_eachwhich already distributes the per-resource cost.🤖 Generated with Claude Code
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by xmorvay on 2026-11-30T14:06:07Z.
tested the two refresh sift changes from this pr on a 4070 super with a 7900x3d and 32 gb of ram
three launches from the same post prologue save with the same scripted camera turns
series x at 1440p with dlss quality and frame generation off
both builds used the same input changes and the same persistent cache
these are window title samples taken every two seconds from second 68 to second 96 with more than 3000 draws per frame
the percentile describes the sampled readings rather than individual frames
all three runs reached the world and finished with zero failed pipelines
both patched runs had lower sampled frame times but the cache loaded more slowly in the control and the draw counts varied
i still saw slow turns on the second patched run so i would treat this as a result worth reproducing rather than a fix for camera stutter
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by paales on 2026-11-30T20:51:59Z.
Written by 🤖:
In-game numbers, tested together with #4340 in one build, so the two are not told apart. PC: RTX 5070 Ti 16 GB, Ryzen 9 5900X, 32 GB, Windows 11. Series X, 1440p, DLSS Performance, frame generation off, 30 fps cap. Each run: a new game (settings save, no story save), one A press, the first cutscene for 60 s from its first frame. On this PC the same build's submitting thread took 24 ms a frame in one run and 35 ms in another half an hour later, so only large differences count.
Base:
main84bd61e2with #3918, #1727, #3553, #3043, #4206 (VICTORY_FILL_AHEAD=1), #4138 and #720 (VICTORY_HEAP_WORKER=1). One run each, back to back:I could not measure a gain. One run is not enough to call it a loss on this PC either.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.