GPU: compact watch page tracking with dense PageBits and inline OneOrMany storage #3229

Open
github-bot wants to merge 1 commit from github-bot/gh-3229 into main AGit
Owner

@⁠0xKaji on GitHub · 2026-11-26 13:48 UTC · original
0xKaji:perf/compact-watch-tracking → main · +253 −26 · 1 files · 1 commits · open

Summary

Compacts victory-gpu's write-watch metadata in watch.rs to eliminate per-page BTreeSet nodes and per-page heap Vec allocations when tracking hundreds of thousands of 64 KiB pages.

Changes

  • PageBits dense bitset (watch.rs): Replaces Changed.0: Mutex<BTreeSet<usize>> with a contiguous Box<[u64]> bitset relative to the tracked range's start page (1 bit per 64 KiB page = 16 bytes per MiB), with O(1) insert/remove/contains and trailing_zeros()-based range_pages.
  • OneOrMany<T> inline storage (watch.rs): Replaces Vec<Arc<Changed>> in Guards::holders and Vec<usize> in Guards::alias_of with an inline single-element enum (One(T) | Many(Vec<T>)) that spills to Vec only when a page has multiple holders/aliases and collapses back to One on retain.
  • Tracked::disarm trimming (watch.rs): Shrinks oversized Saved::armed (> 64) and Saved::bytes (> 16) capacities when disarming.

Verification

  • cargo xwin clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings
  • cargo xwin clippy --workspace --all-targets --all-features --locked --target x86_64-pc-windows-msvc -- -D warnings
  • cargo test -p xtask --locked (6/6 passed)
  • Wine watch::tests:: --test-threads=1: 17/17 passed (including page_bits_tracks_multi_word_ranges and one_or_many_spills_and_collapses).
  • Touches watch.rs in areas distinct from #3154 (alias page unprotection on last tracker drop), #3156 (take_split unmapped merge), and #3161 (transitive alias groups).
**@⁠0xKaji** on GitHub · 2026-11-26 13:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/3229) `0xKaji:perf/compact-watch-tracking` → `main` · +253 −26 · 1 files · 1 commits · open ## Summary Compacts `victory-gpu`'s write-watch metadata in `watch.rs` to eliminate per-page `BTreeSet` nodes and per-page heap `Vec` allocations when tracking hundreds of thousands of 64 KiB pages. ## Changes - **`PageBits` dense bitset (`watch.rs`):** Replaces `Changed.0: Mutex<BTreeSet<usize>>` with a contiguous `Box<[u64]>` bitset relative to the tracked range's start page (1 bit per 64 KiB page = 16 bytes per MiB), with O(1) `insert`/`remove`/`contains` and `trailing_zeros()`-based `range_pages`. - **`OneOrMany<T>` inline storage (`watch.rs`):** Replaces `Vec<Arc<Changed>>` in `Guards::holders` and `Vec<usize>` in `Guards::alias_of` with an inline single-element enum (`One(T) | Many(Vec<T>)`) that spills to `Vec` only when a page has multiple holders/aliases and collapses back to `One` on `retain`. - **`Tracked::disarm` trimming (`watch.rs`):** Shrinks oversized `Saved::armed` (> 64) and `Saved::bytes` (> 16) capacities when disarming. ## Verification - `cargo xwin clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings` - `cargo xwin clippy --workspace --all-targets --all-features --locked --target x86_64-pc-windows-msvc -- -D warnings` - `cargo test -p xtask --locked` (6/6 passed) - Wine `watch::tests:: --test-threads=1`: **17/17 passed** (including `page_bits_tracks_multi_word_ranges` and `one_or_many_spills_and_collapses`). ## Related PRs - Touches `watch.rs` in areas distinct from `#3154` (alias page unprotection on last tracker drop), `#3156` (`take_split` unmapped merge), and `#3161` (transitive alias groups).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 13:53:05 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 14:09 UTC · original · approved these changes

Verified on RTX 5090 against origin/main (63bcca4):

  • cargo test -p victory-gpu --lib watch:: -- --test-threads=1: 17/17 passed (including one_or_many_spills_and_collapses and page_bits_tracks_multi_word_ranges).
  • cargo test -p victory-gpu --lib shadow:: -- --test-threads=1: 10/10 passed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Cleanly compacts watch page tracking with dense PageBits and inline OneOrMany storage.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 14:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/3229#pullrequestreview-6075535097) · **approved these changes** Verified on RTX 5090 against `origin/main` (`63bcca4`): - `cargo test -p victory-gpu --lib watch:: -- --test-threads=1`: 17/17 passed (including `one_or_many_spills_and_collapses` and `page_bits_tracks_multi_word_ranges`). - `cargo test -p victory-gpu --lib shadow:: -- --test-threads=1`: 10/10 passed. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Cleanly compacts watch page tracking with dense `PageBits` and inline `OneOrMany` storage. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3229/head:github-bot/gh-3229'
git switch 'github-bot/gh-3229'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3229'
git switch 'github-bot/gh-3229'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3229'
git switch 'github-bot/gh-3229'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3229'
git switch 'main'
git merge --squash 'github-bot/gh-3229'
git switch 'main'
git merge --ff-only 'github-bot/gh-3229'
git switch 'main'
git merge 'github-bot/gh-3229'
git push origin 'main'
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/Marvisak--VIctory!3229
No description provided.