perf(victory-gpu): coalesce heap_twin write-watch queries, batch ahead syncs, and defer heap_marks floor sampling #12
No reviewers
Labels
No labels
accessibility
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/MahanYTT--VIctory-MA!12
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-12"
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?
@MahanYTT on GitHub · 2026-12-04 18:27 UTC · original
MahanYTT:perf/heap-twin-watch→mega-upgrade-v3· +395 −104 · 2 files · 1 commits · merged 2026-12-04 20:18 UTCRoot Cause
From
victory-ma-play-20261204-165800-18832.log:heap_twin: 1.0 syncs (16.0 left out, covered), 2,229 parts of 4 KiB copied (8.7 MB), 0.09 ms copy (1.88 ms asking the write watch!); ahead: 8.1 syncs, 2.49 ms.GetWriteWatchcalls:pieces()split on every unused 2 MiB chunk andsync()forced 32 MiB (PIECE = 16) splits wheneverneeded != 0orours(andcan_join()checked all chunks including unused0-epoch chunks), multiplyingGetWriteWatch(WRITE_WATCH_FLAG_RESET)kernel calls (30–70 µs fixed cost each) and contending on Windows kernel address-space locks.aheadthread:ahead()woke and ran a full-heap write-watch scan on everytitle_submitsburst (8.1 syncs/frame, 2.49 ms/frame), did not clearOURSunderSYNC_LOCK, andtitle_submitslockedWAKE.0on every title submission.note_used()executed an unconditionalused.swap(true, SeqCst)on every CBV/draw lookup even when chunks were already marked used.heap_markslock acquisitions:heap_marks::prep_wrote()calleddescriptor::round_mark()(lockingSYNC_ROUNDS.0) andPREP_FLOOR.fetch_max()on everyStep::Placed/Step::Run/flush_copyduring submission prep.Changes
crates/victory-gpu/src/heap_twin.rs:GAP_CHUNKS = 4, 8 MiB, matchingwatch::AHEAD_GAP) incoalesced_pieces()and query full coalesced runs with automatic fallback to(Some(PIECE), 0)if the kernel refuses a wide range.(page, write_epoch)entries per chunk (filter_written()+copy_runs_used()+advance_used()) so bridged unused gaps keepafter == 0and mixed-epoch chunks never replay older CPU writes over shader data, while skippingparts_written()and extra allocations when no pages changed.title_submitsbursts inahead()(AHEAD_BATCH = 4,AHEAD_COALESCE_US = 1500, tunable viaVICTORY_TWIN_AHEAD_BATCH/VICTORY_TWIN_AHEAD_COALESCE_US), handle/clearOURSunderSYNC_LOCK, and gateWAKE.0locking intitle_submitsviaAHEAD_WAKE_SEQ.note_used()with a read-onlyRelaxedcheck beforeswap(true, SeqCst).crates/victory-gpu/src/heap_marks.rs:round_mark()lock acquisition inprep_wrote()with aPREP_DIRTYflag flushed once atset_mark(0)(after all submission writes complete) orneeded(), avoiding repeatedSYNC_ROUNDSmutex locks per submission.round_afteroverflow-safe (saturating_sub/saturating_add).Verification
clippy-driver --edition=2024 --crate-type=lib -D warningsand--test -D warnings: 0 warnings, 0 errors.coalesced_pieces,filter_written,advance_used,ahead_action, andprep_dirty_coalesces_floor_samples).