[pr-feature][startup][shaders] Preload: save the pipeline library every N seconds so a stopped preload keeps its work (DARNER_PRELOAD_SAVE_EVERY, off by default) #147
Loading…
Reference in a new issue
No description provided.
Delete branch "Jesper-A/Darner:up-preload-library-chunks"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Refs #128
Contributor role (optional)
What it changes
Step 3 of the plan in #128 ("Save
into_libraryprogress as it goes, so 'Play now' keeps what was made"). Steps 1 and 2 are the draft PRs #140 (DARNER_PRELOAD_RESUME) and #142 (DARNER_PRECOMPILE_SKIP_DONE). This one does not depend on them.Before: the last step of a preload,
warm::into_library(apps/darner/src/warm.rs), builds every early and slow pipeline and saves the host pipeline library once, at the end. A preload stopped by Play now, Quit or a crash before that save keeps none of them, and the next start builds them again.Now:
DARNER_PRELOAD_SAVE_EVERY=<seconds>(off by default; 30 or more, a smaller number is raised to 30; 0 or anything that is not a whole number is off). With it set, a thread nameddarner-pipelines-savecallsknown::keep_library(the save a normal run makes) every that many seconds while at least one library worker is alive. The final save at the end is unchanged. A pipeline that is in the library is loaded in milliseconds by the next pass, so the library itself is the mark; no done marks are written.It is a time and not a pipeline count because a save writes the whole file however few pipelines were added.
Files:
apps/darner/src/warm.rs(the switch, a worker counter, the saver thread, two unit tests),README.md(one switch row),docs/findings.md(a short section). No newunsafe.Risks to review (why this is WIP)
known::makerests on the saver taking the library'ssavingwrite lock (crates/darner-gpu/src/pipeline/library.rs,save_library) while stores read it. Nothing exercises this under load; the unit tests use a counter, not the real library.How it was tested
up-preload-library-chunks@144038871on top ofmain57dea7f23.144038871):cargo test --locked -j 4 -p darner --bin darner save_every: 1 passed.cargo test --locked -j 4 -p darner --bin darner chunk_saver: 1 passed.cargo clippy --workspace --all-targets --locked -j 4 -- -D warnings: clean.cargo xtask policy: 553 files ok.cargo clippy --workspace --all-targets --all-features --locked -- -D warningsandcargo test --workspace --locked. Upstream has no CI, so nothing else has run this. No gate was run on any other commit.Spec dependence
Checklist
main.docs/asset-policy.md(cargo xtask policy: 553 files ok).docs/findings.mdand theREADME.mdswitch table with #140 and #142; see below)Checked for overlap
docs/findings.md). A trial merge of this branch with each (git merge-tree --write-tree) conflicts only indocs/findings.md;README.mdandwarm.rsmerge cleanly. Whichever lands second needs the two findings sections kept. #130 merges cleanly; #132 touches neitherwarm.rsnorREADME.md. #125 (captures stderr of failed warm workers) also editswarm.rs; a trial merge with #125's head (git merge-tree --write-tree) is clean. #145, #118, #110, #75, #59, #37, #36 and #34 touchREADME.mdordocs/findings.mdand merge cleanly with this branch. #9, #10, #12, #14, #15, #16, #17 and #18 conflict with it inREADME.mdordocs/findings.mdor elsewhere, but those also conflict withmainas it is now.Drafted with AI assistance (Claude Code).
WIP: [pr-feature][startup][shaders] Preload: save the pipeline library every N seconds so a stopped preload keeps its work (DARNER_PRELOAD_SAVE_EVERY, off by default)to [pr-feature][startup][shaders] Preload: save the pipeline library every N seconds so a stopped preload keeps its work (DARNER_PRELOAD_SAVE_EVERY, off by default)Second-opinion review: merge as is (opt-in). Saves go through temp file + rename, so stopping during a save can't corrupt the library. Stores made during a save are queued, a save with nothing added is skipped, and the worker count drops even if a worker panics, so the saver can't run forever. One unmeasured cost: each save serialises the whole library (about 2 GB) through RAM and holds worker stores while it writes, which matters on 16 GB PCs. Before anyone recommends it to players, one measured stopped preload (time and peak memory) would help.