[pr-feature][startup][shaders] Preload window: build the early set first (DARNER_PRELOAD_EARLY_FIRST, off by default) #267

Manually merged
TrustNo1 merged 0 commits from Jesper-A/Darner:up-preload-early-first into main 2026-12-04 22:17:33 +00:00
Collaborator

Draft: no timing run with the switch on, and two of the three gates have not run. Branch up-preload-early-first, one commit on main f3840d73d.

Refs #128, #250

Contributor role (optional)

  • Fluxer ID:

What it changes

  • The problem on main: the preload window always starts darner preload with --all (apps/darner/src/preload_ui.rs, the .arg("--all") line in run()). That makes every pipeline an earlier run recorded, 77k to 89k of them. Our own cold test runs use the --used path (about 5,000 early pipelines plus about 2,550 slow ones) and take 28.4, 31.3 and 28.9 min (3 cold or near-cold runs, all clocks unlocked). A reporter measured 47 minutes for --all on a Ryzen 7 8845HS laptop (#128). The gap probably comes mostly from about 70k cheap pipelines, about 0.11 s each on average (a rough estimate from #128's numbers; different PCs, so not a measured difference).
  • What this does: with DARNER_PRELOAD_EARLY_FIRST=1 the window passes --used instead of --all, but only when early-pipelines.txt holds at least 1,000 pipelines (DARNER_PRELOAD_USED_MIN). The game then starts after the early and slow set (about 7.5k pipelines) and makes the rest when it first draws with it, as it does for any pipeline a preload did not cover. With a short or missing list, --used would build little or nothing in step 2, so the window keeps --all then. With the switch off (the default) nothing changes. The switch is read with a plain environment read, like the other DARNER_PRELOAD_* switches in apps/darner (the asked_for!/toggled! macros live in darner-gpu).
  • New file apps/darner/src/preload_scope.rs: a small pure function argument(early_first, list_recorded) with three unit tests, and a one-line change in preload_ui.rs. The console prints which scope was chosen. A line in docs/findings.md. The switch is documented in the README switch table.
  • The preload's done mark keeps its meaning: "the preload this start asked for is done", not "every pipeline is made". After an early-first preload the next start does not ask again; darner preload --all from a shell makes the rest.
  • Cost: the rest is made during play. #250 reports dropped frames going from 1,355 per 10 min without a full preload to 28 per 5 min with one, and runtime compiles from 68-77 per session to 0. That is the price of the shorter wait. #250's point 3 also says its long freezes persisted with made=0, so not every hitch is a compile. Not measured with this switch.
  • Not in this PR (phase 2, not built): filling the rest in the background at low priority while playing. That needs changes in play.rs and warm.rs and would collide with #140 and #215.

How it was tested

  • Tested revision: e27749176 (on f3840d73d); cargo xtask policy and the preload tests ran on this tree.

  • Commands and results:

    • cargo test --locked -j 4 -p darner --bin darner -- preload: 10 passed, 1 ignored.
    • cargo clippy --workspace --all-targets --locked -- -D warnings: clean.
    • cargo xtask policy: ok.
  • Changes a default: no.

  • A/B result: not applicable for a speed claim, because the switch is off by default and there is no timing run with it on. The behaviour was checked by the unit tests of the decision only. The numbers above (28.4, 31.3 and 28.9 min for --used, 47 min for --all) are from other runs: ours are from our PC (see Spec dependence), the 47 min is the reporter's in #128.

    A (off, --all) B (on, --used)
    cold preload time not measured on our PC; 47 min reported in #128 (Ryzen 7 8845HS, RTX 4050 Laptop 6 GB, DLSS Quality) 28.4, 31.3 and 28.9 min on our PC (3 cold or near-cold runs of the --used path, not with this switch)
  • Gates run on that revision (the three in AGENTS.md; there is no CI): gate 1 (cargo clippy --workspace --all-targets --locked -- -D warnings) plus a narrow test run (cargo test --locked -j 4 -p darner --bin darner -- preload), on the head commit. Not run: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings and cargo test --workspace --locked.

  • Gameplay, when relevant: not run. No game run and no timing run with the switch on.

  • Shader wave sizes tested, when relevant: not relevant (no shader change).

  • Hardware dependence: likely general, may depend on CPU core count (see below).

  • Coverage gaps: no game start after a --used preload; hitches from the remaining compiles during play not measured; F1's PRELOAD SHADERS uses the same window and so also follows the switch (not tried).

Spec dependence

  • Likely general: the choice of argument is plain logic and does not depend on the GPU.
  • May depend on our specs: the 28.4, 31.3 and 28.9 minute figures are from a RTX 2070 SUPER 8 GB (Turing), Ryzen 7 5800X (8C/16T), 32 GB, Windows 11 Pro Insider 26320, no ReBAR, Series S profile with DLSS Performance. The times may depend on CPU core count (not measured). How much the in-play compiles hurt depends on the card's compiler speed and the driver cache.
  • Untested elsewhere: AMD and Intel cards, 16 GB machines, any PC with a cold driver cache other than ours.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only). Not yet: no game run. The PR stays a draft until one is done.
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md (cargo xtask policy: ok).
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #142, #140, #215 (ours) and #235 (andrewpozdnakov7-jpg), #234 (same author, warm.rs).
  • Also ours and independent of this one (no dependency either way): #264 keeps the done marks across a translator change, which decides how often the --used set is already done on the next start; #266 orders and schedules the same step-3 slow set that --used builds. Shared files: only the appended docs/findings.md line (all three) and the README switch table (#264), so at most a trivial textual conflict.
  • Replaces or overlaps:
    • #140 (play.rs, preload_ui.rs) and #215 (preload_ui.rs, warm.rs): expected textual conflict next to the --all line in run(). #215 may rewrite run(). This draft is posted as it is, conflicts included, and will be rebased before WIP: comes off.
    • #235 (checkpointing early-pipelines.txt): changes what the list holds, not this decision. It should make "early-pipelines.txt holds at least 1,000 pipelines" true earlier.
    • #142 (translate.rs, shader_cache.rs): no shared files. Only docs/findings.md is touched by several PRs.
    • No open or closed PR found that does the same: searched "preload", "warm-done", "DARNER_PRELOAD", "slow-pipelines", "early set".

