perf(gpu): batch dynamic descriptor release, 64-way padded RETIRED with oldest watermark, and scratch_held_with_base #26

Closed
github-bot wants to merge 1 commit from gh-pr/26/head into gh-pr/26/base
Owner

@⁠justadudeinbulgaria on GitHub · 2026-12-01 18:16 UTC · original
justadudeinbulgaria:pr/descriptor-batch-retired-64 → main · +193 −26 · 4 files · 1 commits · closed without merging

Summary

Cherry-picks the three genuine lock/COM-overhead wins from Androtim/MiniVI#288 adapted cleanly to VIctory-Hydra's existing bits::two_ended_run, DYNAMIC_SLAB, CopyRun, and bury_lag() architecture:

  1. Batched dynamic slot release (descriptor.rs, descriptor/host.rs, draw.rs):
    • Adds descriptor::release_dynamic_batch() and HostHeap::release_batch(), collapsing per-table SHADER_HEAPS.read() + HostHeap::next.lock() loops in State::tables_done() and Drop for State into a single read lock + single heap lock per contiguous heap run.
    • Folds any remaining active self.slab directly into self.dynamic on tables_done() / Drop (eliminating an extra lock for the unused tail), preserves the guard.0 = guard.0.min(min_at) lowest-free hint for bits::two_ended_run, and notifies list::thin::moved() once after releasing the lock.
  2. 64-way cache-line-padded RETIRED shards + lock-free oldest watermark (host.rs):
    • Upgrades RETIRED from 16 unpadded [Mutex<VecDeque>; 16] entries to 64 #[repr(align(64))] struct RetiredShard entries with an atomic oldest: AtomicU64 watermark, eliminating cache-line false sharing across recording/list threads and letting bury() skip empty/not-ready shards with one lock-free Acquire load.
    • Preserves let finished = finished.saturating_sub(bury_lag()); strictly before uav_pool::drain_retired_uavs(finished).
  3. HostList::scratch_held_with_base + HostHeap::constant_at_with_base (host.rs, descriptor/host.rs, draw.rs):
    • Returns the scratch buffer's base GPU virtual address alongside gpu so constant_at_with_base() skips a redundant ID3D12Resource::GetGPUVirtualAddress() COM call per CBV slot when VICTORY_PORT_CBV=0.

