GPU: register pipeline demand after asynchronous compilation timeout #1642

Closed
santiago-andreiu wants to merge 1 commit from upstream-pr/1643 into main
santiago-andreiu commented 2026-11-24 20:19:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by santiago-andreiu on 2026-11-24T20:19:50Z.


<html>

Problem

Pipeline demand is currently recorded only when ready() returns a successfully compiled pipeline.

When a draw or dispatch exceeds the 500 ms waiting budget and the compilation worker completes afterward, the pipeline may never be registered in the early pipeline list unless another rendering operation requests it.

This can cause the same compilation delay to recur in subsequent runs.

Root Cause

Rendering demand and asynchronous compilation completion were not tracked independently. A successful compilation occurring after the waiting budget expired could therefore remain unregistered.

Implementation

Introduce independent atomic event tracking using AtomicU8:

  • REQUESTED: actual rendering demand has occurred.

  • COMPILED: pipeline compilation has completed successfully.

The operation that adds the second distinct event registers the pipeline through note_used().

This approach:

  • Supports either event ordering.

  • Prevents duplicate registration per Pending instance.

  • Excludes purely speculative warmups.

  • Excludes unsuccessful compilations.

  • Preserves pipeline publication through OnceLock.

  • Preserves the existing waiting budget, cache format and retention policy.

Modified Files

  • crates/victory-gpu/src/pipeline/make.rs

  • crates/victory-gpu/src/pipeline/library.rs

Regression Tests

Four CPU-only regression tests were added:

  • late_success_registers_demand_without_a_second_draw

  • warmup_registers_only_on_real_demand_and_only_once

  • failed_compilation_never_registers_demand

  • demand_and_compilation_on_separate_threads_register_once

The late-completion regression test was confirmed to fail before the correction and pass afterward.

Validation

Check | Result -- | -- Default GPU tests | 54 passed, 0 failed, 1 ignored GPU tests with all features | 57 passed, 0 failed, 1 ignored Workspace Clippy, default features | Passed Workspace Clippy, all features | Passed Repository asset policy | Passed Git diff check | Passed

Existing rustfmt discrepancies were reproduced on the original code and were intentionally left unchanged.

Testing Environment

  • CPU: Intel Core i5-12600KF

  • GPU: NVIDIA GeForce RTX 3060 12 GB

  • RAM: 20 GB

  • OS: Windows x64

Known Limitations

This change does not recover rendering operations already discarded after a timeout.

A worker completing after the final cache snapshot during process termination may still produce a registration that is not persisted. Shutdown synchronization is intentionally outside the scope of this contribution.

No in-game rendering or performance improvements have been measured.

Related Work

PR #983 addresses the retention policy of the early pipeline list. This contribution addresses when successfully compiled pipelines become eligible for registration.

The changes are intended to complement each other.

Development Disclosure

Development and testing were assisted by OpenAI Codex. No proprietary game assets were used.

