perf(gpu): optimize merge_under_writes, take_all nesting, and refresh batching #368
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: launcher
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
run report
security: hold
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs gpu test
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Androtim--MiniVI!368
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-368"
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?
@Androtim on GitHub · 2026-12-02 20:11 UTC · original
Androtim:perf/merge-under-writes-and-refresh-parallelism→main· +436 −126 · 4 files · 1 commits · merged 2026-12-02 20:35 UTC## Summary
Reduces CPU submission overhead (
lists_steps,refreshes, andmerge_under_writes) by eliminating per-page allocations and lock contention during stale write-watch merging, unlocking nested parallel range splits intake_all, and lowering parallel refresh thresholds:take_all(crates/victory-gpu/src/land.rs): AddedPool::each_or_inlineandeach_wide_sub(victory-wide-subpool) soShadow::take_all(with loweredLONG = 256 KiBandPART = 128 KiB) no longer falls back to single-threaded execution when invoked insidevictory-wide.Shadow::merge_under_writes(crates/victory-gpu/src/shadow.rs):Mutex<Option<Vec<(usize, usize)>>>buckets with at most 8MergeBucketaccumulators writing coalesced shadow-relative runs directly into flat workerVecs + bulkcard_changed_runs_slicesslice appends.PAGE_RUNS/SUB_RUNS+ reusable-bufferword_runs_into/word_runs_avx2_intoandstale_pages_taken_in_atomiclinear two-pointer scan.crate::watch::parts_writtenonce per range on regular write-watched shadows somerge_page_under_writesonly reads changed 4 KiB sub-pages (part_runs).shadow::joined.crates/victory-gpu/src/host.rs): LoweredFEWfrom256to32inBatch::refresh_frontandBatch::flush_all, andwide_refreshminimum copy count from4to2inBatch::flush_all.Plain
--releaseA/B Benchmarks (vsorigin/main@0c8200c)1440p 90s ABBA (
-PlayParity -AutoNudgeMenu -Res 1440 -WorldSeconds 90)mainA1candB1candB2mainA2preparing(med)sub_tot(med / mean)lists_steps(med / mean)refreshes(med / mean)under(merge_under_writes)card_mem(med / mean)copyback(med)4K 90s A/B (
-PlayParity -AutoNudgeMenu -Res 4k -WorldSeconds 90)mainA1candB1preparing(med)refreshes(med / mean)under(med / mean)lists_steps(med / mean)Diagnostics Visual Check
--features diagnostics1440p 90s (-PlayParity -AutoNudgeMenu): 6/6 PASS (world_windows=20, max_draws=13111, crashes=0, VRAM max=5940 MB / 6777 MB, mapped_rate=0.82 ms/s, pngs=24, lit=21/24, luma=97.46, near_black=0.09%, edge_energy=7.49, magenta=0.0%).frame-1713.png,frame-1721.png,frame-1703.png) cleanly: full world geometry, lighting, water, sky, vegetation, and textures matchmaincleanly.Verification
cargo +1.98.1-x86_64-pc-windows-gnu xtask policy(329 files ok,host.rs651,825bytes <=655,360limit)cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib --locked land::tests(8 passed; 0 failed; 1 ignored)cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib --locked shadow:: -- --test-threads=1(60 passed; 0 failed; 3 ignored)cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib --locked host::refresh_tests(5 passed; 0 failed; 2 ignored)cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --locked -- -D warnings(clean)cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics --locked -- -D warnings(clean)@Androtim on GitHub · 2026-12-02 20:35 UTC · original
Architect Review (CI
46960529881GREEN, allowlisted):shadow.rs(stale_pages_taken_in_atomiclinear two-pointer scan overBTreeMap-orderedwritten,watch::parts_writtengated strictly onself.watched == 1withu16::MAXfallback for uncopied/t == 0and non-1 watched states, flatMergeBucket+card_changed_runs_slicesboundary merging, TLSPAGE_RUNS/SUB_RUNSword_runs_into, in-placejoined),land.rs(each_wide_sub+each_or_inlinepreventing nestedvictory-wideturn-lock stalls, unit-tested), andhost.rs(FEW = 32,wide_refresh >= 2).--releaseA/B shows major CPU submission wins: 1440p ABBAsub_tot -4.15 / -4.97 ms (-12.9% / -15.3%),preparing -2.75 ms (-11.1%),refreshes -1.73 / -1.90 ms (-19.1%),merge_under_writes -44.6% / -46.4%,VRAM -81.5 MB; 4Kpreparing -2.55 ms (-12.3%),mean FPS 6.42 -> 6.68,min FPS 0.4 -> 5.4,+14,678textures uploaded (final_waiting 11,045 -> 7,416,over = 0 MB);--features diagnostics6/6 PASS,0crashes.main.