Remove per-command mutex from command list state #145

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

@⁠Adika713 on GitHub · 2026-11-25 16:56 UTC · original
Adika713:perf/list-state-no-lock → main · +64 −13 · 1 files · 1 commits · open

TARGET: pull request from Adika713:perf/list-state-no-lock to Belobug/VIctory-Belobug-AMD:main.

Improve CPU time of recorded draw-state calls.

List.state was a Mutex<draw::State>. Every recorded command — setters, draws,
dispatches, target changes — locked and unlocked it. The file already documents
that the title uses a list on one thread at a time and uses UnsafeCell for
host and parts on that basis. This applies the same treatment to state and
adds an ignored CPU-only benchmark.

What is in it

  • List.state is now UnsafeCell<draw::State>; with_state, cut, hoist,
    close and reset borrow it directly.
  • An ignored list::tests::benchmark_state_lock that times 200,000 recorded
    stencil_ref calls and prints the median of five samples.

Tested

AMD Radeon RX 6950 XT (RDNA2), Ryzen 5 3600, 32 GB RAM, Windows 11,
rustc/cargo 1.98.1. No game data; the game was not run. Each tree used an
isolated CARGO_TARGET_DIR.

Benchmark:
cargo test --release -p victory-gpu --lib benchmark_state_lock -- --ignored --nocapture --test-threads=1

  • main 01aadd1: medians 10.8, 11.1, 10.9 ns/call (3 runs).
  • this branch: medians 5.2, 5.7, 5.6 ns/call (3 runs).

Correctness:

  • cargo check -p victory-gpu --lib --tests --locked: exit 0.
  • cargo test -p victory-gpu --lib list:: -- --test-threads=1: 5 passed, 0 failed, 1 ignored, 110 filtered.
  • cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 1 passed, 0 failed, 115 filtered.
  • Full lib, 20 serial runs with --skip watch::tests::written_pages_are_reported_to_every_asker: 0 failed; every run 110 passed, 0 failed, 5 ignored.
  • cargo test --workspace --no-fail-fast --locked: no new failures; the known xmem, shader and policy failures remain. victory-gpu 111 passed, 0 failed, 5 ignored.

Not tested

  • In-game FPS. No game files or paths were supplied, so this makes no claim
    about frame rate.
  • NVIDIA hardware. The intermittent
    watch::tests::written_pages_are_reported_to_every_asker failure was skipped
    in the repeated runs; it also occurs at main.
  • Open PR #142 initializes List.state and keeps a Mutex; its hunk would
    need updating if both changes land.

AI use

AI-assisted: OpenCode, model Big Pickle. No game data.

**@⁠Adika713** on GitHub · 2026-11-25 16:56 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/145) `Adika713:perf/list-state-no-lock` → `main` · +64 −13 · 1 files · 1 commits · open TARGET: pull request from `Adika713:perf/list-state-no-lock` to `Belobug/VIctory-Belobug-AMD:main`. Improve CPU time of recorded draw-state calls. `List.state` was a `Mutex<draw::State>`. Every recorded command — setters, draws, dispatches, target changes — locked and unlocked it. The file already documents that the title uses a list on one thread at a time and uses `UnsafeCell` for `host` and `parts` on that basis. This applies the same treatment to `state` and adds an ignored CPU-only benchmark. **What is in it** - `List.state` is now `UnsafeCell<draw::State>`; `with_state`, `cut`, `hoist`, `close` and `reset` borrow it directly. - An ignored `list::tests::benchmark_state_lock` that times 200,000 recorded `stencil_ref` calls and prints the median of five samples. **Tested** AMD Radeon RX 6950 XT (RDNA2), Ryzen 5 3600, 32 GB RAM, Windows 11, rustc/cargo 1.98.1. No game data; the game was not run. Each tree used an isolated `CARGO_TARGET_DIR`. Benchmark: `cargo test --release -p victory-gpu --lib benchmark_state_lock -- --ignored --nocapture --test-threads=1` - main `01aadd1`: medians 10.8, 11.1, 10.9 ns/call (3 runs). - this branch: medians 5.2, 5.7, 5.6 ns/call (3 runs). Correctness: - `cargo check -p victory-gpu --lib --tests --locked`: exit 0. - `cargo test -p victory-gpu --lib list:: -- --test-threads=1`: 5 passed, 0 failed, 1 ignored, 110 filtered. - `cargo test -p victory-gpu --lib draw:: -- --test-threads=1`: 1 passed, 0 failed, 115 filtered. - Full lib, 20 serial runs with `--skip watch::tests::written_pages_are_reported_to_every_asker`: 0 failed; every run 110 passed, 0 failed, 5 ignored. - `cargo test --workspace --no-fail-fast --locked`: no new failures; the known xmem, shader and policy failures remain. `victory-gpu` 111 passed, 0 failed, 5 ignored. **Not tested** - In-game FPS. No game files or paths were supplied, so this makes no claim about frame rate. - NVIDIA hardware. The intermittent `watch::tests::written_pages_are_reported_to_every_asker` failure was skipped in the repeated runs; it also occurs at main. - Open PR #142 initializes `List.state` and keeps a `Mutex`; its hunk would need updating if both changes land. **AI use** AI-assisted: OpenCode, model Big Pickle. No game data.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:36:37 +00:00
Author
Owner

