vkback: split remap inflight reads by queue, own-queue reads wait for the remap #218

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

@⁠lordra9-svg on GitHub · 2026-12-02 14:37 UTC · original
lordra9-svg:fix/maporder-queue-split → main · +216 −24 · 4 files · 1 commits · open

What

docs/TASKS.md:1081: the "reads while a remap was under way" counter could not tell the remap's own queue's reads (a race: they come at its Execute, after the mapping may have changed) from other queues' (legal: the console does not order them against the remap either). This splits the count by queue and makes an own-queue read wait for the remap before it resolves the address.

Change

  • maporder: release(seq, queue) records the remap's queue (seq_queue) and, per page, the remaps holding it (inflight_seqs); reached clears both. A CURRENT_QUEUE thread-local (enter_queue, RAII) is set by Live::call_inner(this) for the whole recording of a queue's calls.
  • check classifies each inflight read as own / other / unknown and, when own, drops the shared lock and waits (wait_done, the remap's next reported done) before the caller reads. VKB_REMAP_OWN_WAIT (=0 kill switch, default on: waiting is the accurate path) and counters INFLIGHT_CLASS[3], OWN_WAITS, OWN_WAIT_US.
  • Descriptor jobs carry the recording queue to the vkback-desc helper (Batch.queue), so their reads are attributed instead of unknown.
  • Stats line: reads while a remap was under way N (own queue X [W waited, T ms], other queues O, queue unknown U).

Measured (b7fixed, clean single run, bin-mapqueue)

  • reads while a remap was under way 10793 (own queue 0 [0 waited, 0.0 ms], other queues 10793, queue unknown 0) — before descriptor attribution the same run shape showed every unknown (337) was the descriptor path; it is now attributed.
  • So on this workload no read belongs to the remap's own queue: the ~8-11k inflight reads are other queues' fills/descriptor work, which the console does not order against the remap. The wait is inert here (0 waits), as intended.
  • 26.6-27.2 fps, no device loss.

Verified

  • cargo test -p vkback --lib: 170 passed (own/other/unknown classification, own wait, switch default, batch queue capture); policy 6; cargo test -p frame --lib 13; clippy -D warnings clean; tools/build.sh exit 0.
  • Validation run (VK_LAYER_KHRONOS_validation, 220 s): only the four known VUIDs (06409 x4, 01687/01688/03428 x20 each), no new errors, no device loss; split still own 0, other 4762, unknown 0.

Caveat

The wait path is not exercised on this save (own = 0); it exists so a scene that does produce own-queue reads gets the console's order. VKB_REMAP_OWN_WAIT=0 restores the previous racing behaviour (counted).

**@⁠lordra9-svg** on GitHub · 2026-12-02 14:37 UTC · [original](https://github.com/vktory6/VKtory/pull/218) `lordra9-svg:fix/maporder-queue-split` → `main` · +216 −24 · 4 files · 1 commits · open ## What `docs/TASKS.md:1081`: the "reads while a remap was under way" counter could not tell the remap's own queue's reads (a race: they come at its Execute, after the mapping may have changed) from other queues' (legal: the console does not order them against the remap either). This splits the count by queue and makes an own-queue read wait for the remap before it resolves the address. ## Change - `maporder`: `release(seq, queue)` records the remap's queue (`seq_queue`) and, per page, the remaps holding it (`inflight_seqs`); `reached` clears both. A `CURRENT_QUEUE` thread-local (`enter_queue`, RAII) is set by `Live::call_inner(this)` for the whole recording of a queue's calls. - `check` classifies each inflight read as **own / other / unknown** and, when own, drops the shared lock and waits (`wait_done`, the remap's next reported done) before the caller reads. `VKB_REMAP_OWN_WAIT` (`=0` kill switch, default on: waiting is the accurate path) and counters `INFLIGHT_CLASS[3]`, `OWN_WAITS`, `OWN_WAIT_US`. - Descriptor jobs carry the recording queue to the `vkback-desc` helper (`Batch.queue`), so their reads are attributed instead of `unknown`. - Stats line: `reads while a remap was under way N (own queue X [W waited, T ms], other queues O, queue unknown U)`. ## Measured (b7fixed, clean single run, `bin-mapqueue`) - **`reads while a remap was under way 10793 (own queue 0 [0 waited, 0.0 ms], other queues 10793, queue unknown 0)`** — before descriptor attribution the same run shape showed every `unknown` (337) was the descriptor path; it is now attributed. - So on this workload **no read belongs to the remap's own queue**: the ~8-11k inflight reads are other queues' fills/descriptor work, which the console does not order against the remap. The wait is inert here (0 waits), as intended. - 26.6-27.2 fps, no device loss. ## Verified - `cargo test -p vkback --lib`: **170 passed** (own/other/unknown classification, own wait, switch default, batch queue capture); policy 6; `cargo test -p frame --lib` 13; clippy `-D warnings` clean; `tools/build.sh` exit 0. - **Validation run** (`VK_LAYER_KHRONOS_validation`, 220 s): only the four known VUIDs (06409 x4, 01687/01688/03428 x20 each), no new errors, no device loss; split still `own 0, other 4762, unknown 0`. ## Caveat The wait path is not exercised on this save (own = 0); it exists so a scene that does produce own-queue reads gets the console's order. `VKB_REMAP_OWN_WAIT=0` restores the previous racing behaviour (counted).
The inflight-read counter now says whether a read into a page of a remap
under way belongs to the remap's own queue, another queue, or no queue is
current (INFLIGHT_CLASS; the per-path totals stay). A read by the remap's
own queue waits for that remap before it resolves the address: the console's
order (CopyPageMappingsBatchX before the queue's later work). The renderer
reads the queue from a thread-local set by Live::call_inner (enter_queue),
the remap's queue travels with release() and is kept per page in
inflight_seqs, so check (still under no lock while waiting) can tell own from
other. The descriptor path runs its buffer views on the vkback-desc helper
thread, off the renderer's thread-local: the batch carries the recording
queue captured when it is sent and the helper enters it around its jobs, so
those reads are attributed too (None stays unknown).

VKB_REMAP_OWN_WAIT=0 is the kill switch; unset (waiting) is the accurate
path. The stats phrase now says "renderer or a recording queue waiting for
one", since C_WAIT_* includes the own-queue recording waits. Tests cover
own/other/unknown, the wait when done, the switch default, and the batch's
queue capture for the helper.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 14:40:33 +00:00
Author
Owner

@⁠vktory6 on GitHub · 2026-12-02 16:02 UTC · original

Thanks, splitting the inflight-read counter by queue answers the question the TASKS item asked, and attributing the descriptor jobs to their queue is a good catch. Your run shows 0 own-queue reads, so the wait path doesn't fire today. It's still the accurate behaviour if one ever does, and defaulting to it fits the rules. Merge order: the holdfrees branch (finishing now) changes the same remap release path in maporder, and #184 also changes reached, so I'll merge holdfrees first and then this one rebased on it.

**@⁠vktory6** on GitHub · 2026-12-02 16:02 UTC · [original](https://github.com/vktory6/VKtory/pull/218#issuecomment-7351355511) Thanks, splitting the inflight-read counter by queue answers the question the TASKS item asked, and attributing the descriptor jobs to their queue is a good catch. Your run shows 0 own-queue reads, so the wait path doesn't fire today. It's still the accurate behaviour if one ever does, and defaulting to it fits the rules. Merge order: the holdfrees branch (finishing now) changes the same remap release path in maporder, and #184 also changes `reached`, so I'll merge holdfrees first and then this one rebased on it.
This pull request has changes conflicting with the target branch.
  • greenfield/vkback/src/maporder.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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