This change was made with AI assistance (Claude Code).

Draft: no timing run with the switch on, and two of the three gates have not run. Branch `up-preload-early-first`, one commit on `main` f3840d73d. Refs #128, #250 ## Contributor role (optional) - Fluxer ID: ## What it changes - The problem on main: the preload window always starts `darner preload` with `--all` (`apps/darner/src/preload_ui.rs`, the `.arg("--all")` line in `run()`). That makes every pipeline an earlier run recorded, 77k to 89k of them. Our own cold test runs use the `--used` path (about 5,000 early pipelines plus about 2,550 slow ones) and take 28.4, 31.3 and 28.9 min (3 cold or near-cold runs, all clocks unlocked). A reporter measured 47 minutes for `--all` on a Ryzen 7 8845HS laptop (#128). The gap probably comes mostly from about 70k cheap pipelines, about 0.11 s each on average (a rough estimate from #128's numbers; different PCs, so not a measured difference). - What this does: with `DARNER_PRELOAD_EARLY_FIRST=1` the window passes `--used` instead of `--all`, but only when `early-pipelines.txt` holds at least 1,000 pipelines (`DARNER_PRELOAD_USED_MIN`). The game then starts after the early and slow set (about 7.5k pipelines) and makes the rest when it first draws with it, as it does for any pipeline a preload did not cover. With a short or missing list, `--used` would build little or nothing in step 2, so the window keeps `--all` then. With the switch off (the default) nothing changes. The switch is read with a plain environment read, like the other `DARNER_PRELOAD_*` switches in `apps/darner` (the `asked_for!`/`toggled!` macros live in `darner-gpu`). - New file `apps/darner/src/preload_scope.rs`: a small pure function `argument(early_first, list_recorded)` with three unit tests, and a one-line change in `preload_ui.rs`. The console prints which scope was chosen. A line in `docs/findings.md`. The switch is documented in the README switch table. - The preload's done mark keeps its meaning: "the preload this start asked for is done", not "every pipeline is made". After an early-first preload the next start does not ask again; `darner preload --all` from a shell makes the rest. - Cost: the rest is made during play. #250 reports dropped frames going from 1,355 per 10 min without a full preload to 28 per 5 min with one, and runtime compiles from 68-77 per session to 0. That is the price of the shorter wait. #250's point 3 also says its long freezes persisted with `made=0`, so not every hitch is a compile. Not measured with this switch. - Not in this PR (phase 2, not built): filling the rest in the background at low priority while playing. That needs changes in `play.rs` and `warm.rs` and would collide with #140 and #215. ## How it was tested - Tested revision: e27749176 (on f3840d73d); `cargo xtask policy` and the `preload` tests ran on this tree. - Commands and results: - `cargo test --locked -j 4 -p darner --bin darner -- preload`: 10 passed, 1 ignored. - `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean. - `cargo xtask policy`: ok. - Changes a default: no. - A/B result: not applicable for a speed claim, because the switch is off by default and there is no timing run with it on. The behaviour was checked by the unit tests of the decision only. The numbers above (28.4, 31.3 and 28.9 min for `--used`, 47 min for `--all`) are from other runs: ours are from our PC (see Spec dependence), the 47 min is the reporter's in #128. | | A (off, `--all`) | B (on, `--used`) | |---|---|---| | cold preload time | not measured on our PC; 47 min reported in #128 (Ryzen 7 8845HS, RTX 4050 Laptop 6 GB, DLSS Quality) | 28.4, 31.3 and 28.9 min on our PC (3 cold or near-cold runs of the `--used` path, not with this switch) | - Gates run on that revision (the three in AGENTS.md; there is no CI): gate 1 (`cargo clippy --workspace --all-targets --locked -- -D warnings`) plus a narrow test run (`cargo test --locked -j 4 -p darner --bin darner -- preload`), on the head commit. Not run: `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` and `cargo test --workspace --locked`. - Gameplay, when relevant: not run. No game run and no timing run with the switch on. - Shader wave sizes tested, when relevant: not relevant (no shader change). - Hardware dependence: likely general, may depend on CPU core count (see below). - Coverage gaps: no game start after a `--used` preload; hitches from the remaining compiles during play not measured; F1's PRELOAD SHADERS uses the same window and so also follows the switch (not tried). ## Spec dependence - Likely general: the choice of argument is plain logic and does not depend on the GPU. - May depend on our specs: the 28.4, 31.3 and 28.9 minute figures are from a RTX 2070 SUPER 8 GB (Turing), Ryzen 7 5800X (8C/16T), 32 GB, Windows 11 Pro Insider 26320, no ReBAR, Series S profile with DLSS Performance. The times may depend on CPU core count (not measured). How much the in-play compiles hurt depends on the card's compiler speed and the driver cache. - Untested elsewhere: AMD and Intel cards, 16 GB machines, any PC with a cold driver cache other than ours. ## Checklist - [ ] I ran this change in the game, or say below why it can't be (docs, tests only). Not yet: no game run. The PR stays a draft until one is done. - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md` (`cargo xtask policy`: ok). - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #142, #140, #215 (ours) and #235 (andrewpozdnakov7-jpg), #234 (same author, `warm.rs`). - Also ours and independent of this one (no dependency either way): #264 keeps the done marks across a translator change, which decides how often the `--used` set is already done on the next start; #266 orders and schedules the same step-3 slow set that `--used` builds. Shared files: only the appended `docs/findings.md` line (all three) and the README switch table (#264), so at most a trivial textual conflict. - Replaces or overlaps: - #140 (`play.rs`, `preload_ui.rs`) and #215 (`preload_ui.rs`, `warm.rs`): expected textual conflict next to the `--all` line in `run()`. #215 may rewrite `run()`. This draft is posted as it is, conflicts included, and will be rebased before `WIP:` comes off. - #235 (checkpointing `early-pipelines.txt`): changes what the list holds, not this decision. It should make "`early-pipelines.txt` holds at least 1,000 pipelines" true earlier. - #142 (`translate.rs`, `shader_cache.rs`): no shared files. Only `docs/findings.md` is touched by several PRs. - No open or closed PR found that does the same: searched "preload", "warm-done", "DARNER_PRELOAD", "slow-pipelines", "early set". This change was made with AI assistance (Claude Code).
The window always passes --all (77k to 89k pipelines). With
DARNER_PRELOAD_EARLY_FIRST=1 (off by default) it passes --used when an early
list exists, so the game starts after the early/slow set (~7.5k pipelines) and
the rest is made on demand. Without a list, or with the switch off, it stays
--all. The decision is a pure function in the new preload_scope.rs, with tests.

