feat(gpu): allow cached pipelines to warm after startup #475

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

@⁠vanya890 on GitHub · 2026-12-06 01:21 UTC · original
vanya890:feature/pipeline-startup-background-459 → main · +115 −3 · 2 files · 2 commits · open

Summary

  • Add opt-in LARP_PIPELINE_STARTUP_WAIT=0 to release menu input after the previous-run pipeline list is queued, rather than waiting for the entire cached queue to drain.
  • Skip the render-phase all-pipelines barrier only when a previous-run list actually supplied pipelines.
  • Keep the default behavior unchanged, including the full wait on a cold first run.
  • Keep normal per-pipeline creation/waiting in ready(); pipelines still compile in the background and first use can still hitch while the queue catches up.
  • Document the setting and its interaction with LARP_PIPELINE_WAIT_MS.

This is an explicit startup-speed trade-off for users who prefer reaching the title sooner over warming every cached PSO first.

Related: #459. Complementary to #481, which accelerates cache enumeration and blob loading; this PR adds the separate opt-in to bypass the global startup hold. Both touch pipeline queue/progress code, so if #481 lands first this branch may need a small rebase/reconciliation.

Validation

  • cargo test -p larp-gpu (34 passed, 7 ignored)
  • git diff --check
  • Regression tests cover disabled/unpublished/empty cache gating and publication of the final count before the LISTED_QUEUED release flag.

cargo fmt --check currently reports pre-existing formatting differences across the workspace; no whole-repository formatting was applied.

