perf(shadow): batch card.dirty in merge_under_writes and binary-search skip in land_card #1400
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!1400
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1400"
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?
@qlfu on GitHub · 2026-11-28 18:59 UTC · original
qlfu:pr/merge-under-writes-perf→main· +175 −45 · 1 files · 1 commits · merged 2026-11-28 19:39 UTCSummary
Reduces lock contention, mutex overhead, and heap churn in
Shadow::merge_under_writesandShadow::land_card(crates/victory-gpu/src/shadow.rs):UnderSlots): replacesVec<Mutex<Done>>(~280 mutexes allocated, locked, and unwrapped per frame) with aSyncUnsafeCell<PageMerge>slice where each worker writes exclusively to its own indexi.word_runs_avx2: reserves128entries on first diff instead of growing0 -> 4 -> 8 -> ... -> 128across contending parallel workers (still 0 bytes allocated for unchanged pages).card.dirtylock + singlereserve(total_runs)+ minimizedself.merging.write()critical section:MERGED[0..3]once outsideself.merging.write()(eliminating hundreds of cross-core atomic RMWs).card.dirty.lock()once per busy range (instead of once per page), reservestotal_runsonce, coalesces via sharedpush_dirty_runs, swapscard.touchedonce, and dropsbeforeandself.merging.write()before updatingself.copiedand freeing the per-pageVecs.skipinShadow::land_card: mergesskiponce outsidecard.dirty/card.sentlocks and reuses a singlepartsbuffer viaoutside_sorted_into(partition_point), avoiding per-piece linear scans and tripleVecallocations.Correctness & Safety
self.merging.write()andself.before.lock()remain held from before reading title memory until bothheldandcard.dirty/card.touchedare updated (preserving exact synchronization withShadow::land_cardandShadow::card_merge_relay).copied[page - base] = now;overpages still count inMERGED[0]and triggernote_stale(2)identically tomain.relay_tests::outside_sorted_into_matches_outsideandrelay_tests::push_dirty_runs_coalesces_adjacent_and_overlapping_ranges.Verification
cargo +1.98.1-x86_64-pc-windows-msvc clippy -p victory-gpu --lib --tests --lockedand--all-features: 0 warnings in modified lines.cargo +1.98.1-x86_64-pc-windows-msvc test -p victory-gpu --lib --locked -- --test-threads=1 --quiet: 456 passed, 0 failed, 36 ignored.cargo +1.98.1-x86_64-pc-windows-msvc build --release --locked -p victory: exit0.Clean Idle-PC 90s A/B Benchmark (RTX 4070 Ti 12 GB + Ryzen 7 5700X,
-FrameGen, vsorigin/main)origin/mainunder(merge_under_writes) median6.60 ms(293.5pgs /73.5kruns)5.60 ms(276.5pgs /71.8kruns)-1.00 ms(-15.2%;-13.2%per 1k runs)undermean6.57 ms5.43 ms-1.14 ms(-17.4%)wait_under(blocked onself.merging)2.13 ms1.06 ms-1.07 ms(-50.2%)land_merge(land_card)5.10 ms4.71 ms-0.39 ms(-7.6%)land_alltotal24.75 ms21.35 ms-3.40 ms(-13.7%)sub_allmedian50.85 ms49.00 ms-1.85 ms(-3.6%)53.80 ms/18.6052.75 ms/18.95-1.05 ms/+1.9%0 / 00 / 0