gpu/shadow: O(dirty) CopiedPages bitmask, lock-free mirrors & AVX2 merge/diff (2/4 of #51) #57
No reviewers
Labels
No labels
accessibility
bench-bm-v1
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/PastiiJay--klbf-lab!57
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-57"
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?
@Vladimir-Human on GitHub · 2026-11-26 00:39 UTC · original
Vladimir-Human:perf/split-copied-pages-avx2→beta· +1342 −307 · 1 files · 1 commits · openSplit 2/4 of #51 cleanly on top of
beta(independent of #56, Part 3 ReBAR, and Part 4 Lazy Copy-Back).Summary of Changes (
crates/victory-gpu/src/shadow.rs)CopiedPagesbitmask +SmallRunsinline coalescer: pairs per-page copied stamps with a 64-page-per-worduncopied_bitsbitmask and inline 8-entrySmallRunssoShadow::copy_staleskips clean spans 64 pages at a time, plans coalesced copy runs underself.copied, and releases the mutex before issuing memory copies.Shadow::has_pending(AtomicBool) andCard::{has_dirty, has_sent}(AtomicBools with Release/Acquire ordering incard_dirtyandcard_merge_relay) to avoid mutex traffic on read-only windows and clean carded copies.has_avx2()runtime dispatch forfirst_difference,last_difference,changed_runs,merge_piece,merge_sync_card, andmerge_back_piece, eliminatingback_piece's per-piecemaskallocation.WideDoneworker completion, panic propagation, and TLS scratch reuse: movescopy_wideandShadow::differingonto the kept worker pool withWideDone, adaptiveWIDE_MIN_SPLITbatching, nestedIN_WIDEreentrancy guard, andSCRATCH_TITLE/parts+restbuffer reuse.copied_and_simd_tests::{plan_stale_matches_oracle_across_boundaries_and_partial_init, simd_diff_and_merge_helpers_match_scalar_oracles, nested_wide_runs_without_deadlock, wide_propagates_worker_panic_without_deadlocking_pool}and#[ignore] bench_copied_and_simd.Verification (
VICTORY_D3D12_DEBUG=1)cargo test -p victory-gpu-> passedcargo test -p victory-gpu --all-features-> passedcargo run -p xtask -- policy --staged->asset policy: 1 files ok(shadow.rs= 222,729 B)Related: #51, #56
@HandshakeHackin on GitHub · 2026-11-26 02:53 UTC · original
I tested
ea3f336on a Windows x64 runner that confirmed AVX2 was available. Across 22,380 placements of a changed byte range (including empty spans) in 31–97 byte buffers, the first/last differences and exact changed runs matched the expected values. With CPU edits at bytes 30, 31, 32, 63 and 64 where present, the copy-back merge also preserved those edits, returned the expected disjoint ranges, and left the host and title buffers byte-identical to the oracle. This exercises all-changed 32-byte blocks, ends of vectors and scalar tails using synthetic bytes. Test and log@PastiiJay on GitHub · 2026-11-26 10:42 UTC · original
Thanks for the 22k-placement check against the oracle, that's thorough. We'll test the AVX2 path in game.
@Proudnoob4 on GitHub · 2026-11-26 14:39 UTC · original
Live in-game GTA 6 runtime oracle audit + 10-minute benchmark (
0mismatches,-65%noting the runs,-82%finding the pages)We ported this full shadow/watch optimization stack (
O(dirty)TOUCHED_CARDS, 64-page-per-wordCopiedPagesbitmask, lock-freehas_pending, directmerge_under_writes,FOUND_LOOSEthread-local cache, in-placejoined(), and AVX2first_difference/last_difference/merge_piece/merge_sync_card/changed_runs) into our RTX 4080 / i5-13600K (Windows 10) GTA 6 Series S build and verified it both for live correctness and steady-state performance:10-minute live GTA 6 runtime oracle audit (
31,249log lines, real gameplay frames):first_difference/last_difference/changed_runs/merge_piece/merge_sync_card,TOUCHED_CARDSdirty scan,CopiedPagesbitmask,FOUND_LOOSEcache, and in-placejoined()) to compare against the scalar / stock reference on live frames.0mismatches (ERROR=0) across the entire 10-minute live run.10-minute release benchmark (RTX 4080 16 GB, i5-13600K, Win10,
render_scale=0.6667,VICTORY_CARD_BUFFERS_MIN_KB=64,VICTORY_FETCH_CHECK=1,VICTORY_SKIP_WC_MIN_KB=1024, RT skipped):VICTORY_LATE_WAIT=2(212pages looked at,77,290changed runs,2.38 MB):finding the pages:~0.28 ms -> 0.05 ms(-82%)noting the runs:~3.7 ms -> 1.28 ms(-65%)comparing pages:1.93 mswall (1.65 msreading +6.71 mscomparing/putting in across worker threads)n=104, tail-40n=40):32.00 fpsmedian (31.50p10,32.60p90,32.70tail-40 max,33.20overall max;0tail frames>55 ms)4,505draws/frame,317pieces landed/frame (4.5 MBdirty 4 KiB pages,0.84 MBdwords)t=140..600s):0/230black frames,120/120clean consecutive burst frames (4 fpscontact sheets att=420–435sandt=520–535s).The AVX2 paths and
O(dirty)bookkeeping held up 100% clean in real GTA 6 gameplay!@PastiiJay on GitHub · 2026-11-26 14:49 UTC · original
Thanks @Proudnoob4, a 10-minute live oracle with zero mismatches is the strongest check this one has had, and the drop in page-finding time is a nice bonus. If you have the setup ready, the same oracle-plus-benchmark on #59 (lazy copy-back) would be the most useful next run, since it touches the same shadow path.
@Proudnoob4 on GitHub · 2026-11-26 14:58 UTC · original
@PastiiJay Sounds like a plan! We're running a 10-minute verification pass on our current batch (
fxceless#1184+#1274+#1276) right now, and right after that we'll port#59(VICTORY_LAZY_COPYBACK=1) onto our tree, run the live GTA 6 coherence/oracle + 10-minute benchmark on RTX 4080 / i5-13600K (Win10), and post the full measured results and visual check on#59.@PastiiJay on GitHub · 2026-11-26 15:18 UTC · original
Sounds good, thanks. We will watch #59 for the results; a visual check of the same scenes with and without
VICTORY_LAZY_COPYBACK=1would be the part we care about most.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.