This change was made with AI assistance (Claude Code).
Owner

Review of e2774917 (read only, not built or run). WIP draft: small, correct.

Checked:

  • argument(early_first, list_recorded) gives --used only when the switch is on and warm::used_pipelines_recorded() says a list of at least DARNER_PRELOAD_USED_MIN exists. Otherwise it gives --all, so --used can never build almost nothing. A read error counts as no list. The three tests cover the table.
  • With the switch off, the window passes --all exactly as on main. darner preload --all from a shell is untouched.
  • This also covers the point I raised on #228 (that the window always passes --all) as an opt-in, without changing the default.

Points:

  1. What "finished" means with the switch on. A first-start preload that ran --used writes the finished mark, so later starts don't preload again. F1 > PRELOAD SHADERS goes through the same window and switch, so with the switch on nothing ever builds the other ~70k pipelines up front; they are made in play. That's intended, but say it in the README row: "F1's preload also builds only the used set while this is on; darner preload --all builds everything."
  2. What takes it off WIP: the timing run you list (window wait with the switch on vs off), plus a note on hitches in the first minutes of play with only the used set. That's the cost side of the trade. Then gates 2 and 3.

It merges cleanly with main (f3840d73), #153 and #228. It conflicts with #215 in preload_ui.rs, where both rewrite the Command in run(). The fix is one line: keep #215's command and pass preload_scope::current_argument() in place of "--all". It conflicts with #140 in README, main.rs (module list) and docs/findings.md, all trivial.