Verification

  • Zero shader-cache invalidation (crates/victory-shader/* and shader_cache.rs untouched).
  • Unit tests on origin/main (48413c9):
    • descriptor:: + host::retired_tests::sharded_retired_queues_drain_across_threads_in_order: all passed
    • VICTORY_DYNAMIC_SLAB=0 draw::: 7/7 passed
  • Live gameplay (i5-10600K 6C/12T + RTX 2060 SUPER 8 GB): Verified together with PR 1 & PR 3 — SUB dropped from 51.5 ms to 32.4–44.8 ms, live FRAME dropped from 104.5 ms to 85.0–93.4 ms, 0 descriptor waits, 0 drops/visual artifacts.
**@⁠justadudeinbulgaria** on GitHub · 2026-12-01 18:16 UTC · [original](https://github.com/ToLIManl/VIctory-Hydra/pull/26) `justadudeinbulgaria:pr/descriptor-batch-retired-64` → `main` · +193 −26 · 4 files · 1 commits · closed without merging ## Summary Cherry-picks the three genuine lock/COM-overhead wins from `Androtim/MiniVI#288` adapted cleanly to VIctory-Hydra's existing `bits::two_ended_run`, `DYNAMIC_SLAB`, `CopyRun`, and `bury_lag()` architecture: 1. **Batched dynamic slot release (`descriptor.rs`, `descriptor/host.rs`, `draw.rs`)**: - Adds `descriptor::release_dynamic_batch()` and `HostHeap::release_batch()`, collapsing per-table `SHADER_HEAPS.read()` + `HostHeap::next.lock()` loops in `State::tables_done()` and `Drop for State` into a single read lock + single heap lock per contiguous heap run. - Folds any remaining active `self.slab` directly into `self.dynamic` on `tables_done()` / `Drop` (eliminating an extra lock for the unused tail), preserves the `guard.0 = guard.0.min(min_at)` lowest-free hint for `bits::two_ended_run`, and notifies `list::thin::moved()` once after releasing the lock. 2. **64-way cache-line-padded `RETIRED` shards + lock-free `oldest` watermark (`host.rs`)**: - Upgrades `RETIRED` from 16 unpadded `[Mutex<VecDeque>; 16]` entries to 64 `#[repr(align(64))] struct RetiredShard` entries with an atomic `oldest: AtomicU64` watermark, eliminating cache-line false sharing across recording/list threads and letting `bury()` skip empty/not-ready shards with one lock-free `Acquire` load. - Preserves `let finished = finished.saturating_sub(bury_lag());` strictly **before** `uav_pool::drain_retired_uavs(finished)`. 3. **`HostList::scratch_held_with_base` + `HostHeap::constant_at_with_base` (`host.rs`, `descriptor/host.rs`, `draw.rs`)**: - Returns the scratch buffer's base GPU virtual address alongside `gpu` so `constant_at_with_base()` skips a redundant `ID3D12Resource::GetGPUVirtualAddress()` COM call per CBV slot when `VICTORY_PORT_CBV=0`. ## Verification - **Zero shader-cache invalidation** (`crates/victory-shader/*` and `shader_cache.rs` untouched). - **Unit tests** on `origin/main` (`48413c9`): - `descriptor::` + `host::retired_tests::sharded_retired_queues_drain_across_threads_in_order`: **all passed** - `VICTORY_DYNAMIC_SLAB=0` `draw::`: **7/7 passed** - **Live gameplay (i5-10600K 6C/12T + RTX 2060 SUPER 8 GB)**: Verified together with PR 1 & PR 3 — `SUB` dropped from `51.5 ms` to `32.4–44.8 ms`, live `FRAME` dropped from `104.5 ms` to `85.0–93.4 ms`, `0` descriptor waits, `0` drops/visual artifacts.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 17:09:11 +00:00
github-bot closed this pull request 2026-12-02 17:09:11 +00:00
Author
Owner

@⁠ToLIManl on GitHub · 2026-12-02 12:54 UTC · original

Thank you @⁠justadudeinbulgaria! Integrated onto v2.0 main in commit 5d7f3ef with full Co-authored-by credit:

  • Ported 64-way #[repr(align(64))] cache-padded RETIRED shards with atomic oldest watermark and fast-skip in bury() (host.rs, plus updated host/membench.rs), preserving v2.0's monotonic fence invariant.
  • Ported scratch_held_with_base (host.rs) and constant_at_with_base (descriptor/host.rs) to avoid redundant GetGPUVirtualAddress() COM calls.
  • (Note: release_dynamic_batch was already present in v2.0 descriptor.rs.)

Built, unit-tested, and shipped in the refreshed VIctory-Hydra-v2.0-Stage17.zip release. Closing since the PR targeted pre-v2.0 history and is now landed on main.

**@⁠ToLIManl** on GitHub · 2026-12-02 12:54 UTC · [original](https://github.com/ToLIManl/VIctory-Hydra/pull/26#issuecomment-7346062575) Thank you @⁠justadudeinbulgaria! Integrated onto v2.0 `main` in commit `5d7f3ef` with full `Co-authored-by` credit: - Ported 64-way `#[repr(align(64))]` cache-padded `RETIRED` shards with atomic `oldest` watermark and fast-skip in `bury()` (`host.rs`, plus updated `host/membench.rs`), preserving v2.0's monotonic fence invariant. - Ported `scratch_held_with_base` (`host.rs`) and `constant_at_with_base` (`descriptor/host.rs`) to avoid redundant `GetGPUVirtualAddress()` COM calls. - *(Note: `release_dynamic_batch` was already present in v2.0 `descriptor.rs`.)* Built, unit-tested, and shipped in the refreshed `VIctory-Hydra-v2.0-Stage17.zip` release. Closing since the PR targeted pre-v2.0 history and is now landed on `main`.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.