Skip to content

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

Open
gmankab wants to merge 1 commit into
fxceless:mainfrom
gmankab:gpu/clean-guard-intervals
Open

gmankab wants to merge 1 commit into
fxceless:mainfrom
gmankab:gpu/clean-guard-intervals

Conversation

@gmankab

@gmankab gmankab commented Nov 25, 2026 •

Copy link
Copy Markdown

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

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: fxceless#824
Tested-on: RX 6800, Fedora Linux 45, Wine (14 guard and mapping tests)
Assisted-by: gpt-6.2 sol xhigh
@avt0m4t48

Copy link
Copy Markdown

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

soldsawn added a commit to soldsawn/victory-nvidia-8gb that referenced this pull request Nov 25, 2026
zsy-miao pushed a commit to zsy-miao/VI-BR-PORT that referenced this pull request Nov 25, 2026
wolfattack199 pushed a commit to wolfattack199/victory-fork that referenced this pull request Nov 25, 2026
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: fxceless#824
Tested-on: RX 6800, Fedora Linux 45, Wine (14 guard and mapping tests)
Assisted-by: gpt-6.2 sol xhigh

(pull request fxceless#979, fitted to this tree: the asking whether a range is held,
and the notes of writes through other views, use the runs as well)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants