Refreshes: a quick look with no lock for copies with nothing new, fan-out only when there is enough, and why each is not known clean #2010
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!2010
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2010"
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?
@binarycleric on GitHub · 2026-11-29 07:10 UTC · original
up/refresh-clean-check→main· +1096 −39 · 4 files · 4 commits · closed without mergingWhat it changes
Before each submission, the submitting thread refreshes the host copies its lists read. In the game world that's about 10,000 refreshes a frame, and about nine in ten of them find nothing new. Each of those still walked several cold cache lines of its copy, took its
pending,copiedandrangedlocks, and took the journal's read lock. When four or more were left, the work also went out to the thread pool. In a play log (RTX 5070 Ti, about 17 fps in the game world), refreshes were the largest part of the submitting thread's time: 15.2 ms of 45 ms a frame.Four commits:
nothing_newsays why a range isn't known to copy nothing (NotNew: shader writes pending, not watched, not covered by the asking or the bits, a page never taken, written since taken). The refreshes' frame line counts each reason. Nothing changes behaviour.host::refresh_tests::refreshes_at_a_frames_shape(ignored) runs refreshes shaped like a gameplay frame: 6,000 copies, about 10,300 refreshes in 40 flushes, 8 busy threads. It needsswitch::set_for_test, soVICTORY_BENCH_AB=<switch>can turn a switch off and on in one process.VICTORY_CLEAN_CHECK, on;=0off). Each copy keepsClean, a 32-byte record read under a sequence count: the range it is known to hold as of an asking.watch::LAST_WRITTENkeeps, per page, the latest asking that found it written, andwatch::Aheadkeeps the standing asking. A refresh whose range lies inside the record is told "nothing new" with no lock. That needs three things: the range is covered by the standing asking or known by its bits, no page of it was found written after the record's asking, and no shader writes are declared. The look runs once per item, before any fan-out. It only ever gives the answernothing_newwould give; anything else goes on tonothing_newas before.writing), shader writes landing (copy_back_done), merges under title writes (merge_under_writes), landings beside a guard (landed), and memory found not watched (update). The record only moves forward incopy_staleand innothing_new, under thecopiedlock.copiedis private toshadow.rs, and its only writers areShadow::new,copy_stale,merge_under_writesandlanded. Each either moves the record forward under the lock or callsforget. TheCopiedstruct on main merged the oldcopiedandrangedlocks into one but added no new writer.watch::owned, the ray-tracing arenas): the quick look doesn't accept it, so those ranges fall through tonothing_newas before.VICTORY_SPREAD_FEW, on;=0off). The refreshes left after the looks go to several threads only at 32 or more items or 256 KiB or more. Before, it was at 4 or more, and eachwide()paid for waking threads. This commit also counts the spans afternothing_newfilters them (refresh_found(found, due)). Counting them before indexed past the end. The testrefreshes_in_front_of_the_steps_some_left_out_by_nothing_newcovers it.How it was tested
cargo testpassed for the crates it touches: yes. Rebased onto maine1f2eb60:cargo test --release -p victory-gpu --lib, 594 passed, 0 failed, 45 ignored, twice in a row. A first run had one failure indescriptor::host::tests::views_off_their_elements_get_a_copy_of_their_bytes(a file this PR doesn't touch), which passed 3 of 3 times run alone.cargo clippy -p victory-gpu --release --all-targetsreports nothing new in the changed files.Bench:
Checked for overlap
I searched the open pull requests for the same issue and for the files this touches. Related:
Shadow::copiedinto atomics with a copy lock.This PR keeps
copied's lock and adds a separate record that only ever givesnothing_new's answer, behind a switch, plus the per-reason counts and the bench. If one of the others lands first, the counts, the bench and the fan-out threshold can be rebased onto it.[pr-performance] Refreshes: a quick look with no lock for copies with nothing new, fan-out only when there is enough, and why each is not known cleanto Refreshes: a quick look with no lock for copies with nothing new, fan-out only when there is enough, and why each is not known cleanPull request closed