perf(gpu/watch): stripe GUARDS mutex 64 ways by 4 MiB address region #287
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!287
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/287/head"
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-01 14:43 UTC · original
Androtim:perf/watch-striped-guards-64→main· +945 −343 · 1 files · 1 commits · merged 2026-12-01 15:20 UTCReplaces the single global
GUARDSmutex and globalOPENEDqueue incrates/victory-gpu/src/watch.rswith 64 cache-line-padded address-striped shards (default-on, kill-switchVICTORY_GUARD_SHARDS=0), removing the 35–52 ms/frame cross-thread contention wall betweenguard(),publish(),opened_for_writing(), andlandworkers.Summary of Changes (
crates/victory-gpu/src/watch.rs)GuardShard): Maps each 64 KiB block via(block >> 6) & 63so every stripe aligns exactly with one 64-bit word ofBlocks. Each#[repr(align(64))] GuardShardowns its ownGuardsstate, per-shardopenedsettle queue,to_settleatomic, and diagnosticsholder.open_unlockedfaults queue and settle strictly on their own shard; rare multi-stripe aliased faults spill toCROSS_OPENED/settle_cross()(serialized cleanly viaCROSS_SETTLEbefore any shard lock).ShardSetlocking: Multi-shard operations lock shards in strictly ascending0..64order and use single-snapshotsnapshot_open_aliases/open_resolved_withso concurrentinplaceview mappings cannot add an un-locked shard between mask discovery and opening.guard(): Locks one 4 MiB shard at a time in Pass 1 (clean check + absent collection) and Pass 3 (per-word dirty protect + inline same-shard alias cover; rare cross-shard aliases clearcleanimmediately and resolve atomically in ascending order).sharded_guards_do_not_block_distinct_stripesandcross_stripe_alias_settle_and_open_preserve_invariants.Verification
cargo +1.98.1-x86_64-pc-windows-gnu xtask policy: 317 files okcargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --locked watch:: -- --test-threads=1: 55/55 PASScargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --locked --features diagnostics lock_holders_attributes_contended_guards_waits -- --test-threads=1: 1/1 PASSclippy --workspace --all-targets --locked -- -D warnings(default +--features diagnostics): PASS (0 warnings)Real-GPU Verification (RTX 4060 Ti 8 GB / Series X
-PlayParity, 1440p + DLSS Quality, FG off, RT off)Plain
--release60s A/B (NO--features diagnostics, Draw-Matched Outdoor6.5k–7.8kDraws)main(6.7k–7.0kdraws)r1(6.5k–6.9k)r2(7.4k–7.8k)refresheslandguards (13kspike)e4310834)final_waiting)room_false=0%)room_false=10%)90s
--features diagnosticsLock Telemetry & Visual InspectionGUARDScontention (waits for the guards' lock per frame): dropped ~94%, from 127–138 waits / 35.00–52.19 ms onmaindown to 44–48 waits / 1.82–3.22 ms!ear_black = 0.83%, edge_energy = 5.31, magenta = 0.0%, ailed = 0), crashes = 0, over = 0 MB. Visually inspected world PNGs (rame-2785.png, rame-2833.png).
@Androtim on GitHub · 2026-12-01 15:07 UTC · original
Automated triage for the maintainers (not an approval).
Verdict:
needs-gpu-test· CI (check):passingReview Summary (
crates/victory-gpu/src/watch.rs)Logic, concurrency invariants, and scoping look solid, and CI is passing. Because this changes the core CPU→GPU dirty-page guard and fault-settling path under multi-threaded rendering load, this warrants a local real-GPU smoke test before merging.
What Was Verified
GuardShard,GUARD_SHARDS_TABLE,guard_stripe,range_mask): 64 cache-line-aligned shards map(block >> 6) & 63to align 1:1 withBlocksu64words (4 MiB per stripe).VICTORY_GUARD_SHARDS=0cleanly collapses all operations onto shard0.ShardSet::lock_raw_mask,lock_shards,lock_shards_timed) lock shards in strictly ascending0..64order.settle_cross()is only called with no shard locks held, serializes viaCROSS_SETTLE, and releasesCROSS_OPENEDbefore acquiring shard locks.CROSS_OPENEDand per-shardopenedare strictly leaf locks, andto_settle/CROSS_TO_SETTLEresets occur inside their respective mutexes, avoiding lost-wakeup races.snapshot_open_aliases,open_resolved_with,cover_in_shard,cross_covers):inplace::pages_ofonce per range under the currentShardSetand retry with the union mask if any alias lies outside the locked set, preventing concurrent mappings from introducing unlocked shards mid-open.guard()Pass 3 keeps cross-shard aliased blocks out ofg.cleanuntilcross_coversacquires the unionShardSet, protects all aliases, and re-checksprotected,!BESIDE, and!unsettledbefore marking clean.publish()re-verifiesg.clean/g.heldper shard, so Pass 1's per-shard clean scan cannot cause a concurrently opened block to be falsely published.watch::tests are cleanly migrated to shard helpers, andsharded_guards_do_not_block_distinct_stripes+cross_stripe_alias_settle_and_open_preserve_invariantscover distinct-stripe concurrency and cross-stripe settle invariants.Minor Non-Blocking Note
guard()Pass 1 (for s in BitsOf(range_mask(first, last))), the innerfor w in w_first..w_lastiterates all words for every shard in the mask and skips mismatches viaif guard_stripe(w * 64) != s { continue; }. SteppingwbyGUARD_SHARDSfrom the first word matchingswould avoid redundant iterations on wide ranges.(Independent automated triage review — not formal maintainer approval.)
Generated with Antigravity CLI (
agy).@Androtim on GitHub · 2026-12-01 15:20 UTC · original
Architect & Strict-Gate Review (
78606152, CI passing,minivi-triageconcurrency/deadlock/alias-coherency review verified, zero file overlap with#286):Landmark Pillar #2 structural win — default-on 64-way address-striped
GUARDS(VICTORY_GUARD_SHARDS=0kill-switch only, zero opt-in toggles):GUARDScontention (90s diag):-94%(35.00–52.19 ms->1.82–3.22 ms/frame)--release60s A/B (6.5k–7.8kdraws vs10.9 fps/38.4 msprep /10,459waiting):17.35 fps (+59.2%)(r1,6.5k–6.9kdraws) and14.3 fps (+31.2%)(r2,7.4k–7.8kdraws)28.2 ms (-10.2 ms)(r1) and26.8 ms (-11.6 ms)(r2)final_waiting):1,315(-87%) /5,580(-47%)over = 0 MBon both runs (6,069 / 5,991 MB),0crashes/DRED,55/55watch::tests pass--features diagnosticslate in-world PNGs directly verified crisp and clean (lit=24/24,near_black=0.83%,magenta=0.0%).Squash-merging into
main.