perf(gpu): batch dynamic descriptor release and add lock-free fast path in mirror #52

Merged
ahmetbagci8 merged 1 commit from upstream-pr/52 into main 2026-12-01 17:46:28 +00:00
ahmetbagci8 commented 2026-12-01 16:50:37 +00:00 (Migrated from github.com)

Imported from edsuuu/VI-BR-PORT. Originally posted by ahmetbagci8 on 2026-12-01T16:50:37Z.


Towards #27 (lower per-frame CPU preparing cost).

Problem

  1. Per-table lock churn on dynamic slot release: A frame allocates 12,500-35,000 dynamic descriptor tables (State::dynamic). State::tables_done() and State::drop() released them one entry at a time via
    elease_dynamic(), acquiring SHADER_HEAPS.read(), linearly scanning SHADER_HEAPS, acquiring host.next.lock() (contending with recording threads calling HostHeap::dynamic()), and issuing atomic updates for every single table.
  2. Unconditional pending mutex in descriptor::mirror(): Every descriptor write into a shader-visible heap locked heap.pending before checking heap.host.get() (OnceLock), even though heap.host is permanently initialized after the first draw and pending is never used again.

Changes

  • Add HostHeap::release_batch() and descriptor::release_dynamic_batch() to take SHADER_HEAPS.read() once and host.next.lock() once per contiguous run of the same title heap, accumulating ree and updating oo_long once per batch. Use it in State::tables_done() and State::drop().
  • Check heap.host.get() before locking heap.pending in descriptor::mirror().

Verification

  • cargo test -p victory-gpu --lib dynamic_slots (passed)
  • cargo clippy -p victory-gpu --tests (0 warnings)
  • cargo test -p xtask english (5 passed, 0 failed)
<!-- greyfinch-sync:edsuuu/VI-BR-PORT:issue:5590289908 --> Imported from [edsuuu/VI-BR-PORT](https://github.com/edsuuu/VI-BR-PORT/pull/52). Originally posted by [ahmetbagci8](https://github.com/ahmetbagci8) on 2026-12-01T16:50:37Z. --- Towards #27 (lower per-frame CPU preparing cost). ## Problem 1. **Per-table lock churn on dynamic slot release:** A frame allocates 12,500-35,000 dynamic descriptor tables (State::dynamic). State::tables_done() and State::drop() released them one entry at a time via elease_dynamic(), acquiring SHADER_HEAPS.read(), linearly scanning SHADER_HEAPS, acquiring host.next.lock() (contending with recording threads calling HostHeap::dynamic()), and issuing atomic updates for every single table. 2. **Unconditional pending mutex in descriptor::mirror():** Every descriptor write into a shader-visible heap locked heap.pending before checking heap.host.get() (OnceLock), even though heap.host is permanently initialized after the first draw and pending is never used again. ## Changes - Add HostHeap::release_batch() and descriptor::release_dynamic_batch() to take SHADER_HEAPS.read() once and host.next.lock() once per contiguous run of the same title heap, accumulating ree and updating oo_long once per batch. Use it in State::tables_done() and State::drop(). - Check heap.host.get() before locking heap.pending in descriptor::mirror(). ## Verification - cargo test -p victory-gpu --lib dynamic_slots (passed) - cargo clippy -p victory-gpu --tests (0 warnings) - cargo test -p xtask english (5 passed, 0 failed)
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
edsuuu/VI-BR-PORT!52
No description provided.