Pipeline wait budget is per frame only: a pipeline that stays "being made" costs the whole budget in every frame that binds it #73

Open
opened 2026-11-26 03:31:46 +00:00 by github-bot · 2 comments
Owner

@⁠j-fuxa on GitHub · 2026-11-26 01:40 UTC · original

What the code does. pipeline/make.rs bounds the wait for a pipeline that is not made yet per frame (wait_budget, 500 ms, VICTORY_PIPELINE_WAIT_MS, shared by all threads) but remembers nothing per pipeline. ready() enters wait() whenever p.made.get().is_none(), so a pipeline whose build outlasts the budget takes it again in every frame that binds it. For passes over the screen the budget is VICTORY_SCREEN_WAIT_MS, 10 s by default.

Evidence. #61 (median 398 ms a frame, GPU 0.0 ms, 459-539 ms "waiting for pipelines", 1,251 draws a frame dropped as "being made") and #67 (about 380 ms a frame, 80 ms of it work) have this shape, though their logs cannot tell "slow to build" from "stuck". fxceless/victory-fork#1181 measured the loop on four stuck pipelines: 500.1 ms waited in every world frame; with a 50 ms budget the median went from 761 to 252 ms. Our tree had the same code shape (found by code review, then fixed as below).

Second gap. Pending::make() runs HostPipeline::new with no catch_unwind (used elsewhere in the crate: list/thin.rs, host/aside.rs, land.rs, queue/behind.rs). If it panics, the worker ends, made stays unset and the state stays MAKING (start() returns early for good), WAITING and a slow slot (slow_now) are never given back, and every frame that binds the pipeline waits again. We have not seen such a panic; this is from reading the code.

Suggested fix.

  • Keep the time waited per pipeline (atomic microseconds on Pending). wait() takes the smaller of the frame's and the pipeline's budget left and returns at once at zero; the draw is dropped as now and finds the pipeline when it appears. A per-pipeline budget well under the frame budget keeps the first-frame wait for cheap pipelines.
  • Wrap the worker's make in catch_unwind; on a panic log the shaders and set made to None (refused).

Smaller. shader_cache::cached stores only successes (its test says "Failures are not stored"), so a program that does not translate is translated and refused again every run. In our tree about 114 programs did, roughly 100 s of worker time a run; victory shaders shows your count. A negative entry keyed like the positive one would stop it.

Caveat. Your library locking (same_name stripes, saving) already matches what mattered for us: one lock over every library call left 8 workers waiting 59 % of the time on a 404 MB library (about 150 ms a load).

**@⁠j-fuxa** on GitHub · 2026-11-26 01:40 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/73) **What the code does.** `pipeline/make.rs` bounds the wait for a pipeline that is not made yet per frame (`wait_budget`, 500 ms, `VICTORY_PIPELINE_WAIT_MS`, shared by all threads) but remembers nothing per pipeline. `ready()` enters `wait()` whenever `p.made.get().is_none()`, so a pipeline whose build outlasts the budget takes it again in every frame that binds it. For passes over the screen the budget is `VICTORY_SCREEN_WAIT_MS`, 10 s by default. **Evidence.** #61 (median 398 ms a frame, GPU 0.0 ms, 459-539 ms "waiting for pipelines", 1,251 draws a frame dropped as "being made") and #67 (about 380 ms a frame, 80 ms of it work) have this shape, though their logs cannot tell "slow to build" from "stuck". fxceless/victory-fork#1181 measured the loop on four stuck pipelines: 500.1 ms waited in every world frame; with a 50 ms budget the median went from 761 to 252 ms. Our tree had the same code shape (found by code review, then fixed as below). **Second gap.** `Pending::make()` runs `HostPipeline::new` with no `catch_unwind` (used elsewhere in the crate: `list/thin.rs`, `host/aside.rs`, `land.rs`, `queue/behind.rs`). If it panics, the worker ends, `made` stays unset and the state stays MAKING (`start()` returns early for good), `WAITING` and a slow slot (`slow_now`) are never given back, and every frame that binds the pipeline waits again. We have not seen such a panic; this is from reading the code. **Suggested fix.** - Keep the time waited per pipeline (atomic microseconds on `Pending`). `wait()` takes the smaller of the frame's and the pipeline's budget left and returns at once at zero; the draw is dropped as now and finds the pipeline when it appears. A per-pipeline budget well under the frame budget keeps the first-frame wait for cheap pipelines. - Wrap the worker's make in `catch_unwind`; on a panic log the shaders and set `made` to `None` (refused). **Smaller.** `shader_cache::cached` stores only successes (its test says "Failures are not stored"), so a program that does not translate is translated and refused again every run. In our tree about 114 programs did, roughly 100 s of worker time a run; `victory shaders` shows your count. A negative entry keyed like the positive one would stop it. **Caveat.** Your library locking (`same_name` stripes, `saving`) already matches what mattered for us: one lock over every library call left 8 workers waiting 59 % of the time on a 404 MB library (about 150 ms a load).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:31:46 +00:00
Author
Owner

@⁠BE29ZZ on GitHub · 2026-11-26 01:46 UTC · original

Are you still struggling with this error? Would you like me to help?

**@⁠BE29ZZ** on GitHub · 2026-11-26 01:46 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/73#issuecomment-7180117798) Are you still struggling with this error? Would you like me to help?
Author
Owner

@⁠jtrudeau1530 on GitHub · 2026-11-26 08:40 UTC · original

On Linux/vkd3d-proton one root cause of a pipeline that stays "being made" forever is a host compile thread that dies: dxil-spirv overflows its stack on a few large shaders (see #111). Then the whole 500 ms budget is spent every frame (measured 500.1-500.2 ms/frame, 3.4 fps). #162 detects the dead thread and compiles the shader again in another control-flow shape: 0.0 ms waiting, 13.7-15.1 fps on the same build. It doesn't change the per-frame budget logic itself, so the cap discussed here is still worth having for pipelines that are genuinely slow.

**@⁠jtrudeau1530** on GitHub · 2026-11-26 08:40 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/73#issuecomment-7186884133) On Linux/vkd3d-proton one root cause of a pipeline that stays "being made" forever is a host compile thread that dies: dxil-spirv overflows its stack on a few large shaders (see #111). Then the whole 500 ms budget is spent every frame (measured 500.1-500.2 ms/frame, 3.4 fps). #162 detects the dead thread and compiles the shader again in another control-flow shape: 0.0 ms waiting, 13.7-15.1 fps on the same build. It doesn't change the per-frame budget logic itself, so the cap discussed here is still worth having for pipelines that are genuinely slow.
This discussion has been locked. Commenting is limited to contributors.
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/avatarmanz--VIctory-7900XTX#73
No description provided.