Shadows & watch: fused AVX2 word_runs_and_update, linear stale_pages_in, and sorted Journal::ahead #1637
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!1637
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1637"
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?
@Bazovsky on GitHub · 2026-11-28 22:45 UTC · original
Bazovsky:pr/shadow-watch-fused→main· +255 −28 · 2 files · 1 commits · merged 2026-11-29 08:16 UTCFixes #
What it changes
Cuts CPU work in shadow CPU-side diff/copy (
under) and write-watch / stale-page lookups (ref):word_runs_and_update(crates/victory-gpu/src/shadow.rs): when updating card-backed shadow copies inShadow::take, comparestitleagainstheldand writes updated 32-byte vectors toheldin one AVX2 pass instead of runningword_runsand then re-scanning withcopy_from_slice. Falls back todword_runs+copy_from_sliceon unaligned or non-AVX2 paths.stale_pages_in(crates/victory-gpu/src/shadow.rs): advances a single linear cursor over the sortedwrittenslice after one initialpartition_pointinstead of binary-searchingwrittenfor every page inlo..hi.Journal::ahead+ahead_containsbinary search (crates/victory-gpu/src/watch.rs): keepsJournal::aheadsorted and non-touching acrossask_aheadandask_rest, usesahead_contains(linear for<= 8entries,partition_pointabove), and inask_resttries mergedkernel_writtenfirst with a per-piece fallback so a touching unwatched or separate reservation never prevents caching its watched neighbour.word_runs_and_update_matches_word_runs_and_copies_exactly(aligned random, unaligned/odd fallback, all-differ, none-differ), expandedpages_never_taken_are_stale_written_or_not(cursor skips belowlo, gaps, and pasthi), and addedask_rest_falls_back_per_piece_when_touching_unwatched_neighbourandahead_contains_matches_linear_over_binary_threshold.How it was tested
RUSTFLAGS="-C target-cpu=znver5") on cleanorigin/main(d4b5d51), 90 s same-session A/B runs (aligned steady window DLSS frames 100..1800, 0 D3D12 errors).d4b5d51): median 26.80 ms (37.3 fps), p95 36.30 ms, Prep 26.05 ms (ref=7.50 ms,under=2.05 ms), GPU busy 63%, 1,839 DLSS frames in 90 s.pr/shadow-watch-fused,b366bb9): median 25.40 ms (39.4 fps, +2.1 fps / +5.6%), p95 32.55 ms (-3.75 ms), Prep 24.40 ms (-1.65 ms) (ref=6.95 ms (-7.3%),under=1.45 ms (-29.3%)), GPU busy 67%, 1,908 DLSS frames (+69) in 90 s.cargo testpassed for the crates it touches: yes (victory-gpu: 553 passed, 0 failed — 514 non-watch + 39watch::testsserial;clippy+--features diagnosticscheck clean with 0 new warnings).Checked for overlap
Journal::aheadinwatch.rs; no open PR touches fused AVX2word_runs_and_updateor linearstale_pages_ininshadow.rs).@POMXARK on GitHub · 2026-11-28 23:42 UTC · original
@Bazovsky — ran a 20-minute gameplay A/B of the
shadow.rsportion (fused AVX2word_runs_and_update+ linear O(N)stale_pages_in, since our stack already carriesahead_normalize/ahead_holdsfrom#1094) on Windows 11 (RTX 5080 16 GB, Ryzen 7 5700X 8C/16T, 32 GB RAM, Series X 1440p, DLSS Quality + MFG 4x, release build, matched switches):Verification
word_runs_and_update_matches_word_runs_and_copies_exactly+dword_runs+word_runs3/3 PASS (0.00s).0errors over 20 minutes,refused=2, clean visuals across all 16 captured screenshots.20-minute A/B (with draw-bucket & copy-throughput normalization)
shadow.rs)MB/ms)n=50vsn=51)77.2 ms,cop 30.1 ms / 58.2 MB= 1.93 MB/ms)73.0 ms,cop 26.6 ms / 53.6 MB= 2.02 MB/ms)+5.4% FPS)n=12vsn=31)cop 33.5 ms / 68.8 MB= 2.05 MB/ms)cop 40.6 ms / 85.9 MB= 2.12 MB/ms)under(putting title's bytes under flights)(Note: overall unweighted
ALL 3D p50differed (15.30vs13.55 FPS) because the 20m route spent more samples in the heavier7k–10kbucket (n=31vsn=12); within the matched4k–7kbucket and in normalized copy throughput (MB/ms), fused AVX2word_runs_and_update+ linearstale_pages_inimproved copy efficiency by +3.0% to +4.2% with 0 errors and lower commit!)@unueberlegt on GitHub · 2026-11-29 01:23 UTC · original
Tested this part (sorted, disjoint
Journal::ahead+partition_pointcontainment) standalone on our side while working #1521: implemented the same shape (sort + join touching ranges at both writers, binary search above 8 entries, linear below) and measured it in isolation on a machine whereaheadholds only dozens of ranges: RTX 5070 12 GB, Ryzen 9 9950X3D (16C/32T), Series X 2560x1440, prologue, steady windows, medians. The refresh/journal numbers moved within scene noise there (7.0 vs 7.2 ms refreshes/frame against baseline) — expected: the linear scan over dozens of in-cache ranges was already cheap at this core count, so the win case remains the issue reporter's 8-core CPU-bound setup, where the per-span scan was cache-cold. The design matches ours, for what a second implementation is worth: the join has to include touching (not only overlapping) ranges, or a probe across two former neighbours answers falsely negative — ours joined them and the containment stayed exact.GPU and profile: NVIDIA RTX 5070 12 GB, AMD Ryzen 9 9950X3D, 31 GB RAM, Windows 11 26300; Series X profile, 2560x1440, release builds, steady-window medians.
b366bb9143to03d5f57097@Bazovsky on GitHub · 2026-11-29 01:43 UTC · original
Thanks @POMXARK for the 20-minute
shadow.rsA/B on Ryzen 7 5700X + RTX 5080 (+3.0% to +4.2% copy throughputMB/ms, +5.4% FPS in matched 4k–7k draws, 0 errors), and thanks @unueberlegt for independently confirming the sorted/disjointJournal::ahead+ touching-range join invariant while working #1521 — great to have two independent implementations converge on the exact same semantics.Rebased onto
origin/main(d585f88->03d5f57), preserving #1062'sownedchecks inask_rest/asked/writes/nothing_newand0174844'sCopiedlock changes. Verified withclippy(default +--features diagnostics, 0 new warnings) and native Windowsvictory-gputests (592/592 pass).@POMXARK on GitHub · 2026-11-29 03:00 UTC · original
@Bazovsky — quick follow-up data point on
watch.rs(GetWriteWatch) +xmem.rsfrom our synthetic repro + 20-minute 3D A/B on Windows 11 (Ryzen 7 5700X 8C/16T + RTX 5080 16 GB, 1440p DLSS Quality + 4x FG,0errors):AHEAD_GAP = 8 MiBhurts CPU recording threads on Windows 11:In a real Win32
VirtualAlloc(MEM_WRITE_WATCH)microbenchmark (174 MiBheap,160clustered256 KiBspans,4,200dirty 4 KiB pages/f),GetWriteWatch(WRITE_WATCH_FLAG_RESET)withAHEAD_GAP = 8 MiBresets untouched gap pages (4,200vs987), causing next-frame CPU writes to re-trap into the Windows kernel (~560 ns/page). ShrinkingAHEAD_GAPto512 KiBcut combinedGetWriteWatch + next-frame CPU writetime by-32%(2.85 -> 1.94 ms/f).MEM_WRITE_WATCHon strictly CPU-onlyXMEM_CPUallocations (flags & 2 == 0and noPAGE_GRAPHICS_*bits):On a
128 MiBCPU-only buffer (8,000scattered 4 KiB page writes/f), omittingMEM_WRITE_WATCHsped up CPU writes by76x(4.478 -> 0.059 ms/f).AHEAD_GAP=512 KiB+ unwatchedXMEM_CPU, matched heavy open-world trajectory,0errors):GetWriteWatch(ww):6.7 ms(p9016.9 ms) →5.6 ms(p9010.1 ms) (-16.4%med /-40.2%p90)SUB):67.1 → 60.5 ms(-6.6 ms)ALL 3Dmedian:13.60 → 14.15 FPS(+4.0%),7k–10k:10.20 → 10.60 FPS(+3.9%),>=10k:8.80 → 8.90 FPSGetWriteWatchacross threads (1T=0.64 ms,4T=0.61 ms,8T=0.66 ms), so shrinking the reset footprint beats parallelizing queries.Clean-room writeup & standalone repro suite: https://github.com/POMXARK/bcpack-gpu-hlsl/blob/main/docs/PERF_REPRO_AND_TUNING.md
@Bazovsky on GitHub · 2026-11-29 05:32 UTC · original
Thanks @POMXARK for the
GetWriteWatch/AHEAD_GAP(8 MiBatwatch.rs:473) and unwatchedXMEM_CPUmeasurements (ww6.7 -> 5.6 msmed /-40.2%p90,ALL 3D +4.0%, and the Win11GetWriteWatchserialization finding) plus the clean-room repro!I'll keep #1637 focused on
shadow.rs(fused AVX2word_runs_and_update+ linearstale_pages_in) and sortedJournal::aheadso the diff stays easy to review; tuningAHEAD_GAPand skippingMEM_WRITE_WATCHon CPU-onlyXMEM_CPUallocations look like a strong, well-scoped separate follow-up PR.@amazedturnip on GitHub · 2026-11-29 05:38 UTC · original
Tested on 9800X3D (AVX2) + RTX 5070 Ti 16 GB in a combined perf stack across 20+ min sessions. Zero shadow/watch regressions; combined stack cut write-watch time from ~4.5 ms to ~1.9-2.3 ms/frame.