@⁠KernelSmoker on GitHub · 2026-11-25 19:56 UTC · original

Independent verification & A/B benchmark on Intel Core i9-11900K + NVIDIA GeForce RTX 3090 (Bazzite Linux 45 x86_64, driver 620.73.04, GE-Proton 10-34 / Wine 10.0 / vkd3d-proton 3.0.0, Rust 1.98.1) on PR head 1bc9a7f:

  • Release benchmark (list::tests::benchmark_state_lock, 3 runs each, 200,000 stencil_ref calls/sample):
    • Base 01aadd1 (Mutex<draw::State>): medians 10.3 / 10.2 / 10.1 ns/call
    • PR #145 (1bc9a7f, UnsafeCell<draw::State>): medians 1.4 / 1.6 / 1.4 ns/call (~6.8× faster on this CPU/Wine runtime)
  • Debug unit tests under Wine/RTX 3090 (--test-threads=1):
    • list::: 5 passed, 0 failed, 1 ignored
    • draw::: 1 passed, 0 failed
  • Clippy (x86_64-pc-windows-gnu): 0 new warnings in the changed lines of crates/victory-gpu/src/list.rs.
  • Aliasing audit: Checked all callers of with_state, cut, hoist, close, and reset in list.rs — none of the with_state closures capture this to re-enter with_state/cut/hoist, and cut/hoist/reset borrow disjoint UnsafeCell fields (host, parts, state).

(In-game FPS was not measured here; this verifies the CPU benchmark, unit tests, clippy, and aliasing audit on Intel + NVIDIA.)

**@⁠KernelSmoker** on GitHub · 2026-11-25 19:56 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/145#issuecomment-7172974815) Independent verification & A/B benchmark on **Intel Core i9-11900K + NVIDIA GeForce RTX 3090** (Bazzite Linux 45 x86_64, driver 620.73.04, GE-Proton 10-34 / Wine 10.0 / vkd3d-proton 3.0.0, Rust 1.98.1) on PR head `1bc9a7f`: - **Release benchmark (`list::tests::benchmark_state_lock`, 3 runs each, 200,000 `stencil_ref` calls/sample):** - Base `01aadd1` (`Mutex<draw::State>`): medians **10.3 / 10.2 / 10.1 ns/call** - PR #145 (`1bc9a7f`, `UnsafeCell<draw::State>`): medians **1.4 / 1.6 / 1.4 ns/call** (~**6.8× faster** on this CPU/Wine runtime) - **Debug unit tests under Wine/RTX 3090 (`--test-threads=1`):** - `list::`: **5 passed, 0 failed, 1 ignored** - `draw::`: **1 passed, 0 failed** - **Clippy (`x86_64-pc-windows-gnu`):** **0 new warnings** in the changed lines of `crates/victory-gpu/src/list.rs`. - **Aliasing audit:** Checked all callers of `with_state`, `cut`, `hoist`, `close`, and `reset` in `list.rs` — none of the `with_state` closures capture `this` to re-enter `with_state`/`cut`/`hoist`, and `cut`/`hoist`/`reset` borrow disjoint `UnsafeCell` fields (`host`, `parts`, `state`). (In-game FPS was not measured here; this verifies the CPU benchmark, unit tests, clippy, and aliasing audit on Intel + NVIDIA.)
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-26 05:11 UTC · original

Concurrency check on Windows/RDNA2 (RX 6950 XT, Windows 11 build 26300, Rust 1.98.1). I merged this PR (1bc9a7f) onto main 4f62c2a plus #210, which fixes list::tests::lists_are_cut_at_waits_that_follow_work, a test that fails in every release run on main. Then I ran the release victory-gpu lib test binary 10 times, with the default thread count:

  • This PR: 10 of 10 runs passed (113 passed, 5 ignored).
  • The same base without the PR: 1 run failed on the known flake watch::tests::written_pages_are_reported_to_every_asker (#102), and 1 run died without a result line.

No new failure, deadlock or hang showed up in these runs. Ten runs are a small sample for races. Not run in the game.

harness machine: rx6950xt-w11 | AMD Radeon RX 6950 XT (RDNA2), driver 32.0.21045.29003 | 32 GB RAM | Windows 11 build 26300

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

**@⁠MamaLeVrai** on GitHub · 2026-11-26 05:11 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/145#issuecomment-7183255398) Concurrency check on Windows/RDNA2 (RX 6950 XT, Windows 11 build 26300, Rust 1.98.1). I merged this PR (`1bc9a7f`) onto `main` `4f62c2a` plus #210, which fixes `list::tests::lists_are_cut_at_waits_that_follow_work`, a test that fails in every release run on `main`. Then I ran the release `victory-gpu` lib test binary 10 times, with the default thread count: - This PR: 10 of 10 runs passed (113 passed, 5 ignored). - The same base without the PR: 1 run failed on the known flake `watch::tests::written_pages_are_reported_to_every_asker` (#102), and 1 run died without a result line. No new failure, deadlock or hang showed up in these runs. Ten runs are a small sample for races. Not run in the game. harness machine: rx6950xt-w11 | AMD Radeon RX 6950 XT (RDNA2), driver 32.0.21045.29003 | 32 GB RAM | Windows 11 build 26300 AI-assisted (Claude Code); no game data.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/145/head:github-bot/gh-145'
git switch 'github-bot/gh-145'

Merge

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