perf(descriptor): defer TextureQueue WRITE ops to per-heap pending inbox with inline QueueBatch #3104

Closed
github-bot wants to merge 2 commits from github-bot/gh-3104 into main AGit
Owner

@⁠qlfu on GitHub · 2026-11-29 20:02 UTC · original
qlfu:pr/perf-texture-queue-pending-inbox → main · +356 −128 · 2 files · 2 commits · closed without merging

Summary

Eliminates ~98% of global TextureQueue mutex traffic (TextureQueue::WRITE) caused by per-slot mirror(handle) calls during descriptor::record and sync_heaps:

  • Per-HostHeap pending_ops inbox + pending_count (on by default; VICTORY_QUEUE_PENDING=0 disables): single-slot mirror writes append into a per-heap inbox rather than locking the global TextureQueue on every descriptor slot.
  • 2-bit STATE_KEEPS | STATE_PENDING SeqCst CAS Dekker handshake: guarantees draining readers never miss a newly queued op while keeping the uncontended fast path lock-free.
  • Inline [QueueOp; 64] QueueBatch: avoids heap allocation for normal batches.
  • Direct host.mirror fast path in single-slot mirror_in_heaps.

Verification

  • cargo +1.98.1-x86_64-pc-windows-msvc clippy -p victory-gpu --lib --tests --no-deps --locked: 0 new warnings.
  • cargo +1.98.1-x86_64-pc-windows-msvc test -p victory-gpu --lib --locked -- descriptor::host::tests --test-threads=1: 71/71 passed.
  • Live 90s benchmarks (1440p DLSS Balanced, 0 WARNs / 0 ERRORs):
    • TextureQueue locks/5s: 84,418–85,323 -> 1,538–1,682 (-98.0%).
    • TextureQueue lock wait/5s: 376–492 ms -> 8–12 ms (-97.5%), noting 342–470 ms -> 0 ms.
    • sync_heaps wait: 1.55–1.75 ms -> 0.72–1.33 ms.
**@⁠qlfu** on GitHub · 2026-11-29 20:02 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3104) `qlfu:pr/perf-texture-queue-pending-inbox` → `main` · +356 −128 · 2 files · 2 commits · closed without merging ## Summary Eliminates ~98% of global `TextureQueue` mutex traffic (`TextureQueue::WRITE`) caused by per-slot `mirror(handle)` calls during `descriptor::record` and `sync_heaps`: - **Per-`HostHeap` `pending_ops` inbox + `pending_count`** (on by default; `VICTORY_QUEUE_PENDING=0` disables): single-slot `mirror` writes append into a per-heap inbox rather than locking the global `TextureQueue` on every descriptor slot. - **2-bit `STATE_KEEPS | STATE_PENDING` `SeqCst` CAS Dekker handshake**: guarantees draining readers never miss a newly queued op while keeping the uncontended fast path lock-free. - **Inline `[QueueOp; 64]` `QueueBatch`**: avoids heap allocation for normal batches. - **Direct `host.mirror` fast path** in single-slot `mirror_in_heaps`. ## Verification - `cargo +1.98.1-x86_64-pc-windows-msvc clippy -p victory-gpu --lib --tests --no-deps --locked`: 0 new warnings. - `cargo +1.98.1-x86_64-pc-windows-msvc test -p victory-gpu --lib --locked -- descriptor::host::tests --test-threads=1`: `71/71` passed. - Live 90s benchmarks (1440p DLSS Balanced, `0 WARNs / 0 ERRORs`): - `TextureQueue` locks/5s: `84,418–85,323` -> **`1,538–1,682` (`-98.0%`)**. - `TextureQueue` lock wait/5s: `376–492 ms` -> **`8–12 ms` (`-97.5%`)**, `noting` `342–470 ms` -> **`0 ms`**. - `sync_heaps` wait: `1.55–1.75 ms` -> **`0.72–1.33 ms`**.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 20:06:46 +00:00
Author
Owner

@⁠qlfu on GitHub · 2026-11-30 12:36 UTC · original · edited 2026-11-30 15:27 UTC

Fixed a concurrency race in drain_pending_into / enqueue_pending: pending_count now increments via fetch_add(ops.len(), Release) and decrements via fetch_sub(drained, Release) strictly after apply_queue_ops completes, so concurrent texture_news() checks never observe pending_count == 0 while drained ops are still being applied. Verified with descriptor:: tests (105 passed) and clean merge-tree against 41adb551.

**@⁠qlfu** on GitHub · 2026-11-30 12:36 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3104#issuecomment-7278680065) · edited 2026-11-30 15:27 UTC Fixed a concurrency race in `drain_pending_into` / `enqueue_pending`: `pending_count` now increments via `fetch_add(ops.len(), Release)` and decrements via `fetch_sub(drained, Release)` strictly *after* `apply_queue_ops` completes, so concurrent `texture_news()` checks never observe `pending_count == 0` while drained ops are still being applied. Verified with `descriptor::` tests (105 passed) and clean `merge-tree` against `41adb551`.
github-bot closed this pull request 2026-12-01 18:59:05 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!3104
No description provided.