perf(gpu,shader): add opt-in raw CBV reads, sharded submit journal, and fine write guards #3455

Open
legayclightning22 wants to merge 4 commits from upstream-pr/3455 into main
legayclightning22 commented 2026-11-27 03:10:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by legayclightning22 on 2026-11-27T03:10:50Z.


Summary

Adds opt-in raw constant-buffer reads (VICTORY_PORT_CBV), sharded submit journaling (VICTORY_PORT_JOURNAL), and finer-grained write guards (VICTORY_PORT_GUARD) while keeping default behavior safe and preserving bounded root descriptor tables.

Changes

  • Support opt-in raw CBV reads (ROOT_CBV_SPACE), sharded submit journal updates (SHARDS), and per-block write guards (GUARDS / BUSY) across victory-gpu and victory-shader.
  • Keep all new port flags safely gated (0/off by default) and bounded for low-memory configurations.
  • Add unit tests covering sharded journaling, raw CBV flag/lowering guards, and write-guard synchronization.

Verification

  • cargo test --locked -p victory-gpu --lib and cargo test --locked -p victory-shader --lib
  • cargo clippy --locked -p victory-gpu -p victory-shader --all-targets --all-features -- -D warnings
  • cargo xtask policy
<!-- greyfinch-sync:Marvisak/VIctory:issue:5520513538 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3455). Originally posted by [legayclightning22](https://github.com/legayclightning22) on 2026-11-27T03:10:50Z. --- ## Summary Adds opt-in raw constant-buffer reads (`VICTORY_PORT_CBV`), sharded submit journaling (`VICTORY_PORT_JOURNAL`), and finer-grained write guards (`VICTORY_PORT_GUARD`) while keeping default behavior safe and preserving bounded root descriptor tables. ## Changes - Support opt-in raw CBV reads (`ROOT_CBV_SPACE`), sharded submit journal updates (`SHARDS`), and per-block write guards (`GUARDS` / `BUSY`) across `victory-gpu` and `victory-shader`. - Keep all new port flags safely gated (`0`/off by default) and bounded for low-memory configurations. - Add unit tests covering sharded journaling, raw CBV flag/lowering guards, and write-guard synchronization. ## Verification - `cargo test --locked -p victory-gpu --lib` and `cargo test --locked -p victory-shader --lib` - `cargo clippy --locked -p victory-gpu -p victory-shader --all-targets --all-features -- -D warnings` - `cargo xtask policy`
oni-swr commented 2026-11-27 05:06:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-27T05:06:57Z.


WARP test report (Windows, software adapter only; no GPU, no game files). AI-assisted, Claude.

  • OS: Windows 11 Pro, build 10.0.26200
  • Adapter: Microsoft Basic Render Driver (WARP, flagged software)
  • dxil.dll: Windows SDK 10.0.26100.0, file version 1.8.2502.11
  • rustc: 1.98.1 (48a229cea 2026-09-01), --locked
  • Env: VICTORY_WARP=1, VICTORY_D3D12_WARP=1
  • Base: 63bcca4 (main). Head: 0c72875 (this PR, a fast-forward of main, no conflicts)
Run victory-gpu (--features diagnostics, --test-threads=1) victory-shader
main 246 passed, 0 failed, 1 ignored 298 passed, 4 failed, 3 ignored
main + PR, flags off 252 passed, 0 failed, 1 ignored 300 passed, 4 failed, 3 ignored
main + PR, VICTORY_PORT_CBV=1 VICTORY_PORT_JOURNAL=1 VICTORY_PORT_GUARD=1 251 passed, 1 failed, 1 ignored 300 passed, 4 failed, 3 ignored
  • The same 4 victory-shader tests fail on main and on main + PR (all in emit::synthetic_tests: lane permutes, gathers, a mask-at-uniform-loop case). They look WARP-related (wave size) and are not caused by this PR.
  • New tests: 6 in victory-gpu and 2 in victory-shader. All 8 pass with the flags off. With the flags on, 7 of 8 pass.
  • The failing one is port_journal::tests::without_the_switch_every_page_is_fresh, which fails only when VICTORY_PORT_JOURNAL=1 is in the environment. It is not hermetic: enable(false) can only force the flag on, so port_journal() still reads the env switch and claim returns [] instead of [8, 9]. A test-only override that can force the flag off (like CONSTANTS_RAW_HERE: Option<bool>) would fix it.
  • None of the new tests create a device. They are pure logic, so none of them actually exercises WARP. WARP only runs the existing suite.

Notes from reading the diff:

  1. VICTORY_PORT_GUARD=1 alone changes nothing. port_guard() is only read inside the port_journal::on() branch of retake, so the shared-lock path needs the journal as well. light() defaults to on, so with the journal on the shared lock is used even without the guard flag.
  2. With VICTORY_PORT_CBV=1 the shader reads the root CBV through root_srv_handle, and the shader-cache key is changed. I could not see the host-side root SRV binding in this diff. If it already exists elsewhere, ignore this. Otherwise the flag-on path has no test for it.
  3. The new port_cbv::raw_ok and port_journal::shards_of are only compiled for tests, so they cover code that is not used outside tests. The claim comment about a "journal's lock" has no matching outer lock in the code.
  4. In claim, a page is noted before its mark is done. A second thread claiming the same page in that window gets an empty list while the first thread has not yet marked it. This may be harmless, but I did not check it.
  5. Nothing about the flags-off behaviour looked different from main. The Mutex to RwLock change on GUARDS is the only default-path change, and the suites above pass with it.

Counts only; no game data.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7210361383 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3455#issuecomment-7210361383). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-27T05:06:57Z. --- **WARP test report** (Windows, software adapter only; no GPU, no game files). AI-assisted, Claude. - OS: Windows 11 Pro, build 10.0.26200 - Adapter: Microsoft Basic Render Driver (WARP, flagged software) - dxil.dll: Windows SDK 10.0.26100.0, file version 1.8.2502.11 - rustc: 1.98.1 (48a229cea 2026-09-01), `--locked` - Env: `VICTORY_WARP=1`, `VICTORY_D3D12_WARP=1` - Base: `63bcca4` (main). Head: `0c72875` (this PR, a fast-forward of main, no conflicts) | Run | victory-gpu (`--features diagnostics`, `--test-threads=1`) | victory-shader | |---|---|---| | main | 246 passed, 0 failed, 1 ignored | 298 passed, 4 failed, 3 ignored | | main + PR, flags off | 252 passed, 0 failed, 1 ignored | 300 passed, 4 failed, 3 ignored | | main + PR, `VICTORY_PORT_CBV=1 VICTORY_PORT_JOURNAL=1 VICTORY_PORT_GUARD=1` | 251 passed, **1 failed**, 1 ignored | 300 passed, 4 failed, 3 ignored | - The same 4 victory-shader tests fail on main and on main + PR (all in `emit::synthetic_tests`: lane permutes, gathers, a mask-at-uniform-loop case). They look WARP-related (wave size) and are not caused by this PR. - New tests: 6 in victory-gpu and 2 in victory-shader. All 8 pass with the flags off. With the flags on, 7 of 8 pass. - The failing one is `port_journal::tests::without_the_switch_every_page_is_fresh`, which fails only when `VICTORY_PORT_JOURNAL=1` is in the environment. It is not hermetic: `enable(false)` can only force the flag on, so `port_journal()` still reads the env switch and `claim` returns `[]` instead of `[8, 9]`. A test-only override that can force the flag off (like `CONSTANTS_RAW_HERE: Option<bool>`) would fix it. - None of the new tests create a device. They are pure logic, so none of them actually exercises WARP. WARP only runs the existing suite. Notes from reading the diff: 1. `VICTORY_PORT_GUARD=1` alone changes nothing. `port_guard()` is only read inside the `port_journal::on()` branch of `retake`, so the shared-lock path needs the journal as well. `light()` defaults to on, so with the journal on the shared lock is used even without the guard flag. 2. With `VICTORY_PORT_CBV=1` the shader reads the root CBV through `root_srv_handle`, and the shader-cache key is changed. I could not see the host-side root SRV binding in this diff. If it already exists elsewhere, ignore this. Otherwise the flag-on path has no test for it. 3. The new `port_cbv::raw_ok` and `port_journal::shards_of` are only compiled for tests, so they cover code that is not used outside tests. The `claim` comment about a "journal's lock" has no matching outer lock in the code. 4. In `claim`, a page is noted before its mark is done. A second thread claiming the same page in that window gets an empty list while the first thread has not yet marked it. This may be harmless, but I did not check it. 5. Nothing about the flags-off behaviour looked different from main. The `Mutex` to `RwLock` change on `GUARDS` is the only default-path change, and the suites above pass with it. Counts only; no game data.
futurepro62 commented 2026-11-27 08:57:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-27T08:57:46Z.


NVIDIA full-suite run, to go with the reports above by oni-swr, since none of them names a GPU run. Tested exact head 0c72875 (on its base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 874 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: raw_table_views_need_sixteen_bytes, ranges_name_their_parts, claims_are_per_shard_and_per_generation, without_the_switch_every_page_is_fresh, test_flags_are_thread_local, shared_guards_yield_to_a_writer, raw_root_cbv_needs_the_switch_and_a_root_descriptor, constants_raw_is_opt_in.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7214120385 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3455#issuecomment-7214120385). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-27T08:57:46Z. --- NVIDIA full-suite run, to go with the reports above by oni-swr, since none of them names a GPU run. Tested exact head `0c72875` (on its base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **874 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `raw_table_views_need_sixteen_bytes`, `ranges_name_their_parts`, `claims_are_per_shard_and_per_generation`, `without_the_switch_every_page_is_fresh`, `test_flags_are_thread_local`, `shared_guards_yield_to_a_writer`, `raw_root_cbv_needs_the_switch_and_a_root_descriptor`, `constants_raw_is_opt_in`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
KainanP commented 2026-11-27 12:40:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by KainanP on 2026-11-27T12:40:25Z.


Contention numbers for this PR from a shared benchmark (for #3425).

Method. The benchmark guard_contention and the check refreshes_under_writes_lose_nothing from #3516, split out as a standalone test-only commit (KainanP/VIctory perf/guard-bench: no behaviour change, guards() only times a lock it finds taken in test builds), applied unchanged to this PR's head (0c72875) and to main (63bcca4). 256 MB write-watched pool in 64 KiB pages, copies of 32 pages, 1,400 pages dirtied before each refresh, title threads writing a random word every 20 µs while the copies are taken and copied. Release builds, i7-14650HX (24 threads), Windows 11. 31 rounds, builds interleaved and rotated each round, each run = median of 5 refreshes after a warm-up; table = medians over the 31 runs, plus the median (and quartiles) of the per-round PR/main ratio. Foreign load: other agents' rustc jobs were running (≈8 % of the CPU in a spot sample); the paired ratio is what to read.

Config Refresh ms (main → PR) Writers in their writes, ms Writers waiting for GUARDS, ms PR/main, writes PR/main, wait
1 writer 17.4 → 18.4 5.1 → 5.7 2.8 → 2.9 1.05 (0.97–1.27) 1.05 (0.96–1.23)
4 writers 29.1 → 31.0 37.8 → 37.7 24.3 → 23.4 0.99 (0.92–1.02) 1.00 (0.93–1.04)
4 writers, refresh on 4 threads 9.2 → 9.5 28.3 → 29.6 25.7 → 26.9 1.05 (0.96–1.10) 1.05 (0.98–1.10)
4 writers, twin views (aliased) 30.2 → 31.8 56.4 → 59.0 40.1 → 41.5 1.02 (0.92–1.19) 1.02 (0.94–1.17)
4 writers, copies armed (first writes save the page) 43.2 → 41.7 145.3 → 135.3 119.4 → 112.1 0.99 (0.94–1.07) 0.99 (0.93–1.07)

Run with VICTORY_PORT_GUARD=1 VICTORY_PORT_JOURNAL=1 (light refresh on, the default).

Reading. No measurable change in any config (paired ratios 0.99–1.05). That's expected rather than a verdict on the PR: the shared lock is only taken in retake, while the waits this bench measures are the write-fault handler and Tracked::take, both of which still take GUARDS exclusively (guards() → write()). If the fault handler's read-mostly part could run under read(), this bench would show it.

Correctness. refreshes_under_writes_lose_nothing passes on this head (3 × 1,000 rounds), as do the existing watch:: tests. It doesn't call retake, so the shared-lock path itself isn't covered by it.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7218536027 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3455#issuecomment-7218536027). Originally posted by [KainanP](https://github.com/KainanP) on 2026-11-27T12:40:25Z. --- Contention numbers for this PR from a shared benchmark (for #3425). **Method.** The benchmark `guard_contention` and the check `refreshes_under_writes_lose_nothing` from #3516, split out as a standalone test-only commit ([KainanP/VIctory `perf/guard-bench`](https://github.com/KainanP/VIctory/commit/ab96ee44e6bf35ec1dc5cd97c0f059797950b2e8): no behaviour change, `guards()` only times a lock it finds taken in test builds), applied unchanged to this PR's head (`0c72875`) and to `main` (`63bcca4`). 256 MB write-watched pool in 64 KiB pages, copies of 32 pages, 1,400 pages dirtied before each refresh, title threads writing a random word every 20 µs while the copies are taken and copied. Release builds, i7-14650HX (24 threads), Windows 11. 31 rounds, builds interleaved and rotated each round, each run = median of 5 refreshes after a warm-up; table = medians over the 31 runs, plus the median (and quartiles) of the per-round PR/main ratio. Foreign load: other agents' `rustc` jobs were running (≈8 % of the CPU in a spot sample); the paired ratio is what to read. | Config | Refresh ms (main → PR) | Writers in their writes, ms | Writers waiting for `GUARDS`, ms | PR/main, writes | PR/main, wait | |---|---|---|---|---|---| | 1 writer | 17.4 → 18.4 | 5.1 → 5.7 | 2.8 → 2.9 | 1.05 (0.97–1.27) | 1.05 (0.96–1.23) | | 4 writers | 29.1 → 31.0 | 37.8 → 37.7 | 24.3 → 23.4 | 0.99 (0.92–1.02) | 1.00 (0.93–1.04) | | 4 writers, refresh on 4 threads | 9.2 → 9.5 | 28.3 → 29.6 | 25.7 → 26.9 | 1.05 (0.96–1.10) | 1.05 (0.98–1.10) | | 4 writers, twin views (aliased) | 30.2 → 31.8 | 56.4 → 59.0 | 40.1 → 41.5 | 1.02 (0.92–1.19) | 1.02 (0.94–1.17) | | 4 writers, copies armed (first writes save the page) | 43.2 → 41.7 | 145.3 → 135.3 | 119.4 → 112.1 | 0.99 (0.94–1.07) | 0.99 (0.93–1.07) | Run with `VICTORY_PORT_GUARD=1 VICTORY_PORT_JOURNAL=1` (light refresh on, the default). **Reading.** No measurable change in any config (paired ratios 0.99–1.05). That's expected rather than a verdict on the PR: the shared lock is only taken in `retake`, while the waits this bench measures are the write-fault handler and `Tracked::take`, both of which still take `GUARDS` exclusively (`guards()` → `write()`). If the fault handler's read-mostly part could run under `read()`, this bench would show it. **Correctness.** `refreshes_under_writes_lose_nothing` passes on this head (3 × 1,000 rounds), as do the existing `watch::` tests. It doesn't call `retake`, so the shared-lock path itself isn't covered by it. _AI use: Claude Code (Claude Opus 5.5)._
legayclightning22 commented 2026-11-27 15:30:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by legayclightning22 on 2026-11-27T15:30:58Z.


Thanks @oni-swr, @futurepro62, and @KainanP for the WARP, RTX 5070 Ti, and contention benchmark reports! Pushed a428469 making the thread-local flag overrides Option<bool> so without_the_switch_every_page_is_fresh passes hermetically even when VICTORY_PORT_JOURNAL=1 is set in the environment, cleaning up the #[cfg(test)]-only helpers and stale claim lock comment, and clarifying VICTORY_PORT_GUARD / VICTORY_PORT_JOURNAL gating. Re-verified victory-gpu and victory-shader tests (both default and with all flags set), clippy --all-targets --all-features -- -D warnings, and cargo xtask policy.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7222151068 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3455#issuecomment-7222151068). Originally posted by [legayclightning22](https://github.com/legayclightning22) on 2026-11-27T15:30:58Z. --- Thanks @oni-swr, @futurepro62, and @KainanP for the WARP, RTX 5070 Ti, and contention benchmark reports! Pushed `a428469` making the thread-local flag overrides `Option<bool>` so `without_the_switch_every_page_is_fresh` passes hermetically even when `VICTORY_PORT_JOURNAL=1` is set in the environment, cleaning up the `#[cfg(test)]`-only helpers and stale `claim` lock comment, and clarifying `VICTORY_PORT_GUARD` / `VICTORY_PORT_JOURNAL` gating. Re-verified `victory-gpu` and `victory-shader` tests (both default and with all flags set), `clippy --all-targets --all-features -- -D warnings`, and `cargo xtask policy`. ```[cite: 72]
upipibi commented 2026-11-27 22:24:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-27T22:24:56Z.


A note on the write-guard part (VICTORY_PORT_GUARD), from reading a4284695 and a local benchmark: as it stands, the switch does not touch the path the fork's measured gain came from.

  • Write faults stay exclusive. The fault handler on_write (crates/victory-gpu/src/watch.rs:978) takes guards() (:994), which is GUARDS.write() (:260-262) whatever the switch says. So each fault still waits behind every other fault and refresh, as with the old Mutex.
  • The one shared use needs the journal on. guards_shared() (:265-267) is used outside tests only in the narrow mark at :903-904, inside if crate::port_journal::on() (:898). With VICTORY_PORT_GUARD=1 alone, nothing takes the lock shared.
  • No per-block claims. The description lists "per-block write guards (GUARDS / BUSY)", but BUSY does not appear in the diff.

For comparison, port 6 in the fork this is ported from (gleaf-6/VIctory-7900XTX- 42ddb597, Belobug's watch.rs) takes the lock shared in the faults (open_faulted), the refreshes and publish. Each block's state there sits in atomic words with a claim per block, and only mapping changes, kernel writes and frees take it alone. Its measurement (36-41 → 2-6 ms a frame of all threads' waiting, at 352-392 write faults a frame) is from that fault path. On upstream's own stack, #3425's frame budget (RTX 5090) puts the same cost at 52 ms a frame: the title's write-fault handler queueing behind GUARDS, which our own paths hold about 49 ms a frame.

Benchmark (local only, not proposed): an ignored test in watch::tests. 1, 4, 8 and 16 threads write one byte per 4 KiB into freshly taken pool(64) memory, so each first write per block faults through on_write, 40 rounds each. PORT_GUARD_IN_TEST is set from the variable on every writer thread, since the handler reads it on the faulting thread. Release build, 3 alternating runs per setting:

threads VICTORY_PORT_GUARD=0, µs a round =1, µs a round
1 865 / 925 / 911 922 / 911 / 1194
4 627 / 686 / 639 664 / 694 / 843
8 822 / 894 / 829 807 / 863 / 1161
16 981 / 1152 / 1387 1034 / 1024 / 1356

There is no difference beyond run-to-run noise (the machine had other GPU work running), as expected with the handler on the exclusive lock. With the fork's change, this is the benchmark that should move.

AI-assisted (Claude Code, Claude Opus 5.5 read the code, wrote and ran the local benchmark).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7229308520 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3455#issuecomment-7229308520). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-27T22:24:56Z. --- A note on the write-guard part (`VICTORY_PORT_GUARD`), from reading `a4284695` and a local benchmark: as it stands, the switch does not touch the path the fork's measured gain came from. - **Write faults stay exclusive.** The fault handler `on_write` (`crates/victory-gpu/src/watch.rs:978`) takes `guards()` (`:994`), which is `GUARDS.write()` (`:260-262`) whatever the switch says. So each fault still waits behind every other fault and refresh, as with the old `Mutex`. - **The one shared use needs the journal on.** `guards_shared()` (`:265-267`) is used outside tests only in the narrow mark at `:903-904`, inside `if crate::port_journal::on()` (`:898`). With `VICTORY_PORT_GUARD=1` alone, nothing takes the lock shared. - **No per-block claims.** The description lists "per-block write guards (`GUARDS` / `BUSY`)", but `BUSY` does not appear in the diff. For comparison, port 6 in the fork this is ported from (gleaf-6/VIctory-7900XTX- `42ddb597`, Belobug's `watch.rs`) takes the lock shared in the faults (`open_faulted`), the refreshes and `publish`. Each block's state there sits in atomic words with a claim per block, and only mapping changes, kernel writes and frees take it alone. Its measurement (36-41 → 2-6 ms a frame of all threads' waiting, at 352-392 write faults a frame) is from that fault path. On upstream's own stack, #3425's frame budget (RTX 5090) puts the same cost at 52 ms a frame: the title's write-fault handler queueing behind `GUARDS`, which our own paths hold about 49 ms a frame. **Benchmark** (local only, not proposed): an ignored test in `watch::tests`. 1, 4, 8 and 16 threads write one byte per 4 KiB into freshly taken `pool(64)` memory, so each first write per block faults through `on_write`, 40 rounds each. `PORT_GUARD_IN_TEST` is set from the variable on every writer thread, since the handler reads it on the faulting thread. Release build, 3 alternating runs per setting: | threads | `VICTORY_PORT_GUARD=0`, µs a round | `=1`, µs a round | |---|---|---| | 1 | 865 / 925 / 911 | 922 / 911 / 1194 | | 4 | 627 / 686 / 639 | 664 / 694 / 843 | | 8 | 822 / 894 / 829 | 807 / 863 / 1161 | | 16 | 981 / 1152 / 1387 | 1034 / 1024 / 1356 | There is no difference beyond run-to-run noise (the machine had other GPU work running), as expected with the handler on the exclusive lock. With the fork's change, this is the benchmark that should move. AI-assisted (Claude Code, Claude Opus 5.5 read the code, wrote and ran the local benchmark).
legayclightning22 commented 2026-11-28 04:41:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by legayclightning22 on 2026-11-28T04:41:28Z.


Thanks @upipibi — pushed an updated commit decoupling VICTORY_PORT_GUARD=1 from VICTORY_PORT_JOURNAL in crates/victory-gpu/src/watch.rs so fault/refresh/publish paths take guards_shared() with per-block atomic BUSY claims while keeping VICTORY_PORT_GUARD=0 identical to main.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7234197958 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3455#issuecomment-7234197958). Originally posted by [legayclightning22](https://github.com/legayclightning22) on 2026-11-28T04:41:28Z. --- Thanks @upipibi — pushed an updated commit decoupling `VICTORY_PORT_GUARD=1` from `VICTORY_PORT_JOURNAL` in `crates/victory-gpu/src/watch.rs` so fault/refresh/publish paths take `guards_shared()` with per-block atomic `BUSY` claims while keeping `VICTORY_PORT_GUARD=0` identical to `main`.
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/3455:upstream-pr/3455'
git switch 'upstream-pr/3455'

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 'main'
git merge --no-ff 'upstream-pr/3455'
git switch 'upstream-pr/3455'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3455'
git switch 'upstream-pr/3455'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3455'
git switch 'main'
git merge --squash 'upstream-pr/3455'
git switch 'main'
git merge --ff-only 'upstream-pr/3455'
git switch 'main'
git merge 'upstream-pr/3455'
git push origin 'main'
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
Marvisak/VIctory!3455
No description provided.