</html>
<!-- greyfinch-sync:Marvisak/VIctory:issue:6590628106 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1643). Originally posted by [santiago-andreiu](https://github.com/santiago-andreiu) on 2026-11-24T20:19:50Z. --- <html><body> <!--StartFragment--><h2><span>Problem</span></h2><p><span>Pipeline demand is currently recorded only when </span><code><span>ready()</span></code><span> returns a successfully compiled pipeline.</span></p><p><span>When a draw or dispatch exceeds the 500 ms waiting budget and the compilation worker completes afterward, the pipeline may never be registered in the early pipeline list unless another rendering operation requests it.</span></p><p><span>This can cause the same compilation delay to recur in subsequent runs.</span></p><h2><span>Root Cause</span></h2><p><span>Rendering demand and asynchronous compilation completion were not tracked independently. A successful compilation occurring after the waiting budget expired could therefore remain unregistered.</span></p><h2><span>Implementation</span></h2><p><span>Introduce independent atomic event tracking using </span><code><span>AtomicU8</span></code><span>:</span></p><ul><li><p><code><span>REQUESTED</span></code><span>: actual rendering demand has occurred.</span></p></li><li><p><code><span>COMPILED</span></code><span>: pipeline compilation has completed successfully.</span></p></li></ul><p><span>The operation that adds the second distinct event registers the pipeline through </span><code><span>note_used()</span></code><span>.</span></p><p><span>This approach:</span></p><ul><li><p><span>Supports either event ordering.</span></p></li><li><p><span>Prevents duplicate registration per </span><code><span>Pending</span></code><span> instance.</span></p></li><li><p><span>Excludes purely speculative warmups.</span></p></li><li><p><span>Excludes unsuccessful compilations.</span></p></li><li><p><span>Preserves pipeline publication through </span><code><span>OnceLock</span></code><span>.</span></p></li><li><p><span>Preserves the existing waiting budget, cache format and retention policy.</span></p></li></ul><h2><span>Modified Files</span></h2><ul><li><p><code><span>crates/victory-gpu/src/pipeline/make.rs</span></code></p></li><li><p><code><span>crates/victory-gpu/src/pipeline/library.rs</span></code></p></li></ul><h2><span>Regression Tests</span></h2><p><span>Four CPU-only regression tests were added:</span></p><ul><li><p><code><span>late_success_registers_demand_without_a_second_draw</span></code></p></li><li><p><code><span>warmup_registers_only_on_real_demand_and_only_once</span></code></p></li><li><p><code><span>failed_compilation_never_registers_demand</span></code></p></li><li><p><code><span>demand_and_compilation_on_separate_threads_register_once</span></code></p></li></ul><p><span>The late-completion regression test was confirmed to fail before the correction and pass afterward.</span></p><h2><span>Validation</span></h2> Check | Result -- | -- Default GPU tests | 54 passed, 0 failed, 1 ignored GPU tests with all features | 57 passed, 0 failed, 1 ignored Workspace Clippy, default features | Passed Workspace Clippy, all features | Passed Repository asset policy | Passed Git diff check | Passed <p><span>Existing rustfmt discrepancies were reproduced on the original code and were intentionally left unchanged.</span></p><h2><span>Testing Environment</span></h2><ul><li><p><span>CPU: Intel Core i5-12600KF</span></p></li><li><p><span>GPU: NVIDIA GeForce RTX 3060 12 GB</span></p></li><li><p><span>RAM: 20 GB</span></p></li><li><p><span>OS: Windows x64</span></p></li></ul><h2><span>Known Limitations</span></h2><p><span>This change does not recover rendering operations already discarded after a timeout.</span></p><p><span>A worker completing after the final cache snapshot during process termination may still produce a registration that is not persisted. Shutdown synchronization is intentionally outside the scope of this contribution.</span></p><p><span>No in-game rendering or performance improvements have been measured.</span></p><h2><span>Related Work</span></h2><p><span>PR #983 addresses the retention policy of the early pipeline list. This contribution addresses when successfully compiled pipelines become eligible for registration.</span></p><p><span>The changes are intended to complement each other.</span></p><h2><span>Development Disclosure</span></h2><p><span>Development and testing were assisted by OpenAI Codex. No proprietary game assets were used.</span></p><!--EndFragment--> </body> </html>
DenRakEiw commented 2026-11-24 21:02:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T20:26:15Z.

Review: APPROVED


Verified locally merged onto origin/main (Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu — 54 passed, 0 failed (1 ignored) on both RTX 5090 hardware and VICTORY_D3D12_WARP=1 (including the 4 new pipeline demand-registration tests)
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok

Clean state-machine handling so late async pipeline compilations register demand once without requiring a second draw and without false registration on warmup or failure. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6046816181 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1643#pullrequestreview-6046816181). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T20:26:15Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu` — 54 passed, 0 failed (1 ignored) on both RTX 5090 hardware and `VICTORY_D3D12_WARP=1` (including the 4 new pipeline demand-registration tests) - `cargo clippy -p victory-gpu --all-targets` — 0 warnings - `cargo xtask policy` — ok Clean state-machine handling so late async pipeline compilations register demand once without requiring a second draw and without false registration on warmup or failure. Looks good. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-24 23:04:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T22:19:54Z.

Review: COMMENTED


Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Pipeline demand registered after asynchronous creation: keys of successfully built pipelines requested by draws/dispatches feed early-start listing. 4 tests in make.rs/library.rs. Windows-only.

<!-- greyfinch-sync:Marvisak/VIctory:review:6048311708 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1643#pullrequestreview-6048311708). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T22:19:54Z. **Review:** COMMENTED --- Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Pipeline demand registered after asynchronous creation: keys of successfully built pipelines requested by draws/dispatches feed early-start listing. 4 tests in make.rs/library.rs. Windows-only.
upstream-sync closed this pull request 2026-11-25 02:04:43 +00:00
Marvisak commented 2026-11-25 02:05:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:22:39Z.


Automated triage for the maintainers. Closing because this change is already in main, or main has since replaced the code it patches.

Already in main, and more: ready() lists a pipeline for an early start at its first use whether or not it was made in time (make.rs). Body is pasted HTML.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149482694 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1643#issuecomment-7149482694). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:22:39Z. --- Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. Already in main, and more: ready() lists a pipeline for an early start at its first use whether or not it was made in time (make.rs). Body is pasted HTML. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Marvisak commented 2026-11-25 02:06:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:33:05Z.


Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-gpu/src/pipeline/library.rs, crates/victory-gpu/src/pipeline/make.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149676271 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1643#issuecomment-7149676271). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:33:05Z. --- <!-- victory-triage v1 head=c79f4c8912545193565048f9799844af79f2edc9 verdict=needs-rebase at=2026-11-25T01:33:04Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-gpu/src/pipeline/library.rs`, `crates/victory-gpu/src/pipeline/make.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1642
No description provided.