perf(gpu): use pre-snapshotted ahead list in refresh sift paths (~7900 journal lock acquisitions/frame → ~48) #2504
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!2504
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@erax4193 on GitHub · 2026-11-29 13:43 UTC · original
erax4193:perf/refresh-use-ahead-snapshot→main· +989 −859 · 36 files · 17 commits · openProblem
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
f9de61c5bc7 index layout change 85dd7a7e35@xmorvay on GitHub · 2026-11-30 14:06 UTC · original
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
890fe620b1to4ba802898b@paales on GitHub · 2026-11-30 20:51 UTC · original
Written by 🤖:
In-game numbers, tested together with #4341 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, #4207 (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
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.