Shadow: build first-touch copies outside write locks and cache buffer misses #4818
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!4818
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4817"
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-12-01 10:09 UTC · original
Bazovsky:pr/unlock-sync-and-shadow-alloc→main· +1365 −244 · 3 files · 1 commits · closed without mergingWhat it changes
On
main, first-touch allocation of a registered title buffer copy (lookup_buffer) or loose window (loose) acquiresBUFFERS.write()orLOOSE.write()across D3D12 resource / CPU mirror / in-place heap creation, stalling all concurrentVICTORY_THINrecording threads. In addition,lookup_buffertakesBUFFERS.write()viabuffers(), bumpingBUFFERS_CHANGEDon everyNone -> Somefirst-touch population (~4,350 times during world entry and streaming) and invalidating every thread'sFOUNDcache and per-listroot_views(VICTORY_ROOT_SAME), whilelookup_buffernever cachesBufferHit::Miss— forcing every loose-window and unaligned scratch root-CBV lookup to takeBUFFERS.read()and scanBTreeMapnodes acrossmax_size().This change:
BUFFERS.write()/LOOSE.write()behind 64-way per-key build stripes (BUFFER_BUILD/LOOSE_BUILD), with in-stripe copy fallback when an in-place candidate is invalidated, and installsNone -> SomeintoBUFFERSwithout bumpingBUFFERS_CHANGED(since[start, end)andmax_size()do not change).Entryat 16 bytes (const _: () = assert!(size_of::<Entry>() == 16)) and tracks same-key overwrites, removals, and placed evictions in a 1,024-slotBuffers::opsring while returning(key, &Entry)in a singleBTreeMapwalk (find_buffer_entry).MISS_GAPSinterval cache (VICTORY_QUICK_FIND) inlookup_bufferthat records proven buffer-free spans[gap_lo, gap_hi)bounded bymax_end.max(page_lo)and the next registered buffer start, invalidated viaBUFFERS_CHANGEDSeqCst seqlock checks onregister/unregister.PLACE_GATEinflight+freeing,PlacedRegistry256-event 64 KiB-aligned ring,PlacedActive/REGIONS_COUNThandoff inholds_any(), and 64 KiB-alignedCapGuard/SectionViewbyte-cap reservations) sotitle_memory_freeingdrains overlapping in-flight heaps and declines new overlapping placements beforeVirtualFree/VirtualProtectruns.Shadow::dropsubtractingCARD_BYTES[0]when dropping a spilled loose window (window && fallback.0 != 0), balancesbuffer_sidesrollback onCardCpu::allocatefailure, uses atomicfetch_maxframe-use tracking underLOOSE.read(), and converts diagnostic/censusLOOSE.write()readers (stale_pages,spans,memory,window_trim,windows,window_use,window_cover) toLOOSE.read().How it was tested
playsettings (4 x 115 sinterleaved ABBA runs on5fabb46evsc36730f3,0errors in all runs).VICTORY_THINtranslation CPU time (all threads/frame): median86.68 ms(86.85 / 86.50 ms), p95124.90 ms(121.20 / 128.60 ms)[0..10 s]post-load):31.56 FPS(30.33 / 32.78), worst frame231.9 ms(297.1 / 166.6 ms)2 x 72 s): median frame29.95 ms(33.59native FPS /67.18FG 2x FPS), p95 per-second max frame98.15 ms(102.9 / 93.4 ms), worst frame231.85 ms, smooth seconds (<= 50 ms)70.8%VICTORY_THINtranslation CPU time (all threads/frame): median84.13 ms(83.95 / 84.30 ms, -2.9%), p95108.30 ms(108.20 / 108.40 ms, -13.3%)[0..10 s]post-load):33.67 FPS(33.22 / 34.11, +6.7%), worst frame152.9 ms(161.7 / 144.1 ms, -34.1%)2 x 72 s): median frame29.90 ms(33.34native FPS /66.68FG 2x FPS), p95 per-second max frame83.25 ms(78.7 / 87.8 ms, -15.2%), worst frame181.45 ms(-21.7%), smooth seconds (<= 50 ms)72.2%cargo testpassed for the crates it touches: yes (victory-gpu --libonx86_64-pc-windows-msvc:shadow::89 passed x 5 runs under--test-threads=8,inplace::15 passed,port::4 passed,watch::tests::43 passed;cargo xtask policypassed;cargo xwin clippyhas 0 warnings in touched files, with 5 pre-existingcollapsible_ifwarnings incrates/victory-gpu/src/host/{font,menu,panel}.rsonmain)Checked for overlap
@trustno1-coder on GitHub · 2026-12-01 18:31 UTC · original
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed