gpu/descriptor: read the texture queue without its lock and tell it in batches #173

Open
github-bot wants to merge 1 commit from github-bot/gh-172 into main AGit
Owner

@⁠SovietBearz0r on GitHub · 2026-12-05 20:51 UTC · original
SovietBearz0r:darner-queue-marks → main · +653 −106 · 5 files · 1 commits · open

Darner measured other threads waiting 33-44 s on the texture-queue lock in a 150 s run before DARNER_QUEUE_MARKS, and the queue batch switch. This ports the lock-sparing marks and batched tells.

What

  • QueueMarks: per-slot entry write numbers (0 = none) plus a count of shards holding slots back for lack of card room, maintained under the queue lock, read without it. VICTORY_QUEUE_MARKS default on (=0 takes the lock every time).
  • Lock-sparing now covers: a slot record that would remove a non-queued slot or keep a queued one, a table read of a non-queued slot, and texture_slots_room (no shard locked when nothing is held). Spared takes are counted and reported as "texture queue locks not taken N a frame" on the existing list line.
  • texture_slots_due_known gets each due slot's checked data in the same lock take instead of one lock per due slot; new VICTORY_QUEUE_BATCH (default on) / _MAX (64, clamp 1-4096) gathers Told results and applies them once per shard (sorted by slot), flushed at pass end.
  • Results/order unchanged (tests assert batched == one-by-one, marks == lock reads).
  • DARNER_DUE_INDEX is deliberately left out: our queue is a 64-shard HashMap with per-shard census scanning, so a faithful index needs a per-shard bucket index plus census/held/room parity; that is an opt-in follow-up with equivalence tests, not part of this PR.

Verification

  • cargo test -p victory-gpu --lib: 719 passed, 0 failed, 21 ignored (3 new: marks say what the queue holds without the lock; batched tells serve as told one-by-one; due slots come with what the queue knew); all-features 796 passed; clippy default+all-features -D warnings clean; cargo check -p victory; policy 442 files.
  • Default-on note: these are default on because the tests pin unchanged results/order and the only effect is fewer lock takes; if you'd rather have them off until an in-game A/B, they are the two VICTORY_QUEUE_* constants. A/B needed: "texture queue lock waits" and the new "locks not taken" lines, marks/batch defaults vs =0.
  • Risks: +8 B per slot marks (~slot count), a 64-tell batch still takes ~40 shard locks (the bigger win is removing the per-due-slot lock), batched tells deferred <= one batch (stale tells dropped by the existing write check).
**@⁠SovietBearz0r** on GitHub · 2026-12-05 20:51 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/172) `SovietBearz0r:darner-queue-marks` → `main` · +653 −106 · 5 files · 1 commits · open Darner measured other threads waiting **33-44 s on the texture-queue lock in a 150 s run** before `DARNER_QUEUE_MARKS`, and the queue batch switch. This ports the lock-sparing marks and batched tells. ## What - `QueueMarks`: per-slot entry write numbers (0 = none) plus a count of shards holding slots back for lack of card room, maintained under the queue lock, **read without it**. `VICTORY_QUEUE_MARKS` default on (`=0` takes the lock every time). - Lock-sparing now covers: a slot record that would remove a non-queued slot or keep a queued one, a table read of a non-queued slot, and `texture_slots_room` (no shard locked when nothing is held). Spared takes are counted and reported as "texture queue locks not taken N a frame" on the existing list line. - `texture_slots_due_known` gets each due slot's `checked` data in the same lock take instead of one lock per due slot; new `VICTORY_QUEUE_BATCH` (default on) / `_MAX` (64, clamp 1-4096) gathers `Told` results and applies them once per shard (sorted by slot), flushed at pass end. - Results/order unchanged (tests assert batched == one-by-one, marks == lock reads). - `DARNER_DUE_INDEX` is deliberately left out: our queue is a 64-shard `HashMap` with per-shard census scanning, so a faithful index needs a per-shard bucket index plus census/held/room parity; that is an opt-in follow-up with equivalence tests, not part of this PR. ## Verification - `cargo test -p victory-gpu --lib`: **719 passed, 0 failed, 21 ignored** (3 new: marks say what the queue holds without the lock; batched tells serve as told one-by-one; due slots come with what the queue knew); all-features **796 passed**; clippy default+all-features `-D warnings` clean; `cargo check -p victory`; policy 442 files. - **Default-on note**: these are default on because the tests pin unchanged results/order and the only effect is fewer lock takes; if you'd rather have them off until an in-game A/B, they are the two `VICTORY_QUEUE_*` constants. A/B needed: "texture queue lock waits" and the new "locks not taken" lines, marks/batch defaults vs `=0`. - Risks: +8 B per slot marks (~slot count), a 64-tell batch still takes ~40 shard locks (the bigger win is removing the per-due-slot lock), batched tells deferred <= one batch (stale tells dropped by the existing write check).
Port Darner's queue work (crates/darner-gpu/src/descriptor/host.rs and
draw.rs: DARNER_QUEUE_MARKS, DARNER_QUEUE_BATCH / DARNER_QUEUE_BATCH_MAX,
both on by default):

- QueueMarks: the queue's per-slot write numbers and the shards holding
  slots back for lack of card room, kept under its lock and read without
  it, so a table read, a slot's record or the pass's room query take a
  shard's lock only when something changes (VICTORY_QUEUE_MARKS=0: the
  lock every time, as before). The list line counts the takes spared.

- The pass is handed what the queue knew of a slot looked at again in the
  same take as the slots due (texture_slots_due_known), and tells the
  queue what came of its slots a batch at a time, one take of each shard's
  lock a batch (VICTORY_QUEUE_BATCH=0: each told at once, as before;
  VICTORY_QUEUE_BATCH_MAX, 64, sets a batch). A slot whose entry left the
  queue meanwhile is passed over, and a tell of a write the queue no
  longer holds is dropped, as before.

The queue's order, results and defaults are unchanged. Tests: the marks
seen without the lock (and their room/held part), a batch told against
one-at-a-time (due, census, held and a stale tell alike), and the
look-again data coming with the slots due.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 20:53:40 +00:00
Author
Owner

@⁠SovietBearz0r on GitHub · 2026-12-05 21:48 UTC · original

In-game A/B on RX 9070 XT (diag build, builtin:cruise, medians over the measured spots):

counter default (marks+batch on) VICTORY_QUEUE_MARKS=0 VICTORY_QUEUE_BATCH=0
texture queue lock waits / frame 2.80 102.30
texture queue locks not taken / frame 16,922.5 43,564.0 (write-site shortcut remains)

So the marks reduce texture-queue lock waits by ~37x on this route, with identical results/pacing and 0 errors. That is also the argument for keeping the defaults ON: this is measured, not speculative. (locks not taken being non-zero with the switch off is expected — one write-site shortcut is independent of the mark table.) Logs: data\ingame-verify\logs\queue-base.log, ...\queue-nomarks.log.

**@⁠SovietBearz0r** on GitHub · 2026-12-05 21:48 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/172#issuecomment-7446017478) In-game A/B on RX 9070 XT (diag build, builtin:cruise, medians over the measured spots): | counter | default (marks+batch on) | `VICTORY_QUEUE_MARKS=0 VICTORY_QUEUE_BATCH=0` | |---|---|---| | `texture queue lock waits` / frame | **2.80** | **102.30** | | `texture queue locks not taken` / frame | 16,922.5 | 43,564.0 (write-site shortcut remains) | So the marks reduce texture-queue lock waits by ~37x on this route, with identical results/pacing and 0 errors. That is also the argument for keeping the defaults ON: this is measured, not speculative. (`locks not taken` being non-zero with the switch off is expected — one write-site shortcut is independent of the mark table.) Logs: `data\ingame-verify\logs\queue-base.log`, `...\queue-nomarks.log`.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/173/head:github-bot/gh-172'
git switch 'github-bot/gh-172'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-172'
git switch 'github-bot/gh-172'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-172'
git switch 'github-bot/gh-172'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-172'
git switch 'main'
git merge --squash 'github-bot/gh-172'
git switch 'main'
git merge --ff-only 'github-bot/gh-172'
git switch 'main'
git merge 'github-bot/gh-172'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.