Skip the pipeline wait's lock and clock once the frame's budget is spent #56

Closed
github-bot wants to merge 1 commit from github-bot/gh-56 into main AGit
Owner

@⁠romainhedouin on GitHub · 2026-11-25 13:12 UTC · original
romainhedouin:perf/pipeline-wait-spent-budget → main · +9 −2 · 1 files · 1 commits · closed without merging

A draw whose host pipeline is not built yet may wait for it, up to a budget per frame. Once that budget was spent, every further such draw still took the global DONE lock and read the clock three times, though it could no longer wait at all. It now returns as soon as it sees the budget is spent. Also, the "queued" and "used" flags are read before being swapped, so after the first time they cost a plain read instead of a locked write. Each pipeline is still queued, and noted as used, exactly once.

Per not-ready draw, budget spent Before After
DONE lock + unlock 1 0
Clock reads 3 0
Model benchmark, 1 thread 72 ns 1.5 ns
Model benchmark, 4 threads (lock contended) 726–887 ns 73–99 ns

"Model benchmark" = the same logic copied into a standalone program and timed in release mode on a Mac, not in the game. Matters while pipelines are still being built (warm-up, new areas). Type-checked for Windows (cargo clippy --target x86_64-pc-windows-msvc, with and without --all-features, no new warnings); not run.

🤖 Generated with Claude Code

**@⁠romainhedouin** on GitHub · 2026-11-25 13:12 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/56) `romainhedouin:perf/pipeline-wait-spent-budget` → `main` · +9 −2 · 1 files · 1 commits · closed without merging A draw whose host pipeline is not built yet may wait for it, up to a budget per frame. Once that budget was spent, every further such draw still took the global `DONE` lock and read the clock three times, though it could no longer wait at all. It now returns as soon as it sees the budget is spent. Also, the "queued" and "used" flags are read before being swapped, so after the first time they cost a plain read instead of a locked write. Each pipeline is still queued, and noted as used, exactly once. | Per not-ready draw, budget spent | Before | After | |---|---|---| | `DONE` lock + unlock | 1 | 0 | | Clock reads | 3 | 0 | | Model benchmark, 1 thread | 72 ns | 1.5 ns | | Model benchmark, 4 threads (lock contended) | 726–887 ns | 73–99 ns | "Model benchmark" = the same logic copied into a standalone program and timed in release mode on a Mac, not in the game. Matters while pipelines are still being built (warm-up, new areas). Type-checked for Windows (`cargo clippy --target x86_64-pc-windows-msvc`, with and without `--all-features`, no new warnings); not run. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:34:40 +00:00
Author
Owner

@⁠gut0to on GitHub · 2026-11-25 16:00 UTC · original · reviewed

Static review: after the frame-wait budget is exhausted, wait returns before taking DONE or reading the clock; the queue-once and note-used-once guards remain intact. The PR reports Windows clippy and a standalone release-mode model benchmark, not a game benchmark. I did not run tests or the game here. AI-assisted review.

**@⁠gut0to** on GitHub · 2026-11-25 16:00 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/56#pullrequestreview-6060882886) · **reviewed** Static review: after the frame-wait budget is exhausted, wait returns before taking DONE or reading the clock; the queue-once and note-used-once guards remain intact. The PR reports Windows clippy and a standalone release-mode model benchmark, not a game benchmark. I did not run tests or the game here. AI-assisted review.
github-bot closed this pull request 2026-11-27 01:00:06 +00:00
Author
Owner

@⁠romainhedouin on GitHub · 2026-11-26 22:24 UTC · original

Closing: a-publier already has all three changes in pipeline/make.rs: wait returns before the clock and the lock once the budget is spent (:458), ready checks used first (:396), and start checks the queue state first (:600).

**@⁠romainhedouin** on GitHub · 2026-11-26 22:24 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/56#issuecomment-7204653198) Closing: `a-publier` already has all three changes in pipeline/make.rs: `wait` returns before the clock and the lock once the budget is spent (:458), `ready` checks `used` first (:396), and `start` checks the queue state first (:600).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.