List threads no longer queue behind exact and loose copies being made; same page mappings are not redone #443

Open
github-bot wants to merge 2 commits from github-bot/gh-443 into a-publier AGit
Owner

@⁠wesneyalcantara-lang on GitHub · 2026-11-27 02:03 UTC · original
wesneyalcantara-lang:locks-and-same-mappings → a-publier · +119 −25 · 2 files · 2 commits · open

Two lock fixes for the list threads, and one fewer pair of mapping calls for the title's main thread. Measured on a 12 GB NVIDIA card with scripts\play.ps1 settings plus VICTORY_OUTPUT=1280x720.

What profiles showed (VICTORY_PROFILE, list threads)

before after
waiting for shadow::EXACT's mutex 20.5% ~0-3%
waiting for shadow::LOOSE's lock (with VICTORY_WINDOW_KB=256) 11-16% ~0-1%
  • exact(): every miss swept the whole map (two COM calls per copy, ~2,700 kept) and made its host buffer while holding the mutex. Now the sweep comes once the map has doubled since the last one, the buffer is made outside the lock (asked again after; a thread that made the same copy meanwhile wins), and hits take a shared lock.
  • loose(): with a finer window grid or tails, the window was chosen only under the write lock, so nearly every asking took it; and a missing window's buffers (shared_buffer, window_card_for, window_mapped_for) were made while holding it. The choice is now made under the shared lock too, and a new window is made outside the lock and put in after, the same way.
  • xmem::change(): a page asked to show the page it shows already is passed over (no unmap/map, its guards kept). VICTORY_MAP_SAME=0 restores the old behaviour; the count is in the mapping line. Not measured in the game yet: covered by a new unit test only.

Frame rate

With the lock fixes, median FPS in scenes with more than 1,500 draws went from 4.0 to 4.9 (same scene, ~3,400-3,600 draws). Single runs on one machine, not an A/B with several runs each.

12 GB cards

The card-buffer tier for 12 GB cards is a separate pull request, #444 (it gave the larger gain of the two).

Checks

cargo clippy -p victory-gpu -p victory-hle --all-targets [--all-features] --locked -- -D warnings and cargo test -p victory-gpu -p victory-hle --lib --locked pass.

🤖 Generated with Claude Code

**@⁠wesneyalcantara-lang** on GitHub · 2026-11-27 02:03 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/443) `wesneyalcantara-lang:locks-and-same-mappings` → `a-publier` · +119 −25 · 2 files · 2 commits · open Two lock fixes for the list threads, and one fewer pair of mapping calls for the title's main thread. Measured on a 12 GB NVIDIA card with `scripts\play.ps1` settings plus `VICTORY_OUTPUT=1280x720`. ### What profiles showed (`VICTORY_PROFILE`, list threads) | | before | after | |---|---|---| | waiting for `shadow::EXACT`'s mutex | 20.5% | ~0-3% | | waiting for `shadow::LOOSE`'s lock (with `VICTORY_WINDOW_KB=256`) | 11-16% | ~0-1% | - **`exact()`**: every miss swept the whole map (two COM calls per copy, ~2,700 kept) and made its host buffer while holding the mutex. Now the sweep comes once the map has doubled since the last one, the buffer is made outside the lock (asked again after; a thread that made the same copy meanwhile wins), and hits take a shared lock. - **`loose()`**: with a finer window grid or tails, the window was chosen only under the write lock, so nearly every asking took it; and a missing window's buffers (`shared_buffer`, `window_card_for`, `window_mapped_for`) were made while holding it. The choice is now made under the shared lock too, and a new window is made outside the lock and put in after, the same way. - **`xmem::change()`**: a page asked to show the page it shows already is passed over (no unmap/map, its guards kept). `VICTORY_MAP_SAME=0` restores the old behaviour; the count is in the mapping line. **Not measured in the game yet**: covered by a new unit test only. ### Frame rate With the lock fixes, median FPS in scenes with more than 1,500 draws went from 4.0 to 4.9 (same scene, ~3,400-3,600 draws). Single runs on one machine, not an A/B with several runs each. ### 12 GB cards The card-buffer tier for 12 GB cards is a separate pull request, #444 (it gave the larger gain of the two). ### Checks `cargo clippy -p victory-gpu -p victory-hle --all-targets [--all-features] --locked -- -D warnings` and `cargo test -p victory-gpu -p victory-hle --lib --locked` pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Profiles of list threads (RTX 4070 12 GB, Ryzen 7 5700X3D, 32 GB) showed
a fifth of their time waiting for EXACT's mutex and up to 16% for LOOSE's
lock:

