GPU: account for pending pipelines before promotion #2223

Open
github-bot wants to merge 2 commits from github-bot/gh-2223 into main AGit
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 08:16 UTC · original
andrewpozdnakov7-jpg:codex2/pso-queue-accounting → main · +70 −22 · 1 files · 2 commits · open

An early enqueue marks a PSO as queued before it increments the pending count. A concurrent first draw can promote that entry and send it to a worker in between. If the worker finishes first, it can decrement the pending count from zero.

Run the first count through a per-pipeline Once so any concurrent promotion waits for the count to be registered. Urgent and early queue selection remains in the same code path.

The regression pauses the early enqueue before its count and then starts a concurrent promotion. The simulated worker saw 0 before the fix and 1 after it. The existing first-use test also exercises the worker queue.

  • Windows/WARP GPU library suite with the same regression on both builds went from 145 passed, 2 failed, 2 ignored to 146 passed, 1 failed, 2 ignored. The placed-view texture-format test failed in both builds.
  • Clippy passed for victory-gpu all targets with warnings denied, with and without diagnostics.

Coordination claim in #1633.

AI-assisted using Codex. Synthetic data only.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 08:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/2223) `andrewpozdnakov7-jpg:codex2/pso-queue-accounting` → `main` · +70 −22 · 1 files · 2 commits · open An early enqueue marks a PSO as queued before it increments the pending count. A concurrent first draw can promote that entry and send it to a worker in between. If the worker finishes first, it can decrement the pending count from zero. Run the first count through a per-pipeline Once so any concurrent promotion waits for the count to be registered. Urgent and early queue selection remains in the same code path. The regression pauses the early enqueue before its count and then starts a concurrent promotion. The simulated worker saw 0 before the fix and 1 after it. The existing first-use test also exercises the worker queue. - Windows/WARP GPU library suite with the same regression on both builds went from 145 passed, 2 failed, 2 ignored to 146 passed, 1 failed, 2 ignored. The placed-view texture-format test failed in both builds. - Clippy passed for victory-gpu all targets with warnings denied, with and without diagnostics. [Coordination claim in #1633](https://git.gtahub.st/github/Marvisak--VIctory/issues/1633). AI-assisted using Codex. Synthetic data only.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:58:58 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 13:29 UTC · original · edited 2026-11-26 01:24 UTC

Automated triage for the maintainers.

Merge candidate. The branch now merges cleanly into current main (4f2b0f3). The race is real in main's pipeline/make.rs. enqueue sets queued before it increments WAITING. A draw that promotes the entry in between can send it to a worker, and the worker's WAITING.fetch_sub then wraps below zero. After that, drained() no longer fires at the right time and making() reports nonsense. Turning Pending::queued into a std::sync::Once, with the count taken inside call_once, makes a concurrent promotion wait until the count is in. The queue-selection logic is unchanged. The new test forces the interleaving with channels, and the existing enqueue test no longer adjusts the global WAITING by hand. CI (check) passes on this head.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 13:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/2223#issuecomment-7163862018) · edited 2026-11-26 01:24 UTC <!-- victory-triage v1 head=4f2b0f33975ecc38a7b8d786405fe40d5823ada3 verdict=merge-candidate at=2026-11-26T01:24:54Z --> Automated triage for the maintainers. **Merge candidate.** The branch now merges cleanly into current `main` (`4f2b0f3`). The race is real in `main`'s `pipeline/make.rs`. `enqueue` sets `queued` before it increments `WAITING`. A draw that promotes the entry in between can send it to a worker, and the worker's `WAITING.fetch_sub` then wraps below zero. After that, `drained()` no longer fires at the right time and `making()` reports nonsense. Turning `Pending::queued` into a `std::sync::Once`, with the count taken inside `call_once`, makes a concurrent promotion wait until the count is in. The queue-selection logic is unchanged. The new test forces the interleaving with channels, and the existing `enqueue` test no longer adjusts the global `WAITING` by hand. CI (`check`) passes on this head. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-25 08:22 UTC · original · approved these changes

Verified locally merged onto origin/main (940d32f, Windows 11 x64, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu --lib pipeline::make:: — 3 passed, 0 failed (including an_urgent_enqueue_cannot_overtake_the_first_queue_count)
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean ordering fix accounting for pending pipelines before urgent promotion. Looks good.

AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-25 08:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/2223#pullrequestreview-6054065734) · **approved these changes** Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu --lib pipeline::make::` — 3 passed, 0 failed (including `an_urgent_enqueue_cannot_overtake_the_first_queue_count`) - `cargo clippy -p victory-gpu --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean ordering fix accounting for pending pipelines before urgent promotion. Looks good. AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 08:48 UTC · original · reviewed

Account for pending pipelines before promotion; replaces queued AtomicBool with Once and adds a PEAK waiting metric. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.

**@⁠catminou4** on GitHub · 2026-11-25 08:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/2223#pullrequestreview-6054379609) · **reviewed** Account for pending pipelines before promotion; replaces queued AtomicBool with Once and adds a PEAK waiting metric. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 19:27 UTC · original · approved these changes

Reviewed and verified 4f2b0f33975ecc38a7b8d786405fe40d5823ada3 merged onto origin/main (63bcca43c6a00a758510398fa43096ce7e4f7df0) on Windows 11 x64 (RTX 5090 + Microsoft WARP, Rust 1.98.1 MSVC).

Code & Concurrency Audit

  • Replacing Pending::queued: AtomicBool with std::sync::Once (crates/victory-gpu/src/pipeline/make.rs:33) and running note_waiting() inside p.queued.call_once(...) (L221-230) closes the early-vs-urgent promotion race cleanly: any concurrent urgent caller blocks in call_once until WAITING.fetch_add(1) completes, so a worker picking up the promoted entry can never execute WAITING.fetch_sub(1) (L331) before the count is registered.
  • Queue selection (first || ahead && !p.taken.load(Relaxed)) and worker single-claim deduplication via p.taken.swap(true, Relaxed) (L327) remain intact, so WAITING is still incremented and decremented strictly once even when an entry enters both queues.
  • start (L210-214) and count_waiting (L216-218) keep PEAK tracking accurate without altering external behavior.

Local Verification

  • cargo xtask policy — pass.
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --all-features) — 0 warnings.
  • cargo test --locked -p victory-gpu --lib pipeline::make:: (RTX 5090 and WARP) — all passed, including an_urgent_enqueue_cannot_overtake_the_first_queue_count.
  • Additional synthetic stress probe racing 8 threads across 500 barrier-synchronized early + urgent enqueue iterations on a single Pending instance — passed (counted strictly once, worker always observed waiting == 1 before decrement, final waiting == 0).

Looks good to merge.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 19:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/2223#pullrequestreview-6079532603) · **approved these changes** Reviewed and verified `4f2b0f33975ecc38a7b8d786405fe40d5823ada3` merged onto `origin/main` (`63bcca43c6a00a758510398fa43096ce7e4f7df0`) on Windows 11 x64 (RTX 5090 + Microsoft WARP, Rust 1.98.1 MSVC). ### Code & Concurrency Audit - Replacing `Pending::queued: AtomicBool` with `std::sync::Once` (`crates/victory-gpu/src/pipeline/make.rs:33`) and running `note_waiting()` inside `p.queued.call_once(...)` (`L221-230`) closes the early-vs-urgent promotion race cleanly: any concurrent urgent caller blocks in `call_once` until `WAITING.fetch_add(1)` completes, so a worker picking up the promoted entry can never execute `WAITING.fetch_sub(1)` (`L331`) before the count is registered. - Queue selection (`first || ahead && !p.taken.load(Relaxed)`) and worker single-claim deduplication via `p.taken.swap(true, Relaxed)` (`L327`) remain intact, so `WAITING` is still incremented and decremented strictly once even when an entry enters both queues. - `start` (`L210-214`) and `count_waiting` (`L216-218`) keep `PEAK` tracking accurate without altering external behavior. ### Local Verification - `cargo xtask policy` — pass. - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`) — 0 warnings. - `cargo test --locked -p victory-gpu --lib pipeline::make::` (RTX 5090 and WARP) — all passed, including `an_urgent_enqueue_cannot_overtake_the_first_queue_count`. - Additional synthetic stress probe racing 8 threads across 500 barrier-synchronized early + urgent `enqueue` iterations on a single `Pending` instance — passed (counted strictly once, worker always observed `waiting == 1` before decrement, final `waiting == 0`). Looks good to merge.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 20:47 UTC · original

I tested #2223 at 4f2b0f3 with #3353 at df15a80 and #3025 at 018b56a. The new presentation path can hit the same accounting race via hurry: the regression pauses the first enqueue before its count and checks whether the presentation path can promote it. The two-PR control admitted the uncounted pipeline.

Combined commit 335eb7b uses #2223's completed registration for both promotion paths. The presentation path can promote it as soon as the count completes. Graphics still goes first, compute keeps its cap, and a worker claims a promoted entry once. The two new presentation tests from df15a80 pass too.

Windows: 15/15 queue and presentation tests with default features, 16/16 with diagnostics, strict Clippy in both configurations, and the asset policy check passed. This was a scheduler test with synthetic pipelines. Maintainers can carry the combined resolution forward if #3353 or #3025 lands first. Please keep the Git author or use Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding the resolution into another commit.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 20:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/2223#issuecomment-7203072410) I tested #2223 at `4f2b0f3` with #3353 at `df15a80` and #3025 at `018b56a`. The new presentation path can hit the same accounting race via `hurry`: the regression pauses the first enqueue before its count and checks whether the presentation path can promote it. The two-PR control admitted the uncounted pipeline. [Combined commit `335eb7b`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/335eb7baf2f1adc596e30eb641490205fed2fded) uses #2223's completed registration for both promotion paths. The presentation path can promote it as soon as the count completes. Graphics still goes first, compute keeps its cap, and a worker claims a promoted entry once. The two new presentation tests from `df15a80` pass too. Windows: 15/15 queue and presentation tests with default features, 16/16 with diagnostics, strict Clippy in both configurations, and the asset policy check passed. This was a scheduler test with synthetic pipelines. Maintainers can carry the combined resolution forward if #3353 or #3025 lands first. Please keep the Git author or use `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding the resolution into another commit.
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/2223/head:github-bot/gh-2223'
git switch 'github-bot/gh-2223'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2223'
git switch 'github-bot/gh-2223'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2223'
git switch 'github-bot/gh-2223'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2223'
git switch 'main'
git merge --squash 'github-bot/gh-2223'
git switch 'main'
git merge --ff-only 'github-bot/gh-2223'
git switch 'main'
git merge 'github-bot/gh-2223'
git push origin 'main'
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/Marvisak--VIctory!2223
No description provided.