GPU: title threads recording lists no longer wait on descriptor and buffer-copy locks #2819

Open
0xkn0wh3r3 wants to merge 5 commits from upstream-pr/2821 into main
0xkn0wh3r3 commented 2026-11-25 21:28:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T21:28:45Z.


Removes the mutex contention the list benchmark in #2820 measures on the title's recording threads. This PR carries only the locking change. The benchmark lives in #2820 alone (see "Benchmark" below). Each commit's message has its own before/after numbers.

Changes

  1. descriptor::SHADER_HEAPS → RwLock. Every view write and descriptor copy looked up its heap under a mutex, and held it for the whole host view creation. The list only changes when a shader-visible heap is made or dropped, which are the only two write-locked places. Holding the read lock still keeps a heap from being dropped while it is used.

  2. shadow::BUFFERS → RwLock. find now looks up a host copy that already exists under the shared lock. Making a copy, registering a buffer and releasing one take the exclusive lock as before, and the lookup is redone under it.

  3. HostHeap::mirror no longer takes made for slots that are already made. Each title slot gets an atomic copy of its record. It is set last, under the lock, once the slot is made and holds what a draw reads. It is cleared first whenever the slot is remade, nulled or evicted. A slot that reads as ready returns without the lock, just as the check under the lock would have.

    Two kinds of slot are never marked ready, because the checks under the lock look at more than the slot: a texture view left null, which is made when read, and a view of a texture placed in memory. needs_remake checks that second kind against the memory's current host texture (#1997).

  4. descriptor::VIEWS → RwLock. Lookups take the read lock. record finds an already-known view under the shared lock, which still stops forget from making the entry stale while the record is written.

  5. HostHeap::evict re-checks its slots under made. The concurrency review below found a window: a slot rewritten between evict picking it and nulling it lost its new view. Draws could always hit that window; after commit 1, view writes can too. Evict now picks again, under the lock every title-slot rewrite holds, and leaves slots that view something else.

Functions that may now run at the same time (review point 1)

The functions that read SHADER_HEAPS are descriptor::mirror, sync_heaps, make_read, read_textures, evict, release_dynamic and with_host. Two facts narrow down which pairs are new:

  • Submissions don't overlap. HostGpu::execute holds submitted from preparation through copy-back (host.rs), and that one function calls evict (through resource::evict_unused), sync_heaps, make_read and read_textures one after another. with_host runs through memory::prepare there too. These never overlap each other, before or after this PR.
  • Per-slot work never depended on SHADER_HEAPS. Draws bind slots through HostHeap::mirror without it (draw::State::table_entry). The same goes for dynamic slots (dynamic, make_at, raw_view_at, make_null) and Heap::host's replay. So on main, every HostHeap operation could already run at the same time as each submission-side reader, and was kept safe by the heap's own locks: made for title slots, kept, next and pairs, plus pending with the OnceLock. SHADER_HEAPS only kept the heap list, and so each heap, alive.

The new overlaps are therefore between title-thread readers, and between title-thread readers and the submission:

Pair Why it is safe
mirror × mirror (two threads writing views) Both go through HostHeap::mirror, the same path two drawing threads already took at once. Slot making is serialized per slot by made, and the record is read again after prepare, so the slot ends up made from the current record. pending and the host heap's OnceLock are published under the pending lock, as before.
mirror × sync_heaps, mirror × make_read (title write during a submission) The same per-slot serialization on made, with whichever runs last making the slot from the latest record. This is what a drawing thread and a submission already did on main. In make_read, unmade_placed is a snapshot, and acting on a stale one only makes a placed texture that already exists.
mirror × evict (title write while textures are given up) This had the window that commit 5 closes. Draws could already hit it on main.
release_dynamic × anything (a list reset or released on a title thread) HostHeap::release touches only next, which draws taking dynamic slots already share.
with_host × anything (memory::bind while recording, memory::prepare at submission) The closures take memory::SHARED, which serializes them with each other, plus pairs and view_addresses (OnceLock, then made). The submission-side readers touch neither SHARED nor pairs.
Heap creation and drop (write lock) They still wait for every reader, so a heap is never freed while a reader uses it.

shadow::BUFFERS and VIEWS were each taken by single-entry functions: look up, clone, return. Their write paths are unchanged, so the read side adds no new interleaving of their own state.

No nested read locks (review point 2)

std::sync::RwLock can deadlock when a thread takes the read lock again while a writer waits. That needs the same thread to take the same lock twice. On main these were std mutexes, which deadlock on any such nesting, so no executed path could do it. Here are the paths checked:

  • VIEWS: view_at, view and views_current take it, clone and return. record drops its read guard before it calls mirror, and its write section calls nothing that takes VIEWS. forget is self-contained.

  • BUFFERS: find's read section is a map lookup and an Arc clone. It drops the guard before loose(), which takes LOOSE. all and near are plain reads.

  • SHADER_HEAPS: these run with it held:

    • mirror and sync_heaps → HostHeap::mirror → prepare, make_marked, keep.
    • make_read → HostHeap::mirror and stamp_read.
    • evict, read_textures, release_dynamic.
    • with_host → the memory.rs closures named above.

    None of them reaches a SHADER_HEAPS reader. keep → host::retire only pushes onto RETIRED, which is released after the submission on a thread of its own. draw::State::drop, which calls release_dynamic, runs at list reset or release, or in a host list's deferred after work. That work runs in execute after make_read has returned (host.rs). evict is reached only from evict_unused at the top of execute. memory::bind and memory::prepare are not called with SHADER_HEAPS held.

