perf(gpu): 64-way striped Shadow::merging, wide_each, and zero-alloc watch::writes_since #21

Closed
github-bot wants to merge 1 commit from gh-pr/21/head into gh-pr/21/base
Owner

@⁠justadudeinbulgaria on GitHub · 2026-11-30 23:19 UTC · original
justadudeinbulgaria:pr/shadow-striped-merge-and-watch-fastpaths → main · +307 −52 · 3 files · 1 commits · closed without merging

Summary

Reduces lock contention and per-refresh heap allocations on the shadow buffer and write-watch hot paths (cleanly disjoint from PR #11 PATCHED_CARDS):

  • crates/victory-gpu/src/shadow.rs:
    • Replaces whole-buffer Shadow::merging RwLock with 64-way striped locks (16 KiB stripes) and a zero-array single-stripe MergeReadGuard/MergeWriteGuard enum so victory-submit and victory-relay no longer block on disjoint ranges of large buffers.
    • Adds non-straggler wide_each work-stealing dispatch (with a helpers == 0 inline guard), Shadow::all_copied atomic mirror, bit-run coalescing in by_parts, and compiler_fence + Acquire ordering on FOUND.
  • crates/victory-gpu/src/watch.rs & crates/victory-gpu/src/texture.rs:
    • Adds zero-allocation watch::writes_since (Notes::any_since + Held::any_since) wired into Staging::refresh_timed so clean texture refreshes avoid allocating a Vec<(usize, u64)> on every check.
    • Adds watch::asking_stands() early skip before sorting/allocating ranges in ask_ahead_held and all_copied pre-lock check in watch::nothing_new.

Verification

  • Unit tests: cargo test --release -p victory-gpu --lib shadow:: (39/39 passed) and cargo test --release -p victory-gpu --lib watch::tests:: -- --test-threads=1 (31/31 passed).
  • Live verified on RTX 2060 SUPER 8 GB + i5-10600K (6,900-draw open world, clean visuals).
**@⁠justadudeinbulgaria** on GitHub · 2026-11-30 23:19 UTC · [original](https://github.com/ToLIManl/VIctory-Hydra/pull/21) `justadudeinbulgaria:pr/shadow-striped-merge-and-watch-fastpaths` → `main` · +307 −52 · 3 files · 1 commits · closed without merging ## Summary Reduces lock contention and per-refresh heap allocations on the shadow buffer and write-watch hot paths (cleanly disjoint from PR #11 `PATCHED_CARDS`): - **`crates/victory-gpu/src/shadow.rs`:** - Replaces whole-buffer `Shadow::merging` `RwLock` with 64-way striped locks (16 KiB stripes) and a zero-array single-stripe `MergeReadGuard`/`MergeWriteGuard` enum so `victory-submit` and `victory-relay` no longer block on disjoint ranges of large buffers. - Adds non-straggler `wide_each` work-stealing dispatch (with a `helpers == 0` inline guard), `Shadow::all_copied` atomic mirror, bit-run coalescing in `by_parts`, and `compiler_fence` + `Acquire` ordering on `FOUND`. - **`crates/victory-gpu/src/watch.rs` & `crates/victory-gpu/src/texture.rs`:** - Adds zero-allocation `watch::writes_since` (`Notes::any_since` + `Held::any_since`) wired into `Staging::refresh_timed` so clean texture refreshes avoid allocating a `Vec<(usize, u64)>` on every check. - Adds `watch::asking_stands()` early skip before sorting/allocating ranges in `ask_ahead_held` and `all_copied` pre-lock check in `watch::nothing_new`. ## Verification - Unit tests: `cargo test --release -p victory-gpu --lib shadow::` (39/39 passed) and `cargo test --release -p victory-gpu --lib watch::tests:: -- --test-threads=1` (31/31 passed). - Live verified on RTX 2060 SUPER 8 GB + i5-10600K (`6,900`-draw open world, clean visuals).
Eliminate hot shadow/watch lock contention and per-refresh allocations across submission, relay landing, and texture refresh:

- shadow.rs: replace whole-buffer Shadow::merging RwLock with 64-way striped locks (16 KiB stripes) and zero-array single-stripe MergeReadGuard/MergeWriteGuard enum; add non-straggler wide_each (with helpers == 0 inline guard), Shadow::all_copied atomic mirror, bit-run coalescing in by_parts, and FOUND compiler_fence + Acquire.
- watch.rs & texture.rs: add zero-allocation watch::writes_since (Notes::any_since + Held::any_since) wired into Staging::refresh_timed, watch::asking_stands() early skip before sorting/allocating ranges in ask_ahead_held, and all_copied pre-lock check in watch::nothing_new.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 17:09:00 +00:00
github-bot closed this pull request 2026-12-02 17:09:00 +00:00
Author
Owner

@⁠ToLIManl on GitHub · 2026-12-01 00:48 UTC · original

Integrated into \main\ in commit \64f4cb9\ (with \Co-authored-by\ attribution; removed the unused \sking_stands\ helper in \watch.rs\ to keep release builds warning-free).

Live A/B on RTX 3060 12 GB confirmed clear gains over the same PR batch without #21: \mean_fps=15.94\ vs \14.41\ (+10.6%), \median_fps=16.36\ vs \15.31, \p99_ms=90.7\ vs \160.2\ (-43%), \vg_tex_ms=0.26\ vs \

**@⁠ToLIManl** on GitHub · 2026-12-01 00:48 UTC · [original](https://github.com/ToLIManl/VIctory-Hydra/pull/21#issuecomment-7296752613) Integrated into \main\ in commit \64f4cb9\ (with \Co-authored-by\ attribution; removed the unused \sking_stands\ helper in \watch.rs\ to keep release builds warning-free). Live A/B on RTX 3060 12 GB confirmed clear gains over the same PR batch without #21: \mean_fps=15.94\ vs \14.41\ (+10.6%), \median_fps=16.36\ vs \15.31\, \p99_ms=90.7\ vs \160.2\ (-43%), \vg_tex_ms=0.26\ vs \

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.