- exact(): every miss swept the whole map (two COM calls per copy, ~2,700
  kept) and made its host buffer while holding the mutex. The sweep now
  comes once the map has doubled since the last one, the buffer is made
  without the lock (asked again after: a thread that made the same copy
  meanwhile wins), and hits take a shared lock (EXACT is an RwLock, its
  clock and each copy's last asking atomics).
- loose(): with VICTORY_WINDOW_KB below 4096 or VICTORY_WINDOW_TAILS=1 the
  window to take was chosen only under the write lock, so nearly every
  asking took it. The choice is made under the shared lock too, and a
  missing window is made without the lock and put in after, unless another
  thread put the same one in meanwhile.

Lock waits of the list threads went from ~20-28% to under 3%.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
change() passes over pages whose view of that page alone already shows
the same page of the same section: no unmap and map, which would also
make the page read-write and drop its write guards, and which queue for
the kernel's lock with the guards' protection changes. The title's main
thread spent about a third of its time in mapping calls in our profiles.
VICTORY_MAP_SAME=0 maps them again as before; the count of pages passed
over is in the mapping line. Test: the same GPU page mappings asked for
again are passed over and still alias.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 02:16:09 +00:00
Author
Owner

@⁠gw1337x on GitHub · 2026-11-27 03:29 UTC · original

Ran in the title on RDNA 3: RX 7800 XT 16 GB (driver 32.0.32015.7029), Ryzen 7 9800X3D, 32 GB RAM, Windows 11 26200 (Memory Integrity off). Diagnostics builds of 4eb6cfd with and without this PR (d52ad9f), both with a few extra timeline spans of mine around the mapping lock, same boot.

Settings: scripts/play.ps1 settings plus VICTORY_PORT_CONSTANTS/DESCRIPTORS/CBV/GUARD/JOURNAL=1, Series X profile, ray tracing off, and VICTORY_MAP_THREADS=8, so that change() and the new skip are on the path (the launcher's =1 goes through map_alias one page at a time). fps is the layer's 1 s figure from the window title, every second.

Drive: from a Chapter I boat save, throttle held from 190 s with a short right turn, 195-230 s (the boat crosses open water and reaches the mangroves under the bridge). Interleaved PR, base, PR, base:

Run Build median / mean fps lowest second seconds < 15 "held to remap" per frame (200/210/220 s windows)
1 + #443 22.5 / 22.7 18 0 / 32 9.0 / 8.8 / 1.4 ms
2 4eb6cfd 24.0 / 24.1 13 1 / 33 5.9 / 4.3 / 0.9 ms
3 + #443 23.0 / 23.2 19 0 / 33 3.4 / 9.0 / 4.0 ms
4 4eb6cfd 24.5 / 24.3 19 0 / 32 5.3 / 4.0 / 0.1 ms

Hands-off from the same save (270 s), seconds under 15 fps during the cutscenes and scene loads (60-190 s): 13 and 14 with the PR, 15 and 15 without it (earlier in the same hour); steady 28-29 fps for both.

No measurable change in this scene, no problems (no device loss, peak commit 33.4-34.0 GB for both). One caveat: I could not confirm the skip fired, because the "passed over so far" count is only logged when VICTORY_MAP_THREADS is unset (asked_threads().is_none()), and these runs set it to 8.

**@⁠gw1337x** on GitHub · 2026-11-27 03:29 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/443#issuecomment-7209031778) Ran in the title on RDNA 3: RX 7800 XT 16 GB (driver 32.0.32015.7029), Ryzen 7 9800X3D, 32 GB RAM, Windows 11 26200 (Memory Integrity off). Diagnostics builds of `4eb6cfd` with and without this PR (`d52ad9f`), both with a few extra timeline spans of mine around the mapping lock, same boot. Settings: `scripts/play.ps1` settings plus `VICTORY_PORT_CONSTANTS/DESCRIPTORS/CBV/GUARD/JOURNAL=1`, Series X profile, ray tracing off, and `VICTORY_MAP_THREADS=8`, so that `change()` and the new skip are on the path (the launcher's `=1` goes through `map_alias` one page at a time). fps is the layer's 1 s figure from the window title, every second. Drive: from a Chapter I boat save, throttle held from 190 s with a short right turn, 195-230 s (the boat crosses open water and reaches the mangroves under the bridge). Interleaved PR, base, PR, base: | Run | Build | median / mean fps | lowest second | seconds < 15 | "held to remap" per frame (200/210/220 s windows) | |---|---|---|---|---|---| | 1 | + #443 | 22.5 / 22.7 | 18 | 0 / 32 | 9.0 / 8.8 / 1.4 ms | | 2 | `4eb6cfd` | 24.0 / 24.1 | 13 | 1 / 33 | 5.9 / 4.3 / 0.9 ms | | 3 | + #443 | 23.0 / 23.2 | 19 | 0 / 33 | 3.4 / 9.0 / 4.0 ms | | 4 | `4eb6cfd` | 24.5 / 24.3 | 19 | 0 / 32 | 5.3 / 4.0 / 0.1 ms | Hands-off from the same save (270 s), seconds under 15 fps during the cutscenes and scene loads (60-190 s): 13 and 14 with the PR, 15 and 15 without it (earlier in the same hour); steady 28-29 fps for both. No measurable change in this scene, no problems (no device loss, peak commit 33.4-34.0 GB for both). One caveat: I could not confirm the skip fired, because the "passed over so far" count is only logged when `VICTORY_MAP_THREADS` is unset (`asked_threads().is_none()`), and these runs set it to 8.
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-27 03:55 UTC · original

Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At d52ad9f: cargo test --release -p victory-gpu --lib 396 passed, 0 failed, 34 ignored; victory-hle 162 passed, 0 failed, 2 ignored.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-27 03:55 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/443#issuecomment-7209383042) Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At `d52ad9f`: `cargo test --release -p victory-gpu --lib` 396 passed, 0 failed, 34 ignored; `victory-hle` 162 passed, 0 failed, 2 ignored. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠Robotniq on GitHub · 2026-11-27 09:01 UTC · original

Tested in the title on an 8 GB NVIDIA card: RTX 3070 Ti (8 GB, driver 32.0.16.2140), i7-13700F, 32 GB RAM, Windows 11 26200. Diagnostics build of 4eb6cfd with and without this PR, --console series-s, the scripts\play.ps1 settings (not -Safe), VICTORY_PORT_CONSTANTS/DESCRIPTORS/CBV/GUARD/JOURNAL=1, VICTORY_D3D12_DRED=faults, ray tracing off. Same save, about six minutes in the prologue's first area per run, warm pipeline library.

Frame rate by draws a frame (median of the frame lines in each band):

draws a frame 4eb6cfd with this PR
2,000-3,500 7.0 fps 8.3 fps
3,500-5,000 4.7 fps 6.7 fps
5,000-7,000 3.8 fps 5.7 fps

List calls (VICTORY_THIN, median over the frame lines at 20,000 calls or more): 37.2 µs a call before, 14.3 µs with this PR (about 1,700 ms a frame over the eight threads down to about 340 ms at 36,000-38,000 calls).

VICTORY_PROFILE over 90 s, the eight victory-list threads:

4eb6cfd with this PR
Mutex::lock_contended <- shadow::exact 69.5% 0%
RwLock::read_contended <- shadow::exact - 12.0%
RwLock::write_contended <- shadow::exact - 5.9%
MakeResident <- shared_buffer <- shadow::exact 2.4% 12.8%
idle (Condvar::wait in thin::start) 11.4% 43.4%

The frame line there reads about 230 copies of views' own bytes made a frame with 3,600 kept (1,500 asked for), so on this card what is left in exact is the making of the buffers itself (#451's ground). With the PR the card is the limit here (about 80% busy by the card's clock line, 40% before).

No device loss and nothing in crashes.log in either run with the PR. I did not test VICTORY_WINDOW_KB=256, so nothing here speaks for the loose half.

AI-assisted (Claude Code): the runs, the profile reading and this text.

**@⁠Robotniq** on GitHub · 2026-11-27 09:01 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/443#issuecomment-7214198193) Tested in the title on an 8 GB NVIDIA card: RTX 3070 Ti (8 GB, driver 32.0.16.2140), i7-13700F, 32 GB RAM, Windows 11 26200. Diagnostics build of `4eb6cfd` with and without this PR, `--console series-s`, the `scripts\play.ps1` settings (not `-Safe`), `VICTORY_PORT_CONSTANTS/DESCRIPTORS/CBV/GUARD/JOURNAL=1`, `VICTORY_D3D12_DRED=faults`, ray tracing off. Same save, about six minutes in the prologue's first area per run, warm pipeline library. Frame rate by draws a frame (median of the frame lines in each band): | draws a frame | `4eb6cfd` | with this PR | |---|---:|---:| | 2,000-3,500 | 7.0 fps | 8.3 fps | | 3,500-5,000 | 4.7 fps | 6.7 fps | | 5,000-7,000 | 3.8 fps | 5.7 fps | List calls (`VICTORY_THIN`, median over the frame lines at 20,000 calls or more): 37.2 µs a call before, 14.3 µs with this PR (about 1,700 ms a frame over the eight threads down to about 340 ms at 36,000-38,000 calls). `VICTORY_PROFILE` over 90 s, the eight `victory-list` threads: | | `4eb6cfd` | with this PR | |---|---:|---:| | `Mutex::lock_contended` <- `shadow::exact` | 69.5% | 0% | | `RwLock::read_contended` <- `shadow::exact` | - | 12.0% | | `RwLock::write_contended` <- `shadow::exact` | - | 5.9% | | `MakeResident` <- `shared_buffer` <- `shadow::exact` | 2.4% | 12.8% | | idle (`Condvar::wait` in `thin::start`) | 11.4% | 43.4% | The frame line there reads about 230 copies of views' own bytes made a frame with 3,600 kept (1,500 asked for), so on this card what is left in `exact` is the making of the buffers itself (#451's ground). With the PR the card is the limit here (about 80% busy by the card's clock line, 40% before). No device loss and nothing in `crashes.log` in either run with the PR. I did not test `VICTORY_WINDOW_KB=256`, so nothing here speaks for the `loose` half. AI-assisted (Claude Code): the runs, the profile reading and this text.
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/443/head:github-bot/gh-443'
git switch 'github-bot/gh-443'

Merge

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