GPU: walk only dirty gaps when refreshing guarded views #979

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

@⁠gmankab on GitHub · 2026-11-25 14:36 UTC · original
gmankab:gpu/clean-guard-intervals → main · +120 −41 · 1 files · 1 commits · open

The texture refresh path checks guarded views repeatedly, including heaps whose 64 KiB blocks are all clean. The clean-block lookup currently allocates a vector of every clean block under the guard mutex before it can find the gaps.

Store those clean blocks as half-open runs and walk their gaps. A fully clean view needs one lookup. This keeps the existing guard lock, mapping checks, alias protection and write notifications. The tests compare the runs against the per-block representation and exercise real guarded and aliased mappings.

This takes the clean-run idea from #824 into a standalone change. It applies directly to current main and does not require the other changes in that PR.

Validation

  • 13 write-watch and mapping tests passed on this branch under Wine, including the interval regression test. The equivalent canonical test branch passed all 14 tests in its write-watch module.

  • A synthetic 174 MiB lookup benchmark measured 7.6 µs to about 12 ns for an entirely clean range and 11.7 µs to about 80 ns with four gaps. These measurements cover the lookup and gap walk only.

  • A local paired RX 6800 run used the same launch settings, starting saves and caches. Both builds rendered the same prologue shot. The interval build did not show a frame-time improvement in the first 75 seconds of heavy rendering. In the first full reporting window, at similar executed draw counts (1,337 vs 1,352), the control reported 12.0 seconds per frame and the interval build 17.8 seconds. The measured time inside GetWriteWatch also varied between runs. One run per variant is insufficient to attribute the timing difference to this patch.

Based-on: #824
Tested-on: RX 6800, Fedora Linux 45, Wine/vkd3d-proton
Assisted-by: gpt-6.2 sol xhigh

**@⁠gmankab** on GitHub · 2026-11-25 14:36 UTC · [original](https://github.com/fxceless/victory-fork/pull/979) `gmankab:gpu/clean-guard-intervals` → `main` · +120 −41 · 1 files · 1 commits · open The texture refresh path checks guarded views repeatedly, including heaps whose 64 KiB blocks are all clean. The clean-block lookup currently allocates a vector of every clean block under the guard mutex before it can find the gaps. Store those clean blocks as half-open runs and walk their gaps. A fully clean view needs one lookup. This keeps the existing guard lock, mapping checks, alias protection and write notifications. The tests compare the runs against the per-block representation and exercise real guarded and aliased mappings. This takes the clean-run idea from #824 into a standalone change. It applies directly to current main and does not require the other changes in that PR. Validation - 13 write-watch and mapping tests passed on this branch under Wine, including the interval regression test. The equivalent canonical test branch passed all 14 tests in its write-watch module. - A synthetic 174 MiB lookup benchmark measured 7.6 µs to about 12 ns for an entirely clean range and 11.7 µs to about 80 ns with four gaps. These measurements cover the lookup and gap walk only. - A local paired RX 6800 run used the same launch settings, starting saves and caches. Both builds rendered the same prologue shot. The interval build did not show a frame-time improvement in the first 75 seconds of heavy rendering. In the first full reporting window, at similar executed draw counts (1,337 vs 1,352), the control reported 12.0 seconds per frame and the interval build 17.8 seconds. The measured time inside GetWriteWatch also varied between runs. One run per variant is insufficient to attribute the timing difference to this patch. Based-on: https://git.gtahub.st/github/fxceless--victory-fork/pulls/824 Tested-on: RX 6800, Fedora Linux 45, Wine/vkd3d-proton Assisted-by: gpt-6.2 sol xhigh
Repeated checks of clean view heaps collect one entry per 64 KiB block
while holding the guard mutex. If most blocks are clean, that allocates
and scans thousands of entries to find just a few dirty gaps.

Track the same clean blocks as contiguous half-open runs. The fully
clean path needs a single lookup and the mixed path visits only dirty
gaps. Keep the existing mapping queries, alias protection, and dirty
notifications. Compare the interval operations with the old per-block
representation and retain the existing guard and mapping tests.

Based-on: https://github.com/fxceless/victory-fork/pull/824
Tested-on: RX 6800, Fedora Linux 45, Wine (14 guard and mapping tests)
Assisted-by: gpt-6.2 sol xhigh
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:55:03 +00:00
Author
Owner

@⁠avt0m4t48 on GitHub · 2026-11-25 15:25 UTC · original

I ran the same release fixture at 0b0074e and ac6e475 on native Windows. All 11 existing watch tests passed on the baseline and all 12 passed on this head, each in a fresh process. The added interval oracle was among the 12.

I also exercised the full guard() call on a real 174 MiB page-file mapping. I alternated baseline, candidate, candidate, baseline on the same runner and checked the page list on every call. The table gives the two process medians per build, with nine samples per process.

View state Baseline This PR
Completely clean 10.62–10.72 µs 0.020 µs
Four changed 64 KiB blocks 19.61–19.70 µs 3.61–3.72 µs

The four-block case includes reporting and restoring protections inside guard(). Reopening the four blocks and writing into them happen outside the timer. This is a synthetic guarded-view cost on the Windows runner. The RX 6800 frame-time observation in the PR is a separate measurement.

Fixture · Windows run

**@⁠avt0m4t48** on GitHub · 2026-11-25 15:25 UTC · [original](https://github.com/fxceless/victory-fork/pull/979#issuecomment-7166831908) I ran the same release fixture at `0b0074e` and `ac6e475` on native Windows. All 11 existing watch tests passed on the baseline and all 12 passed on this head, each in a fresh process. The added interval oracle was among the 12. I also exercised the full `guard()` call on a real 174 MiB page-file mapping. I alternated baseline, candidate, candidate, baseline on the same runner and checked the page list on every call. The table gives the two process medians per build, with nine samples per process. | View state | Baseline | This PR | | --- | ---: | ---: | | Completely clean | 10.62–10.72 µs | 0.020 µs | | Four changed 64 KiB blocks | 19.61–19.70 µs | 3.61–3.72 µs | The four-block case includes reporting and restoring protections inside `guard()`. Reopening the four blocks and writing into them happen outside the timer. This is a synthetic guarded-view cost on the Windows runner. The RX 6800 frame-time observation in the PR is a separate measurement. [Fixture](https://github.com/avt0m4t48/victory-fork/commit/b826e82a654bfd0c6748c77609b4795979649f53) · [Windows run](https://github.com/avt0m4t48/victory-fork/actions/runs/45644267212)
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/979/head:github-bot/gh-979'
git switch 'github-bot/gh-979'

Merge

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