No testcall-ok while it's a draft.

Review of e2774917 (read only, not built or run). WIP draft: small, correct. **Checked:** - `argument(early_first, list_recorded)` gives `--used` only when the switch is on *and* `warm::used_pipelines_recorded()` says a list of at least `DARNER_PRELOAD_USED_MIN` exists. Otherwise it gives `--all`, so `--used` can never build almost nothing. A read error counts as no list. The three tests cover the table. - With the switch off, the window passes `--all` exactly as on main. `darner preload --all` from a shell is untouched. - This also covers the point I raised on #228 (that the window always passes `--all`) as an opt-in, without changing the default. **Points:** 1. **What "finished" means with the switch on.** A first-start preload that ran `--used` writes the finished mark, so later starts don't preload again. F1 > PRELOAD SHADERS goes through the same window and switch, so with the switch on nothing ever builds the other ~70k pipelines up front; they are made in play. That's intended, but say it in the README row: "F1's preload also builds only the used set while this is on; `darner preload --all` builds everything." 2. **What takes it off WIP:** the timing run you list (window wait with the switch on vs off), plus a note on hitches in the first minutes of play with only the used set. That's the cost side of the trade. Then gates 2 and 3. It merges cleanly with main (f3840d73), #153 and #228. It conflicts with #215 in `preload_ui.rs`, where both rewrite the `Command` in `run()`. The fix is one line: keep #215's command and pass `preload_scope::current_argument()` in place of `"--all"`. It conflicts with #140 in README, `main.rs` (module list) and `docs/findings.md`, all trivial. No testcall-ok while it's a draft.
Jesper-A changed title from WIP: [pr-feature][startup][shaders] Preload window: build the early set first (DARNER_PRELOAD_EARLY_FIRST, off by default) to [pr-feature][startup][shaders] Preload window: build the early set first (DARNER_PRELOAD_EARLY_FIRST, off by default) 2026-12-04 22:06:38 +00:00
TrustNo1 manually merged commit bedc70610a into main 2026-12-04 22:17:33 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
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
TrustNo1/Darner!267
No description provided.