GPU: use RwLock read fast path for shadow::BUFFERS and batch heap_buffers defer_refreshes #1068

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

@⁠UwUCammie on GitHub · 2026-11-25 18:18 UTC · original
UwUCammie:pr/shadow-buffers-rwlock → main · +72 −11 · 3 files · 1 commits · open

All recording threads and heap_buffers contend on the global shadow::BUFFERS mutex on every shadow::find lookup, even though almost all lookups hit an already-created shadow copy. heap_buffers also locked HostList::deferred ~4,600 times per frame in its refresh loop.

  • Switches shadow::BUFFERS from Mutex to RwLock with a shared read-lock fast path in lookup() (only taking the write lock when a buffer entry has not lazily created its shadow yet).
  • Adds HostList::defer_refreshes / Shadow::refresh_many so heap_buffers records all eligible spans under a single deferred() lock.

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

  • Recording time (all threads) dropped from ~242–250 ms to ~210–220 ms/frame, heap buffers non-16th pass dropped from ~39–40 ms to ~33–36 ms, 0 GPUVM faults, picture unchanged.
**@⁠UwUCammie** on GitHub · 2026-11-25 18:18 UTC · [original](https://github.com/fxceless/victory-fork/pull/1068) `UwUCammie:pr/shadow-buffers-rwlock` → `main` · +72 −11 · 3 files · 1 commits · open All recording threads and `heap_buffers` contend on the global `shadow::BUFFERS` mutex on every `shadow::find` lookup, even though almost all lookups hit an already-created shadow copy. `heap_buffers` also locked `HostList::deferred` ~4,600 times per frame in its refresh loop. - Switches `shadow::BUFFERS` from `Mutex` to `RwLock` with a shared read-lock fast path in `lookup()` (only taking the write lock when a buffer entry has not lazily created its shadow yet). - Adds `HostList::defer_refreshes` / `Shadow::refresh_many` so `heap_buffers` records all eligible spans under a single `deferred()` lock. Tested on Linux + Wine 11.22 + RX 7900 XT (RADV, `VICTORY_RELAY=2`, 480 s run into the cell scene): - Recording time (all threads) dropped from ~242–250 ms to ~210–220 ms/frame, `heap buffers` non-16th pass dropped from ~39–40 ms to ~33–36 ms, 0 GPUVM faults, picture unchanged.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:56:59 +00:00
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/shadow.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/1068/head:github-bot/gh-1068'
git switch 'github-bot/gh-1068'

Merge

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