GPU: store watch protected/clean guards as coalesced BlockRuns intervals #1067

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

@⁠UwUCammie on GitHub · 2026-11-25 18:18 UTC · original
UwUCammie:pr/watch-block-runs → main · +295 −76 · 1 files · 1 commits · open

Guards.protected and Guards.clean in watch.rs were BTreeSet<usize> holding one entry per 64 KiB block. Each watch::guard() call allocated a Vec<usize> over g.clean.range(first..last) (up to ~150k blocks/frame across ~10 GB of view memory), locked GUARDS twice, and walked every block in first..=last whenever any block in a range was dirty.

  • Replaces protected and clean with BlockRuns (BTreeMap<usize, usize> storing maximal disjoint [start, end) block intervals).
  • Single-lock O(log runs) g.clean.covers(first, last) fast path in guard() with zero allocation when a range is clean, and walks only g.clean.missing_runs(first, last) gaps when blocks are dirty (with install() hoisted above the lock to avoid VEH lock-order inversion).
  • open_here() uses take_runs() to remove and VirtualProtect contiguous runs directly (falling back per-block if a run spans regions).
  • Adds unit test block_runs_intervals_merge_split_and_query.

Tested on Linux + Wine 11.22 + RX 7900 XT (RADV, VICTORY_RELAY=2, 480 s run into the cell scene):

  • watches dropped from ~21.2 ms to ~16.8 ms/frame (guards 17.3 -> 13.4 ms/frame), 0 GPUVM faults, picture unchanged
  • All 12 watch::tests pass under Wine.
**@⁠UwUCammie** on GitHub · 2026-11-25 18:18 UTC · [original](https://github.com/fxceless/victory-fork/pull/1067) `UwUCammie:pr/watch-block-runs` → `main` · +295 −76 · 1 files · 1 commits · open `Guards.protected` and `Guards.clean` in `watch.rs` were `BTreeSet<usize>` holding one entry per 64 KiB block. Each `watch::guard()` call allocated a `Vec<usize>` over `g.clean.range(first..last)` (up to ~150k blocks/frame across ~10 GB of view memory), locked `GUARDS` twice, and walked every block in `first..=last` whenever any block in a range was dirty. - Replaces `protected` and `clean` with `BlockRuns` (`BTreeMap<usize, usize>` storing maximal disjoint `[start, end)` block intervals). - Single-lock O(log runs) `g.clean.covers(first, last)` fast path in `guard()` with zero allocation when a range is clean, and walks only `g.clean.missing_runs(first, last)` gaps when blocks are dirty (with `install()` hoisted above the lock to avoid VEH lock-order inversion). - `open_here()` uses `take_runs()` to remove and `VirtualProtect` contiguous runs directly (falling back per-block if a run spans regions). - Adds unit test `block_runs_intervals_merge_split_and_query`. Tested on Linux + Wine 11.22 + RX 7900 XT (RADV, `VICTORY_RELAY=2`, 480 s run into the cell scene): - `watches` dropped from ~21.2 ms to ~16.8 ms/frame (`guards` 17.3 -> 13.4 ms/frame), 0 GPUVM faults, picture unchanged - All 12 `watch::tests` pass under Wine.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:56:58 +00:00
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/watch.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1067'
git switch 'github-bot/gh-1067'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1067'
git switch 'github-bot/gh-1067'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1067'
git switch 'main'
git merge --squash 'github-bot/gh-1067'
git switch 'main'
git merge --ff-only 'github-bot/gh-1067'
git switch 'main'
git merge 'github-bot/gh-1067'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.