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

Open
wesneyalcantara-lang wants to merge 2 commits from upstream-pr/443 into a-publier
wesneyalcantara-lang commented 2026-11-27 02:03:30 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by wesneyalcantara-lang on 2026-11-27T02:03:30Z.


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

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:issue:5519913923 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/443). Originally posted by [wesneyalcantara-lang](https://github.com/wesneyalcantara-lang) on 2026-11-27T02:03:30Z. --- 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)
gw1337x commented 2026-11-27 03:29:37 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by gw1337x on 2026-11-27T03:29:37Z.


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.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:comment:7209031778 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/443#issuecomment-7209031778). Originally posted by [gw1337x](https://github.com/gw1337x) on 2026-11-27T03:29:37Z. --- 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.
MamaLeVrai commented 2026-11-27 03:55:49 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by MamaLeVrai on 2026-11-27T03:55:49Z.


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.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:comment:7209383042 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/443#issuecomment-7209383042). Originally posted by [MamaLeVrai](https://github.com/MamaLeVrai) on 2026-11-27T03:55:49Z. --- 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.
euleron7 commented 2026-11-27 09:01:51 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by euleron7 on 2026-11-27T09:01:51Z.


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.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:comment:7214198193 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/443#issuecomment-7214198193). Originally posted by [euleron7](https://github.com/euleron7) on 2026-11-27T09:01:51Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/443:upstream-pr/443'
git switch 'upstream-pr/443'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'a-publier'
git merge --no-ff 'upstream-pr/443'
git switch 'upstream-pr/443'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'upstream-pr/443'
git switch 'upstream-pr/443'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'upstream-pr/443'
git switch 'a-publier'
git merge --squash 'upstream-pr/443'
git switch 'a-publier'
git merge --ff-only 'upstream-pr/443'
git switch 'a-publier'
git merge 'upstream-pr/443'
git push origin 'a-publier'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Belobug/VIctory-Belobug-AMD!443
No description provided.