**@⁠vanya890** on GitHub · 2026-12-06 01:21 UTC · [original](https://github.com/gamingwithhomie/larp/pull/475) `vanya890:feature/pipeline-startup-background-459` → `main` · +115 −3 · 2 files · 2 commits · open ## Summary - Add opt-in `LARP_PIPELINE_STARTUP_WAIT=0` to release menu input after the previous-run pipeline list is queued, rather than waiting for the entire cached queue to drain. - Skip the render-phase all-pipelines barrier only when a previous-run list actually supplied pipelines. - Keep the default behavior unchanged, including the full wait on a cold first run. - Keep normal per-pipeline creation/waiting in `ready()`; pipelines still compile in the background and first use can still hitch while the queue catches up. - Document the setting and its interaction with `LARP_PIPELINE_WAIT_MS`. This is an explicit startup-speed trade-off for users who prefer reaching the title sooner over warming every cached PSO first. Related: #459. Complementary to #481, which accelerates cache enumeration and blob loading; this PR adds the separate opt-in to bypass the global startup hold. Both touch pipeline queue/progress code, so if #481 lands first this branch may need a small rebase/reconciliation. ## Validation - `cargo test -p larp-gpu` (34 passed, 7 ignored) - `git diff --check` - Regression tests cover disabled/unpublished/empty cache gating and publication of the final count before the `LISTED_QUEUED` release flag. `cargo fmt --check` currently reports pre-existing formatting differences across the workspace; no whole-repository formatting was applied.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-06 01:30:08 +00:00
Author
Owner

@⁠vanya890 on GitHub · 2026-12-06 01:25 UTC · original

The opt-in scope is sensible: default behavior and cold-start behavior remain unchanged, and the per-pipeline ready() wait still protects first use. One edge case worth documenting/testing is that the fast path only activates when LISTED_COUNT > 0; a prior-run list that exists but queues zero usable entries will intentionally retain the full wait. Please keep a regression test around that distinction and around the publication order (LISTED_QUEUED only after the listing thread has finished queuing), since the startup barrier now depends on those atomics.

**@⁠vanya890** on GitHub · 2026-12-06 01:25 UTC · [original](https://github.com/gamingwithhomie/larp/pull/475#issuecomment-7449164045) The opt-in scope is sensible: default behavior and cold-start behavior remain unchanged, and the per-pipeline `ready()` wait still protects first use. One edge case worth documenting/testing is that the fast path only activates when `LISTED_COUNT > 0`; a prior-run list that exists but queues zero usable entries will intentionally retain the full wait. Please keep a regression test around that distinction and around the publication order (`LISTED_QUEUED` only after the listing thread has finished queuing), since the startup barrier now depends on those atomics.
Author
Owner

@⁠vanya890 on GitHub · 2026-12-06 01:27 UTC · original

Added the requested regression coverage in commit 2919767:

  • The fast path is false when disabled, before LISTED_QUEUED, or when zero usable entries were queued; it is true only for an enabled, published, non-empty list.
  • publish_listed_queue stores the final count and then publishes LISTED_QUEUED with Release; readers use Acquire before consuming the count.
  • The full larp-gpu suite now passes: 34 passed, 7 ignored. git diff --check is clean.
**@⁠vanya890** on GitHub · 2026-12-06 01:27 UTC · [original](https://github.com/gamingwithhomie/larp/pull/475#issuecomment-7449190899) Added the requested regression coverage in commit `2919767`: - The fast path is false when disabled, before `LISTED_QUEUED`, or when zero usable entries were queued; it is true only for an enabled, published, non-empty list. - `publish_listed_queue` stores the final count and then publishes `LISTED_QUEUED` with `Release`; readers use `Acquire` before consuming the count. - The full `larp-gpu` suite now passes: 34 passed, 7 ignored. `git diff --check` is clean.
Author
Owner

@⁠vanya890 on GitHub · 2026-12-06 01:42 UTC · original · reviewed

Follow-up review: the new tests cover the important gate conditions (disabled, not yet published, empty previous-run list, and non-empty published list), and publish_listed_queue stores the count before the Release publication flag. Readers acquire that flag before using the count. This addresses the startup-barrier coverage I requested; I found no additional issue in the updated diff.

**@⁠vanya890** on GitHub · 2026-12-06 01:42 UTC · [original](https://github.com/gamingwithhomie/larp/pull/475#pullrequestreview-6207509194) · **reviewed** Follow-up review: the new tests cover the important gate conditions (disabled, not yet published, empty previous-run list, and non-empty published list), and `publish_listed_queue` stores the count before the Release publication flag. Readers acquire that flag before using the count. This addresses the startup-barrier coverage I requested; I found no additional issue in the updated diff.
Author
Owner

@⁠christopear on GitHub · 2026-12-06 02:00 UTC · original

I found an interaction with unattended preload on 29197676. With a populated list, LARP_PRELOAD=1 and LARP_PIPELINE_STARTUP_WAIT=0, listed() can clear HOLD before the queue drains. The only call to preload_done() in progress() is guarded by that same hold. That can skip the intended save, flush delay and automatic exit.

Giving preload priority in the shared skip decision preserves both normal background startup and the existing preload behavior. I tested that decision in fresh Windows test processes under Proton. The original failed the precedence check with both options enabled. The patch passed with preload set to 1, yes and 0. All four existing make-module tests passed. I traced the exit path in source but haven't run a full unattended game preload.

Tested patch and optional process-level regression check

Run the ignored test by name in separate processes with LARP_PIPELINE_STARTUP_WAIT=0 and each of the preload values above, since the decision is cached.

--- a/crates/larp-gpu/src/pipeline/make.rs
+++ b/crates/larp-gpu/src/pipeline/make.rs
@@ -361,11 +361,19 @@
     p.made.get()?.as_ref()
 }
 
+fn preload_only() -> bool {
+    std::env::var_os("LARP_PRELOAD").is_some_and(|v| v != "0")
+}
+
 /// Whether a previous-run cache may finish warming after the title starts.
 /// The cold first run keeps its existing full-wait behavior.
 fn skip_cached_startup_wait() -> bool {
     static SKIP: OnceLock<bool> = OnceLock::new();
     *SKIP.get_or_init(|| {
+        // progress() needs HOLD until the queue drains to flush and exit.
+        if preload_only() {
+            return false;
+        }
         let skip = std::env::var("LARP_PIPELINE_STARTUP_WAIT")
             .ok()
             .is_some_and(|value| parse_startup_wait_disabled(Some(&value)));
@@ -1099,7 +1107,7 @@
                         created_without_blob = super::blobs::MADE.load(Ordering::Relaxed),
                         "pipelines: every queued one is made, the title gets its input"
                     );
-                    if std::env::var_os("LARP_PRELOAD").is_some_and(|v| v != "0") {
+                    if preload_only() {
                         preload_done(made);
                     }
                 }
@@ -1496,6 +1504,14 @@
     use super::*;
 
     #[test]
+    #[ignore = "run in fresh processes with both startup and preload flags set"]
+    fn preload_takes_priority_over_background_startup() {
+        assert_eq!(std::env::var("LARP_PIPELINE_STARTUP_WAIT").unwrap(), "0");
+        let preload = std::env::var("LARP_PRELOAD").unwrap() != "0";
+        assert_eq!(skip_cached_startup_wait(), !preload);
+    }
+
+    #[test]
     fn startup_skip_requires_a_published_nonempty_list() {
         assert!(!should_skip_cached_startup_wait(false, true, 1));
         assert!(!should_skip_cached_startup_wait(true, false, 1));
**@⁠christopear** on GitHub · 2026-12-06 02:00 UTC · [original](https://github.com/gamingwithhomie/larp/pull/475#issuecomment-7449615364) I found an interaction with unattended preload on `29197676`. With a populated list, `LARP_PRELOAD=1` and `LARP_PIPELINE_STARTUP_WAIT=0`, `listed()` can clear `HOLD` before the queue drains. The only call to `preload_done()` in `progress()` is guarded by that same hold. That can skip the intended save, flush delay and automatic exit. Giving preload priority in the shared skip decision preserves both normal background startup and the existing preload behavior. I tested that decision in fresh Windows test processes under Proton. The original failed the precedence check with both options enabled. The patch passed with preload set to `1`, `yes` and `0`. All four existing make-module tests passed. I traced the exit path in source but haven't run a full unattended game preload. <details> <summary>Tested patch and optional process-level regression check</summary> Run the ignored test by name in separate processes with `LARP_PIPELINE_STARTUP_WAIT=0` and each of the preload values above, since the decision is cached. ```diff --- a/crates/larp-gpu/src/pipeline/make.rs +++ b/crates/larp-gpu/src/pipeline/make.rs @@ -361,11 +361,19 @@ p.made.get()?.as_ref() } +fn preload_only() -> bool { + std::env::var_os("LARP_PRELOAD").is_some_and(|v| v != "0") +} + /// Whether a previous-run cache may finish warming after the title starts. /// The cold first run keeps its existing full-wait behavior. fn skip_cached_startup_wait() -> bool { static SKIP: OnceLock<bool> = OnceLock::new(); *SKIP.get_or_init(|| { + // progress() needs HOLD until the queue drains to flush and exit. + if preload_only() { + return false; + } let skip = std::env::var("LARP_PIPELINE_STARTUP_WAIT") .ok() .is_some_and(|value| parse_startup_wait_disabled(Some(&value))); @@ -1099,7 +1107,7 @@ created_without_blob = super::blobs::MADE.load(Ordering::Relaxed), "pipelines: every queued one is made, the title gets its input" ); - if std::env::var_os("LARP_PRELOAD").is_some_and(|v| v != "0") { + if preload_only() { preload_done(made); } } @@ -1496,6 +1504,14 @@ use super::*; #[test] + #[ignore = "run in fresh processes with both startup and preload flags set"] + fn preload_takes_priority_over_background_startup() { + assert_eq!(std::env::var("LARP_PIPELINE_STARTUP_WAIT").unwrap(), "0"); + let preload = std::env::var("LARP_PRELOAD").unwrap() != "0"; + assert_eq!(skip_cached_startup_wait(), !preload); + } + + #[test] fn startup_skip_requires_a_published_nonempty_list() { assert!(!should_skip_cached_startup_wait(false, true, 1)); assert!(!should_skip_cached_startup_wait(true, false, 1)); ``` </details>
This pull request can be merged automatically.
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/475/head:github-bot/gh-475'
git switch 'github-bot/gh-475'

Merge

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