gpu(watch,shadow): coalesce consecutive dirty 4 KiB page parts via part_runs #257

Manually merged
github merged 1 commit from gh-pr/257/head into gh-pr/257/base 2026-12-01 20:23:29 +00:00
Owner

@⁠Androtim on GitHub · 2026-11-30 13:37 UTC · original
Androtim:feat/iter251-watch-shadow-coalesce-part-runs → main · +43 −8 · 2 files · 1 commits · merged 2026-11-30 14:04 UTC

Summary

  • Extract watch::part_runs(parts: u16) to iterate consecutive dirty 4 KiB sub-page runs within each 64 KiB page directly as coalesced [first, end) ranges.
  • Replace both the per-bit by_parts loop in crates/victory-gpu/src/shadow.rs (avoiding adjacent range merge overhead for consecutive dirty 4 KiB parts) and the duplicate bit-scanning loop in Tracked in crates/victory-gpu/src/watch.rs.
  • Add exhaustive unit test part_runs_cover_exactly_the_written_parts covering all 0..=u16::MAX part masks.

Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu run -p xtask -- policy -> asset policy: 313 files ok
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib watch:: -- --test-threads=1 -> 53 passed; 0 failed
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib shadow:: -- --test-threads=1 -> 47 passed; 0 failed; 3 ignored
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings -> clean
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics -- -D warnings -> clean
**@⁠Androtim** on GitHub · 2026-11-30 13:37 UTC · [original](https://github.com/Androtim/MiniVI/pull/257) `Androtim:feat/iter251-watch-shadow-coalesce-part-runs` → `main` · +43 −8 · 2 files · 1 commits · merged 2026-11-30 14:04 UTC ## Summary - Extract `watch::part_runs(parts: u16)` to iterate consecutive dirty 4 KiB sub-page runs within each 64 KiB page directly as coalesced `[first, end)` ranges. - Replace both the per-bit `by_parts` loop in `crates/victory-gpu/src/shadow.rs` (avoiding adjacent range merge overhead for consecutive dirty 4 KiB parts) and the duplicate bit-scanning loop in `Tracked` in `crates/victory-gpu/src/watch.rs`. - Add exhaustive unit test `part_runs_cover_exactly_the_written_parts` covering all `0..=u16::MAX` part masks. ## Verification - `cargo +1.98.1-x86_64-pc-windows-gnu run -p xtask -- policy` -> `asset policy: 313 files ok` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib watch:: -- --test-threads=1` -> `53 passed; 0 failed` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib shadow:: -- --test-threads=1` -> `47 passed; 0 failed; 3 ignored` - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings` -> clean - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics -- -D warnings` -> clean
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 20:23:26 +00:00
github manually merged commit d7a3c5da98 into gh-pr/257/base 2026-12-01 20:23:29 +00:00
Author
Owner

@⁠Androtim on GitHub · 2026-11-30 14:02 UTC · original

Automated triage for the maintainers (not an approval).

Verdict: merge-candidate · CI (check): passing

Summary

Clean, self-contained refactor extracting watch::part_runs(parts: u16) to iterate maximal contiguous 4 KiB dirty sub-page runs within a 64 KiB page and reusing it in both shadow::by_parts and watch::Tracked::take.

Code Review

  • crates/victory-gpu/src/watch.rs (part_runs, Tracked::take):
    • Widening parts: u16 to u32 guarantees bits 16..32 stay 0, so first <= 15, end <= 16, and u32::MAX << end is always in-bounds without needing the previous if past >= PARTS / past.min(PARTS) guards.
    • The single-bit fast path (shifted & 2 == 0 with remaining &= remaining - 1) and multi-bit path (shifted.trailing_ones()) cover all cases cleanly.
    • parts_tests::part_runs_cover_exactly_the_written_parts exhaustively verifies all 0..=u16::MAX masks for bounds (first < end <= PARTS), strict non-adjacency/ordering (previous_end < first), and exact bit reconstruction.
  • crates/victory-gpu/src/shadow.rs (by_parts):
    • Replacing the per-bit (0..16).filter(...) loop with crate::watch::part_runs(parts) produces identical clipped [a, b) intervals while avoiding redundant intra-page merges; cross-page coalescing via out.last_mut() is preserved.
  • Scope & overlap note: PR #177 also includes part_runs coalescing as part of a larger bundle; PR #257 isolates just this helper cleanly on main.

Verdict

merge-candidate — CI is passing, the transformation is mathematically equivalent across all 65,536 u16 masks (exhaustively unit-tested), and it does not alter GPU/D3D12/shader behavior, so no local GPU smoke test is required.


Generated with Antigravity CLI (agy).

**@⁠Androtim** on GitHub · 2026-11-30 14:02 UTC · [original](https://github.com/Androtim/MiniVI/pull/257#issuecomment-7280754630) <!-- minivi-triage v1 head=d7a3c5da98b16177da1a657aa841c86e6f831caa verdict=merge-candidate ci=passing at=2026-11-30T14:03:29Z --> Automated triage for the maintainers (not an approval). **Verdict:** `merge-candidate` · **CI (`check`):** `passing` ### Summary Clean, self-contained refactor extracting `watch::part_runs(parts: u16)` to iterate maximal contiguous 4 KiB dirty sub-page runs within a 64 KiB page and reusing it in both `shadow::by_parts` and `watch::Tracked::take`. ### Code Review - **`crates/victory-gpu/src/watch.rs` (`part_runs`, `Tracked::take`)**: - Widening `parts: u16` to `u32` guarantees bits `16..32` stay `0`, so `first <= 15`, `end <= 16`, and `u32::MAX << end` is always in-bounds without needing the previous `if past >= PARTS` / `past.min(PARTS)` guards. - The single-bit fast path (`shifted & 2 == 0` with `remaining &= remaining - 1`) and multi-bit path (`shifted.trailing_ones()`) cover all cases cleanly. - `parts_tests::part_runs_cover_exactly_the_written_parts` exhaustively verifies all `0..=u16::MAX` masks for bounds (`first < end <= PARTS`), strict non-adjacency/ordering (`previous_end < first`), and exact bit reconstruction. - **`crates/victory-gpu/src/shadow.rs` (`by_parts`)**: - Replacing the per-bit `(0..16).filter(...)` loop with `crate::watch::part_runs(parts)` produces identical clipped `[a, b)` intervals while avoiding redundant intra-page merges; cross-page coalescing via `out.last_mut()` is preserved. - **Scope & overlap note**: PR #177 also includes `part_runs` coalescing as part of a larger bundle; PR #257 isolates just this helper cleanly on `main`. ### Verdict `merge-candidate` — CI is passing, the transformation is mathematically equivalent across all 65,536 `u16` masks (exhaustively unit-tested), and it does not alter GPU/D3D12/shader behavior, so no local GPU smoke test is required. --- _Generated with Antigravity CLI (`agy`)._
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Androtim--MiniVI!257
No description provided.