Numbers (list benchmark from #2820, 5 threads, RTX 5070 Ti, release)

Other builds were running on the machine at the same time, so the builds were run interleaved, 9 rounds each. The table gives best / median ns per call:

after commit all calls DrawIndexed CreateCBV diagnostics, all calls
main 1003 / 1651 3955 / 6059 979 / 2148 1214 / 1447
1 SHADER_HEAPS 1029 / 1236 4258 / 5089 809 / 1028 1201 / 1763
2 BUFFERS 924 / 1504 3683 / 5934 837 / 1540 1166 / 1355
3 made fast path 834 / 1157 3277 / 4621 792 / 1096 1143 / 1301
4 VIEWS 782 / 1028 3285 / 4334 516 / 712 1055 / 1225

From main to commit 4, the best run drops 22% (13% with diagnostics) and the median 38%. One thread goes from 334 to 307 ns per call. Commit 5 only runs once per eviction, on the submitting thread. These numbers were measured before the rebase onto the current main. After these changes the profile has lock_contended at 5.5% of recording time instead of 58%. What remains is cache-line traffic on the RwLock reader counts (shadow::find, view_at), which needs per-list caches or lock-free maps to remove.

Benchmark (review point 3)

The benchmark files are no longer in this PR, which is main plus the five commits above. Whether the benchmark belongs in the tree is decided on #2820. If it doesn't land, the table above can be reproduced from that branch.

Overlap with #1356

#1356 (open, currently conflicting with main) also turns SHADER_HEAPS, VIEWS and BUFFERS into RwLocks, makes made an RwLock, and adds per-HostList shadow and view caches. Commits 1, 2 and 4 are a subset of it, offered as the smaller, measured version on current main. Commit 3 takes a different approach (lock-free reads of made slots), and commit 5 applies to either PR. #1356's caches go after the RwLock reader traffic that is left. #2121 also changes HostHeap slot making, so whichever of #2121 and this PR lands second must clear the ready marks in take_back_pages and remakes.

Checks

  • cargo clippy -p victory-gpu --all-targets -- -D warnings, with and without --features diagnostics: clean.
  • cargo test -p victory-gpu --lib: 229 passed. The two failures are descriptor::host::tests::dynamic_slots_are_held_until_released and memory::tests::lists_share_a_table_and_copies_keep_their_views. Both already fail on main on this NVIDIA card (the heap cap, fixed by #2121).
  • With --features diagnostics, the same results as main on this machine:
    • host::present_plane_tests::compositor_failure_presents_primary_in_the_same_frame (from #1997) crashes the test process (exit 2173) every time it runs alone, on main's code too. It is skipped here.
    • frame::tests::waits_end_on_ticks_and_count_frames and descriptor::host::tests::placed_uav_textures_create_real_host_uavs fail intermittently on main and here alike.
  • cargo xtask policy: ok.

Measured in the title

@Jackster ran retail 1.0.2.1 on an RX 7900 XTX: a diagnostics build at 63bcca4 with this PR on a stack of #2703, #1010, #2985, #2849, #2908, #2472, #2958 and #3118, two 300 s world runs (VICTORY_KEYS), warm caches, same save.

without with
title threads waiting to write views (MirrorWaitUs) 334.0 ms 0.1 ms
frame 1,150 ms / 2,186 draws 1,025 ms / 2,172 draws
prepare 428 ms 422 ms

One run each. Slot counts differ between the runs because the title rewrote different pages.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5499479542 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2821). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T21:28:45Z. --- Removes the mutex contention the list benchmark in #2820 measures on the title's recording threads. This PR carries only the locking change. The benchmark lives in #2820 alone (see "Benchmark" below). Each commit's message has its own before/after numbers. ## Changes 1. **`descriptor::SHADER_HEAPS` → `RwLock`.** Every view write and descriptor copy looked up its heap under a mutex, and held it for the whole host view creation. The list only changes when a shader-visible heap is made or dropped, which are the only two write-locked places. Holding the read lock still keeps a heap from being dropped while it is used. 2. **`shadow::BUFFERS` → `RwLock`.** `find` now looks up a host copy that already exists under the shared lock. Making a copy, registering a buffer and releasing one take the exclusive lock as before, and the lookup is redone under it. 3. **`HostHeap::mirror` no longer takes `made` for slots that are already made.** Each title slot gets an atomic copy of its record. It is set last, under the lock, once the slot is made and holds what a draw reads. It is cleared first whenever the slot is remade, nulled or evicted. A slot that reads as ready returns without the lock, just as the check under the lock would have. Two kinds of slot are never marked ready, because the checks under the lock look at more than the slot: a texture view left null, which is made when read, and a view of a texture placed in memory. `needs_remake` checks that second kind against the memory's current host texture (#1997). 4. **`descriptor::VIEWS` → `RwLock`.** Lookups take the read lock. `record` finds an already-known view under the shared lock, which still stops `forget` from making the entry stale while the record is written. 5. **`HostHeap::evict` re-checks its slots under `made`.** The concurrency review below found a window: a slot rewritten between evict picking it and nulling it lost its new view. Draws could always hit that window; after commit 1, view writes can too. Evict now picks again, under the lock every title-slot rewrite holds, and leaves slots that view something else. ## Functions that may now run at the same time (review point 1) The functions that read `SHADER_HEAPS` are `descriptor::mirror`, `sync_heaps`, `make_read`, `read_textures`, `evict`, `release_dynamic` and `with_host`. Two facts narrow down which pairs are new: - **Submissions don't overlap.** `HostGpu::execute` holds `submitted` from preparation through copy-back (`host.rs`), and that one function calls `evict` (through `resource::evict_unused`), `sync_heaps`, `make_read` and `read_textures` one after another. `with_host` runs through `memory::prepare` there too. These never overlap each other, before or after this PR. - **Per-slot work never depended on `SHADER_HEAPS`.** Draws bind slots through `HostHeap::mirror` without it (`draw::State::table_entry`). The same goes for dynamic slots (`dynamic`, `make_at`, `raw_view_at`, `make_null`) and `Heap::host`'s replay. So on main, every `HostHeap` operation could already run at the same time as each submission-side reader, and was kept safe by the heap's own locks: `made` for title slots, `kept`, `next` and `pairs`, plus `pending` with the `OnceLock`. `SHADER_HEAPS` only kept the heap list, and so each heap, alive. The new overlaps are therefore between title-thread readers, and between title-thread readers and the submission: | Pair | Why it is safe | |---|---| | `mirror` × `mirror` (two threads writing views) | Both go through `HostHeap::mirror`, the same path two drawing threads already took at once. Slot making is serialized per slot by `made`, and the record is read again after `prepare`, so the slot ends up made from the current record. `pending` and the host heap's `OnceLock` are published under the `pending` lock, as before. | | `mirror` × `sync_heaps`, `mirror` × `make_read` (title write during a submission) | The same per-slot serialization on `made`, with whichever runs last making the slot from the latest record. This is what a drawing thread and a submission already did on main. In `make_read`, `unmade_placed` is a snapshot, and acting on a stale one only makes a placed texture that already exists. | | `mirror` × `evict` (title write while textures are given up) | This had the window that commit 5 closes. Draws could already hit it on main. | | `release_dynamic` × anything (a list reset or released on a title thread) | `HostHeap::release` touches only `next`, which draws taking dynamic slots already share. | | `with_host` × anything (`memory::bind` while recording, `memory::prepare` at submission) | The closures take `memory::SHARED`, which serializes them with each other, plus `pairs` and `view_addresses` (`OnceLock`, then `made`). The submission-side readers touch neither `SHARED` nor `pairs`. | | `Heap` creation and drop (write lock) | They still wait for every reader, so a heap is never freed while a reader uses it. | `shadow::BUFFERS` and `VIEWS` were each taken by single-entry functions: look up, clone, return. Their write paths are unchanged, so the read side adds no new interleaving of their own state. ## No nested read locks (review point 2) `std::sync::RwLock` can deadlock when a thread takes the read lock again while a writer waits. That needs the same thread to take the same lock twice. On main these were `std` mutexes, which deadlock on any such nesting, so no executed path could do it. Here are the paths checked: - **`VIEWS`:** `view_at`, `view` and `views_current` take it, clone and return. `record` drops its read guard before it calls `mirror`, and its write section calls nothing that takes `VIEWS`. `forget` is self-contained. - **`BUFFERS`:** `find`'s read section is a map lookup and an `Arc` clone. It drops the guard before `loose()`, which takes `LOOSE`. `all` and `near` are plain reads. - **`SHADER_HEAPS`:** these run with it held: - `mirror` and `sync_heaps` → `HostHeap::mirror` → `prepare`, `make_marked`, `keep`. - `make_read` → `HostHeap::mirror` and `stamp_read`. - `evict`, `read_textures`, `release_dynamic`. - `with_host` → the `memory.rs` closures named above. None of them reaches a `SHADER_HEAPS` reader. `keep` → `host::retire` only pushes onto `RETIRED`, which is released after the submission on a thread of its own. `draw::State::drop`, which calls `release_dynamic`, runs at list reset or release, or in a host list's deferred `after` work. That work runs in `execute` after `make_read` has returned (`host.rs`). `evict` is reached only from `evict_unused` at the top of `execute`. `memory::bind` and `memory::prepare` are not called with `SHADER_HEAPS` held. ## Numbers (list benchmark from #2820, 5 threads, RTX 5070 Ti, release) Other builds were running on the machine at the same time, so the builds were run interleaved, 9 rounds each. The table gives best / median ns per call: | after commit | all calls | DrawIndexed | CreateCBV | diagnostics, all calls | |---|---|---|---|---| | main | 1003 / 1651 | 3955 / 6059 | 979 / 2148 | 1214 / 1447 | | 1 `SHADER_HEAPS` | 1029 / 1236 | 4258 / 5089 | 809 / 1028 | 1201 / 1763 | | 2 `BUFFERS` | 924 / 1504 | 3683 / 5934 | 837 / 1540 | 1166 / 1355 | | 3 `made` fast path | 834 / 1157 | 3277 / 4621 | 792 / 1096 | 1143 / 1301 | | 4 `VIEWS` | **782 / 1028** | **3285 / 4334** | **516 / 712** | **1055 / 1225** | From main to commit 4, the best run drops 22% (13% with `diagnostics`) and the median 38%. One thread goes from 334 to 307 ns per call. Commit 5 only runs once per eviction, on the submitting thread. These numbers were measured before the rebase onto the current main. After these changes the profile has `lock_contended` at 5.5% of recording time instead of 58%. What remains is cache-line traffic on the `RwLock` reader counts (`shadow::find`, `view_at`), which needs per-list caches or lock-free maps to remove. ## Benchmark (review point 3) The benchmark files are no longer in this PR, which is main plus the five commits above. Whether the benchmark belongs in the tree is decided on #2820. If it doesn't land, the table above can be reproduced from that branch. ## Overlap with #1356 #1356 (open, currently conflicting with main) also turns `SHADER_HEAPS`, `VIEWS` and `BUFFERS` into `RwLock`s, makes `made` an `RwLock`, and adds per-`HostList` shadow and view caches. Commits 1, 2 and 4 are a subset of it, offered as the smaller, measured version on current main. Commit 3 takes a different approach (lock-free reads of made slots), and commit 5 applies to either PR. #1356's caches go after the `RwLock` reader traffic that is left. #2121 also changes `HostHeap` slot making, so whichever of #2121 and this PR lands second must clear the `ready` marks in `take_back_pages` and `remakes`. ## Checks - `cargo clippy -p victory-gpu --all-targets -- -D warnings`, with and without `--features diagnostics`: clean. - `cargo test -p victory-gpu --lib`: 229 passed. The two failures are `descriptor::host::tests::dynamic_slots_are_held_until_released` and `memory::tests::lists_share_a_table_and_copies_keep_their_views`. Both already fail on main on this NVIDIA card (the heap cap, fixed by #2121). - With `--features diagnostics`, the same results as main on this machine: - `host::present_plane_tests::compositor_failure_presents_primary_in_the_same_frame` (from #1997) crashes the test process (exit 2173) every time it runs alone, on main's code too. It is skipped here. - `frame::tests::waits_end_on_ticks_and_count_frames` and `descriptor::host::tests::placed_uav_textures_create_real_host_uavs` fail intermittently on main and here alike. - `cargo xtask policy`: ok. ## Measured in the title @Jackster ran retail 1.0.2.1 on an RX 7900 XTX: a diagnostics build at 63bcca4 with this PR on a stack of #2703, #1010, #2985, #2849, #2908, #2472, #2958 and #3118, two 300 s world runs (`VICTORY_KEYS`), warm caches, same save. | | without | with | |---|---|---| | title threads waiting to write views (`MirrorWaitUs`) | 334.0 ms | 0.1 ms | | frame | 1,150 ms / 2,186 draws | 1,025 ms / 2,172 draws | | prepare | 428 ms | 422 ms | One run each. Slot counts differ between the runs because the title rewrote different pages.
fuzeofficlal commented 2026-11-25 22:04:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T21:40:54Z.


Verified 9b794b03 on Windows 11 (RTX 5090 + WARP, --features diagnostics):

  • cargo xtask policy: 186 files ok; cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default & --features diagnostics): 0 warnings.
  • Functional suites:
    • RTX 5090 (--features diagnostics --test-threads=1): descriptor:: 17 passed / 1 failed (only pre-existing >1M heap-limit dynamic_slots_are_held_until_released), shadow::tests 8/8 passed, bindless::tests 3/3 passed.
    • WARP (VICTORY_D3D12_WARP=1, --features diagnostics --test-threads=1): 198 passed, 0 failed, 2 ignored.
  • Same-machine --release list_calls benchmark on RTX 5090 (5 threads × 8,310 calls/frame × 10 frames, 0 dropped, 2 runs each):
    • Baseline (#2820 f7579ca0): 1495–1871 ns/call, 12.79–15.97 ms/frame wall (DrawIndexedInstanced 6065–7521 ns, CreateCBV 1344–1795 ns, CopyDescriptorsSimple 2407–3165 ns, Dispatch 1580–1867 ns)
    • With #2821 (9b794b03): 699–747 ns/call, 6.23–6.65 ms/frame wall (DrawIndexedInstanced 2584–2708 ns, CreateCBV 751–857 ns, CopyDescriptorsSimple 1801–2090 ns, Dispatch 1008–1084 ns) — ~53%–60% lower per-call time and >2× faster wall time.
  • Concurrency review looks sound: VIEWS.read() guards slot write against forget() (write()), HostHeap::ready pairs Acquire/Release with view_at(i, generation) validation and resets to 0 under made before mutating or evicting (leaving placed textures at 0 for lazy()), and shadow::find() re-runs innermost() and re-checks entry.shadow.is_none() after upgrading to the write lock.
  • Clean git merge-tree against origin/main 13f91ca, #2601, #2608, #2611, and #2668.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7175401021 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2821#issuecomment-7175401021). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T21:40:54Z. --- Verified `9b794b03` on Windows 11 (RTX 5090 + WARP, `--features diagnostics`): - `cargo xtask policy`: 186 files ok; `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default & `--features diagnostics`): 0 warnings. - Functional suites: - RTX 5090 (`--features diagnostics --test-threads=1`): `descriptor::` 17 passed / 1 failed (only pre-existing >1M heap-limit `dynamic_slots_are_held_until_released`), `shadow::tests` 8/8 passed, `bindless::tests` 3/3 passed. - WARP (`VICTORY_D3D12_WARP=1`, `--features diagnostics --test-threads=1`): 198 passed, 0 failed, 2 ignored. - Same-machine `--release` `list_calls` benchmark on RTX 5090 (`5` threads × `8,310` calls/frame × `10` frames, `0` dropped, 2 runs each): - Baseline (#2820 `f7579ca0`): `1495–1871 ns/call`, `12.79–15.97 ms/frame` wall (`DrawIndexedInstanced` `6065–7521 ns`, `CreateCBV` `1344–1795 ns`, `CopyDescriptorsSimple` `2407–3165 ns`, `Dispatch` `1580–1867 ns`) - With #2821 (`9b794b03`): `699–747 ns/call`, `6.23–6.65 ms/frame` wall (`DrawIndexedInstanced` `2584–2708 ns`, `CreateCBV` `751–857 ns`, `CopyDescriptorsSimple` `1801–2090 ns`, `Dispatch` `1008–1084 ns`) — **~53%–60% lower per-call time and >2× faster wall time**. - Concurrency review looks sound: `VIEWS.read()` guards slot write against `forget()` (`write()`), `HostHeap::ready` pairs `Acquire`/`Release` with `view_at(i, generation)` validation and resets to `0` under `made` before mutating or evicting (leaving placed textures at `0` for `lazy()`), and `shadow::find()` re-runs `innermost()` and re-checks `entry.shadow.is_none()` after upgrading to the write lock. - Clean `git merge-tree` against `origin/main` `13f91ca`, #2601, #2608, #2611, and #2668.
kotekompotek commented 2026-11-25 22:10:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T22:10:41Z.

Review: COMMENTED


Scoped review (the bulk is the list_bench harness): the behavioral change is a clean Mutex->RwLock split — all hot lookup paths (view_at, read_textures, mirror, with_host readers) take read locks while only record/forget/sync_heaps write, preserving the single-lock discipline so no new ordering is introduced. The record-side comment about the lock keeping forget from invalidating an in-flight write is the right generational-slot reasoning. The benchmark making the cost visible on the title's own threads is a good way to justify it. One thing worth a maintainer look: RwLock on this platform can let a writer starve under a steady read stream — if forget/evict latency ever matters (resource teardown during streaming), worth confirming the writer path isn't delayed noticeably.

<!-- greyfinch-sync:Marvisak/VIctory:review:6065686215 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2821#pullrequestreview-6065686215). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T22:10:41Z. **Review:** COMMENTED --- Scoped review (the bulk is the list_bench harness): the behavioral change is a clean Mutex->RwLock split — all hot lookup paths (view_at, read_textures, mirror, with_host readers) take read locks while only record/forget/sync_heaps write, preserving the single-lock discipline so no new ordering is introduced. The record-side comment about the lock keeping forget from invalidating an in-flight write is the right generational-slot reasoning. The benchmark making the cost visible on the title's own threads is a good way to justify it. One thing worth a maintainer look: RwLock on this platform can let a writer starve under a steady read stream — if forget/evict latency ever matters (resource teardown during streaming), worth confirming the writer path isn't delayed noticeably.
0xkn0wh3r3 commented 2026-11-25 23:06:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T22:20:49Z.


A note for whichever of #2121 and #2821 lands second: they merge cleanly but clash in HostHeap::mirror.

  • #2821 adds a lock-free ready check that skips a slot already made from the same record.
  • #2121's page reclaiming keeps each slot's made record when it takes a page back, so a page placed again is never remade: host::tests::view_heap_pages_taken_back_are_placed_again_when_read fails at "made from the title's record".

The fix is to clear ready for a page's slots in take_back_pages and in remakes (crates/victory-gpu/src/descriptor/host.rs). I'll add it to whichever branch lands second.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176247557 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2821#issuecomment-7176247557). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T22:20:49Z. --- A note for whichever of #2121 and #2821 lands second: they merge cleanly but clash in `HostHeap::mirror`. - #2821 adds a lock-free `ready` check that skips a slot already made from the same record. - #2121's page reclaiming keeps each slot's `made` record when it takes a page back, so a page placed again is never remade: `host::tests::view_heap_pages_taken_back_are_placed_again_when_read` fails at "made from the title's record". The fix is to clear `ready` for a page's slots in `take_back_pages` and in `remakes` (crates/victory-gpu/src/descriptor/host.rs). I'll add it to whichever branch lands second.
Marvisak commented 2026-11-26 03:05:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T02:21:57Z.


Automated triage for the maintainers.

Thanks for af969fd. The benchmark files are gone, and the description now goes through each concurrent pair and the nested-lock question. I checked the main points against the code. In HostHeap::mirror, ready is set last under made and only for slots that needs_remake can never pick (non-textures, and textures that are held and not placed). It is cleared before every remake, null and evict. record drops its VIEWS read guard before calling mirror. evict now picks its slots again under made.

One cross-PR point: #2895 (open) adds an owner_moved check to mirror that remakes buffer slots when the innermost title buffer changes. The ready fast path here would return before that check. Whichever of the two lands second needs to clear ready on owner changes, or leave buffer slots out of it. The same applies to #2121's take_back_pages/remakes, as you noted.

CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7180735291 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2821#issuecomment-7180735291). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T02:21:57Z. --- <!-- victory-triage v1 head=af969fdc838450000f7d145200c1e9b70190ae1d verdict=merge-candidate at=2026-11-26T07:22:56Z --> Automated triage for the maintainers. Thanks for `af969fd`. The benchmark files are gone, and the description now goes through each concurrent pair and the nested-lock question. I checked the main points against the code. In `HostHeap::mirror`, `ready` is set last under `made` and only for slots that `needs_remake` can never pick (non-textures, and textures that are held and not placed). It is cleared before every remake, null and evict. `record` drops its `VIEWS` read guard before calling `mirror`. `evict` now picks its slots again under `made`. **One cross-PR point:** #2895 (open) adds an `owner_moved` check to `mirror` that remakes buffer slots when the innermost title buffer changes. The `ready` fast path here would return before that check. Whichever of the two lands second needs to clear `ready` on owner changes, or leave buffer slots out of it. The same applies to #2121's `take_back_pages`/`remakes`, as you noted. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
liandraraiane commented 2026-11-26 03:05:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by liandraraiane on 2026-11-26T02:48:13Z.


A/B on an RTX 3060 (driver 610.88) with a Ryzen 7 5700G (16 threads), list_calls with LIST_BENCH_FRAMES=20, the bench-only commit against this PR's head, runs alternated, 0 dropped draws in every run. ms for all threads to record a frame, median of 5:

threads bench only cdc91bc this PR cfbb10a speed-up
5 13.34 7.16 1.86x
16 51.58 23.55 2.19x

The previous head (9b794b0 vs f7579ca) gave the same picture at 1, 5, 8 and 16 threads: 3.84 → 3.56, 14.21 → 7.74, 26.95 → 11.98 and 62.67 → 24.44 ms. With this PR, per-call cost still grows from one thread to sixteen (about 390 → 2,700 ns), so some contention remains. Not tested: a title; only this synthetic bench.

AI use: Claude Code ran the benchmarks on this machine and drafted this comment.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7181132742 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2821#issuecomment-7181132742). Originally posted by [liandraraiane](https://github.com/liandraraiane) on 2026-11-26T02:48:13Z. --- A/B on an RTX 3060 (driver 610.88) with a Ryzen 7 5700G (16 threads), `list_calls` with `LIST_BENCH_FRAMES=20`, the bench-only commit against this PR's head, runs alternated, 0 dropped draws in every run. ms for all threads to record a frame, median of 5: | threads | bench only `cdc91bc` | this PR `cfbb10a` | speed-up | |---|---|---|---| | 5 | 13.34 | 7.16 | 1.86x | | 16 | 51.58 | 23.55 | 2.19x | The previous head (`9b794b0` vs `f7579ca`) gave the same picture at 1, 5, 8 and 16 threads: 3.84 → 3.56, 14.21 → 7.74, 26.95 → 11.98 and 62.67 → 24.44 ms. With this PR, per-call cost still grows from one thread to sixteen (about 390 → 2,700 ns), so some contention remains. Not tested: a title; only this synthetic bench. AI use: Claude Code ran the benchmarks on this machine and drafted this comment.
0xkn0wh3r3 commented 2026-11-26 07:01:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T06:42:00Z.


Addressed in af969fd. The benchmark files are gone, so the PR now carries only the locking change (descriptor.rs, descriptor/host.rs, shadow.rs) on current main. The description now lists each pair of functions that can run at the same time under the read locks and why each pair is safe, and confirms that no path takes SHADER_HEAPS.read() or VIEWS.read() again while already holding it. The benchmark stays in #2820 for your decision.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7184693676 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2821#issuecomment-7184693676). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T06:42:00Z. --- Addressed in af969fd. The benchmark files are gone, so the PR now carries only the locking change (`descriptor.rs`, `descriptor/host.rs`, `shadow.rs`) on current main. The description now lists each pair of functions that can run at the same time under the read locks and why each pair is safe, and confirms that no path takes `SHADER_HEAPS.read()` or `VIEWS.read()` again while already holding it. The benchmark stays in #2820 for your decision.
passerbyyhx commented 2026-11-26 08:03:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-11-26T07:52:18Z.


I checked the new HostHeap::evict recheck at af969fd on an RTX 4090 Laptop and WARP with the D3D12 debug layer. Eviction first selects two slots that both view red texture A. Before it takes made, a title write rebinds slot 0 to green texture B. The GPU reads both original heap slots directly as green / red before eviction resumes.

On the parent 707b9396, the final read is transparent black / transparent black on both devices. On af969fd, it is green / transparent black on both: eviction preserves the rewrite and still clears the other slot viewing A. The readback never calls mirror to refresh the slots.

Portable test on the author branch · Coordination claim

<!-- greyfinch-sync:Marvisak/VIctory:comment:7185926532 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2821#issuecomment-7185926532). Originally posted by [passerbyyhx](https://github.com/passerbyyhx) on 2026-11-26T07:52:18Z. --- I checked the new `HostHeap::evict` recheck at `af969fd` on an RTX 4090 Laptop and WARP with the D3D12 debug layer. Eviction first selects two slots that both view red texture A. Before it takes `made`, a title write rebinds slot 0 to green texture B. The GPU reads both original heap slots directly as **green / red** before eviction resumes. On the parent `707b9396`, the final read is **transparent black / transparent black** on both devices. On `af969fd`, it is **green / transparent black** on both: eviction preserves the rewrite and still clears the other slot viewing A. The readback never calls `mirror` to refresh the slots. [Portable test on the author branch](https://github.com/0xkn0wh3r3/VIctory/pull/6) · [Coordination claim](https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7185653217)
Dukestar69 commented 2026-11-26 09:49:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T09:49:01Z.

Review: APPROVED


Verified on RTX 5090 against origin/main (63bcca4):

  • cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 20/20 passed.
  • cargo test -p victory-gpu --lib descriptor::host:: -- --test-threads=1 --skip dynamic_slots_are_held_until_released: 14/14 passed.
  • cargo test -p victory-gpu --lib shadow:: -- --test-threads=1: 10/10 passed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Cleanly reduces lock contention between title command-list recording threads and descriptor/buffer-copy updates.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6071839156 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2821#pullrequestreview-6071839156). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T09:49:01Z. **Review:** APPROVED --- Verified on RTX 5090 against `origin/main` (`63bcca4`): - `cargo test -p victory-gpu --lib draw:: -- --test-threads=1`: 20/20 passed. - `cargo test -p victory-gpu --lib descriptor::host:: -- --test-threads=1 --skip dynamic_slots_are_held_until_released`: 14/14 passed. - `cargo test -p victory-gpu --lib shadow:: -- --test-threads=1`: 10/10 passed. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Cleanly reduces lock contention between title command-list recording threads and descriptor/buffer-copy updates. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal commented 2026-11-26 10:22:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T10:22:52Z.

Review: APPROVED


Audited all five commits for lock ordering, re-entrancy, and HostHeap::ready / evict concurrency invariants, and verified on Windows 11 (RTX 5090 + WARP + D3D12 Debug Layer).

Concurrency audit summary

  • RwLock conversions (SHADER_HEAPS, VIEWS, shadow::BUFFERS): verified no reader re-enters the same lock and lock ordering is preserved across all call sites (record drops VIEWS.read() before mirror; shadow::find drops BUFFERS.read() before loose; all/near drop the read guard before taking LOOSE; Heap::drop drops SHADER_HEAPS.write() before memory::release).
  • HostHeap::ready fast path (descriptor/host.rs): matches needs_remake() exactly — generations start at 1 (wrapping with .max(1)) so valid keys are never 0; placed textures and null-kept texture views stay at 0; ready is cleared before mutating or evicting a slot under made and published last with Ordering::Release after stride, address, descriptor, mark, viewed, and kept updates, paired with Ordering::Acquire + view_at(i, generation) validation on read.
  • HostHeap::evict re-check (af969fdc): re-filtering slots under made → kept keeps the lock order identical to mirror (no ABBA deadlock) and closes the window where a concurrent view write rewrote a slot before eviction nulled it.

Hardware & WARP verification (origin/main 63bcca43 merge-tree clean)

  • cargo clippy --workspace --all-targets --locked -- -D warnings (default & --all-features): clean; cargo xtask policy: 191 files ok.
  • RTX 5090: descriptor:: default-parallel 5× consecutive runs 21/21 passed each round (skipping pre-existing NVIDIA 1M-cap dynamic_slots_are_held_until_released); shadow:: 10/10, memory:: 7/7 (skipping pre-existing 1M-cap lists_share_a_table_and_copies_keep_their_views), draw:: 20/20.
  • RTX 5090 + VICTORY_D3D12_DEBUG=1: descriptor:: + shadow:: 31/31 passed.
  • WARP + VICTORY_D3D12_DEBUG=1 (no 1M heap cap): descriptor:: 22/22, memory:: + shadow:: 18/18, draw:: 20/20 (60/60 passed).
<!-- greyfinch-sync:Marvisak/VIctory:review:6072346157 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2821#pullrequestreview-6072346157). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T10:22:52Z. **Review:** APPROVED --- Audited all five commits for lock ordering, re-entrancy, and `HostHeap::ready` / `evict` concurrency invariants, and verified on Windows 11 (RTX 5090 + WARP + D3D12 Debug Layer). ### Concurrency audit summary - **`RwLock` conversions (`SHADER_HEAPS`, `VIEWS`, `shadow::BUFFERS`)**: verified no reader re-enters the same lock and lock ordering is preserved across all call sites (`record` drops `VIEWS.read()` before `mirror`; `shadow::find` drops `BUFFERS.read()` before `loose`; `all`/`near` drop the read guard before taking `LOOSE`; `Heap::drop` drops `SHADER_HEAPS.write()` before `memory::release`). - **`HostHeap::ready` fast path (`descriptor/host.rs`)**: matches `needs_remake()` exactly — generations start at 1 (wrapping with `.max(1)`) so valid keys are never 0; placed textures and null-kept texture views stay at `0`; `ready` is cleared before mutating or evicting a slot under `made` and published last with `Ordering::Release` after stride, address, descriptor, mark, `viewed`, and `kept` updates, paired with `Ordering::Acquire` + `view_at(i, generation)` validation on read. - **`HostHeap::evict` re-check (`af969fdc`)**: re-filtering `slots` under `made` → `kept` keeps the lock order identical to `mirror` (no ABBA deadlock) and closes the window where a concurrent view write rewrote a slot before eviction nulled it. ### Hardware & WARP verification (`origin/main` `63bcca43` merge-tree clean) - `cargo clippy --workspace --all-targets --locked -- -D warnings` (default & `--all-features`): clean; `cargo xtask policy`: 191 files ok. - RTX 5090: `descriptor::` default-parallel 5× consecutive runs **21/21 passed** each round (skipping pre-existing NVIDIA 1M-cap `dynamic_slots_are_held_until_released`); `shadow::` **10/10**, `memory::` **7/7** (skipping pre-existing 1M-cap `lists_share_a_table_and_copies_keep_their_views`), `draw::` **20/20**. - RTX 5090 + `VICTORY_D3D12_DEBUG=1`: `descriptor::` + `shadow::` **31/31 passed**. - WARP + `VICTORY_D3D12_DEBUG=1` (no 1M heap cap): `descriptor::` **22/22**, `memory::` + `shadow::` **18/18**, `draw::` **20/20** (**60/60 passed**).
Jackster commented 2026-11-26 13:04:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T12:15:33Z.


Confirmed on the retail title: 334 ms of title-thread waiting -> 0.1 ms

Setup: Windows 11, RX 7900 XTX (RDNA3, 64-lane waves), Ryzen 9 3950X; retail 1.0.2.1; diagnostics build at 63bcca4 with this PR merged onto a stack of #2703 #1010 #2985 #2849 #2908 #2472 #2958 #3118; two 300 s world runs driven with VICTORY_KEYS, warm caches, same save.

without #2821 with #2821
title threads waiting to write views (MirrorWaitUs) 334.0 ms 0.1 ms
frame 1,150 ms / 2,186 draws 1,025 ms / 2,172 draws
heap slots the title copied 127.7 ms / 550,912 261.3 ms / 316,757
prepare 428 ms 422 ms

The counter is the one in descriptor::mirror around SHADER_HEAPS, printed by copystat as "title threads waiting to write views", so this is the title's recording threads on the engine itself, not the benchmark in #2820. With the wait gone the frame is 11% shorter at the same draw count.

Caveats: one run each; the two runs differ in slot counts because the title rewrote different pages. Nothing else in the tree changed between them.

Written with an AI assistant.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7191771149 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2821#issuecomment-7191771149). Originally posted by [Jackster](https://github.com/Jackster) on 2026-11-26T12:15:33Z. --- **Confirmed on the retail title: 334 ms of title-thread waiting -> 0.1 ms** Setup: Windows 11, RX 7900 XTX (RDNA3, 64-lane waves), Ryzen 9 3950X; retail 1.0.2.1; diagnostics build at `63bcca4` with this PR merged onto a stack of #2703 #1010 #2985 #2849 #2908 #2472 #2958 #3118; two 300 s world runs driven with `VICTORY_KEYS`, warm caches, same save. | | without #2821 | with #2821 | |---|---|---| | `title threads waiting to write views` (`MirrorWaitUs`) | **334.0 ms** | **0.1 ms** | | frame | 1,150 ms / 2,186 draws | 1,025 ms / 2,172 draws | | heap slots the title copied | 127.7 ms / 550,912 | 261.3 ms / 316,757 | | prepare | 428 ms | 422 ms | The counter is the one in `descriptor::mirror` around `SHADER_HEAPS`, printed by `copystat` as "title threads waiting to write views", so this is the title's recording threads on the engine itself, not the benchmark in #2820. With the wait gone the frame is 11% shorter at the same draw count. Caveats: one run each; the two runs differ in slot counts because the title rewrote different pages. Nothing else in the tree changed between them. Written with an AI assistant.
0xkn0wh3r3 commented 2026-11-26 13:04:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T12:16:53Z.


Thanks @Jackster, that's the in-game number this PR was missing: the title's recording threads stop waiting on the heap lock (334 ms to 0.1 ms per frame on that counter). I've added your table to the description, with the one-run caveat.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7191799984 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2821#issuecomment-7191799984). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T12:16:53Z. --- Thanks @Jackster, that's the in-game number this PR was missing: the title's recording threads stop waiting on the heap lock (334 ms to 0.1 ms per frame on that counter). I've added your table to the description, with the one-run caveat.
KainanP commented 2026-11-26 15:02:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by KainanP on 2026-11-26T14:50:09Z.


Measured on main 63bcca4 with this PR merged, with a different benchmark from #2820's: it draws with six textures through a table and three root constant buffers (RTX 4060 Laptop, release, median of 7 interleaved runs; method in https://github.com/Marvisak/VIctory/issues/2586#issuecomment-7195391455):

  • HostHeap::mirror for an unchanged slot: 43 → 18 ns
  • one thread: 2780 → 2731 ns per draw. Five threads at once: 10526 → 8170 ns per draw per thread.
  • with #1978, #2102, #3005 and #3061 also merged, five threads: 4539 ns, against 6664 for #1978 alone. This PR is the one that pays off under contention.

AI use: Claude Code (Claude Opus 5.5) ran the measurements and drafted this comment.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7195399079 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2821#issuecomment-7195399079). Originally posted by [KainanP](https://github.com/KainanP) on 2026-11-26T14:50:09Z. --- Measured on main 63bcca4 with this PR merged, with a different benchmark from #2820's: it draws with six textures through a table and three root constant buffers (RTX 4060 Laptop, release, median of 7 interleaved runs; method in https://github.com/Marvisak/VIctory/issues/2586#issuecomment-7195391455): - `HostHeap::mirror` for an unchanged slot: 43 → 18 ns - one thread: 2780 → 2731 ns per draw. Five threads at once: 10526 → 8170 ns per draw per thread. - with #1978, #2102, #3005 and #3061 also merged, five threads: 4539 ns, against 6664 for #1978 alone. This PR is the one that pays off under contention. _AI use: Claude Code (Claude Opus 5.5) ran the measurements and drafted this comment._
KainanP commented 2026-11-27 12:31:18 +00:00 (Migrated from github.com)

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


This PR also makes SHADER_HEAPS a RwLock, the change #3425 points at, so here are contention numbers (af969fd against its base 63bcca4):

base #2821
title-thread wait per frame, RTX, 12 runs 49.5 ms 12.0 ms
per-write p99 / max 9.7 ms / 12.9 ms 52 µs / 0.5 ms
view writes per frame (5 threads, 20 µs apart) 207 3,710
sync_heaps 9.6 ms 17.5 ms
same, writes 200 µs apart (5 runs): wait / sync 45.3 / 9.1 ms 1.0 / 9.7 ms
Intel UHD (a78b), 20 µs: wait / sync 52.0 / 10.1 ms 26.3 / 25.2 ms

Title threads stop queueing behind the sync. The sync itself gets slower as more views are written while it runs, probably because it now contends with their mirrors on made and VIEWS. That fits neonbyte1's in-game +30 ms of "preparing" for the same read-shared lock in #2848 (fd7de0f6, since dropped there). No views were lost or stale, and the full victory-gpu suite on RTX fails only the two tests that main also fails here.

Bench: sync_contention_bench (#[ignore]d; commit f34bcfb8, cherry-picks onto any tree). A placed, write-watched view heap of 2^20 slots (the host heap caps it at 934,464 here). Each frame, one thread rewrites 200 random 64 KiB pages (50 changed records each) and runs one sync_heaps, while 5 title threads write a placed-buffer SRV every 20 µs into pages of their own. "Wait" is the title threads' time in view writes beyond the uncontended 2–3 µs, summed per frame. Release build, RTX 4060 Laptop, runs interleaved with the base, medians of 30 frames per run. The bench also checks that every view written before a sync is the slot's view address after it, and that every slot is right after a final quiet sync.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7218340241 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2821#issuecomment-7218340241). Originally posted by [KainanP](https://github.com/KainanP) on 2026-11-27T12:31:18Z. --- This PR also makes `SHADER_HEAPS` a `RwLock`, the change #3425 points at, so here are contention numbers (`af969fd` against its base `63bcca4`): | | base | #2821 | |---|---|---| | title-thread wait per frame, RTX, 12 runs | 49.5 ms | **12.0 ms** | | per-write p99 / max | 9.7 ms / 12.9 ms | **52 µs / 0.5 ms** | | view writes per frame (5 threads, 20 µs apart) | 207 | 3,710 | | `sync_heaps` | 9.6 ms | **17.5 ms** | | same, writes 200 µs apart (5 runs): wait / sync | 45.3 / 9.1 ms | 1.0 / 9.7 ms | | Intel UHD (a78b), 20 µs: wait / sync | 52.0 / 10.1 ms | 26.3 / 25.2 ms | Title threads stop queueing behind the sync. The sync itself gets slower as more views are written while it runs, probably because it now contends with their `mirror`s on `made` and `VIEWS`. That fits neonbyte1's in-game +30 ms of "preparing" for the same read-shared lock in #2848 (`fd7de0f6`, since dropped there). No views were lost or stale, and the full `victory-gpu` suite on RTX fails only the two tests that `main` also fails here. Bench: [`sync_contention_bench`](https://github.com/KainanP/VIctory/blob/bench/sync-heaps-contention/crates/victory-gpu/src/descriptor/sync_bench.rs) (`#[ignore]`d; commit `f34bcfb8`, cherry-picks onto any tree). A placed, write-watched view heap of 2^20 slots (the host heap caps it at 934,464 here). Each frame, one thread rewrites 200 random 64 KiB pages (50 changed records each) and runs one `sync_heaps`, while 5 title threads write a placed-buffer SRV every 20 µs into pages of their own. "Wait" is the title threads' time in view writes beyond the uncontended 2–3 µs, summed per frame. Release build, RTX 4060 Laptop, runs interleaved with the base, medians of 30 frames per run. The bench also checks that every view written before a sync is the slot's view address after it, and that every slot is right after a final quiet sync. _AI use: Claude Code (Claude Opus 5.5)._
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/2821:upstream-pr/2821'
git switch 'upstream-pr/2821'

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/2821'
git switch 'upstream-pr/2821'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2821'
git switch 'upstream-pr/2821'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2821'
git switch 'main'
git merge --squash 'upstream-pr/2821'
git switch 'main'
git merge --ff-only 'upstream-pr/2821'
git switch 'main'
git merge 'upstream-pr/2821'
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!2819
No description provided.