warm: save the pipeline library during the warm-up, every N seconds (LEONIDA_PRELOAD_SAVE_EVERY) #3446

Merged
leonida/mandy
MoonEyes merged 3 commits from feat/warm-save-every into main 2026-12-04 10:41:57 +00:00

Pull request successfully merged and closed

Member

Change

warm --store wrote the pipeline library only at the end: a warm-up stopped part way (a crash, a closed window, the gate's time limit) lost everything it had compiled, and the next start compiled it again.

  • New switch LEONIDA_PRELOAD_SAVE_EVERY=<seconds>, off by default (absent, 0 or unreadable = the old behaviour; under 30 is read as 30).
  • When on, a thread inside a thread::scope around known::store saves the library every N seconds with the existing library::save (temporary file then rename, so the final file is never half written). The scope ends before the final write, so the two never write at the same time.
  • One stdout line per periodic save: bytes written, nothing to write or write failed (no stale size). The parent reads stdout, so the line also resets its 180 s silence limit; it acts only on lines starting with made, so the protocol is unchanged.
  • switches.md regenerated.

Same idea as Darner PR #147 (GPL-3.0-or-later), adapted to Mandy's warm-up.

Tests

  • cargo test --locked -p leonida-gpu -p leonida: pass (new: save_every_is_off_unless_seconds, and the save-loop timing test).
  • python -I tools/d3d12_switches.py --check, python -I tests/test_d3d12_switches.py (22 OK).
  • In-game gate of a test branch that includes this change (with #3443, #3444, #3445): PASS, 314 s in the world, no device loss, RTX 4060 8 GB. The switch was off in that run, so the run shows the default path is unchanged; a warm-up with the switch on and a stop part way is still to do.

AI-assisted

Written with Claude Opus 5.5 (Claude Code); reviewed by a separate Claude Opus 5.5 reviewer instance (stderr line nobody read and a stale size in the log line, both fixed).

🤖 Generated with Claude Code

## Change `warm --store` wrote the pipeline library only at the end: a warm-up stopped part way (a crash, a closed window, the gate's time limit) lost everything it had compiled, and the next start compiled it again. - New switch `LEONIDA_PRELOAD_SAVE_EVERY=<seconds>`, off by default (absent, 0 or unreadable = the old behaviour; under 30 is read as 30). - When on, a thread inside a `thread::scope` around `known::store` saves the library every N seconds with the existing `library::save` (temporary file then rename, so the final file is never half written). The scope ends before the final write, so the two never write at the same time. - One stdout line per periodic save: bytes written, `nothing to write` or `write failed` (no stale size). The parent reads stdout, so the line also resets its 180 s silence limit; it acts only on lines starting with `made`, so the protocol is unchanged. - `switches.md` regenerated. Same idea as Darner PR #147 (GPL-3.0-or-later), adapted to Mandy's warm-up. ## Tests - `cargo test --locked -p leonida-gpu -p leonida`: pass (new: `save_every_is_off_unless_seconds`, and the save-loop timing test). - `python -I tools/d3d12_switches.py --check`, `python -I tests/test_d3d12_switches.py` (22 OK). - In-game gate of a test branch that includes this change (with #3443, #3444, #3445): PASS, 314 s in the world, no device loss, RTX 4060 8 GB. The switch was off in that run, so the run shows the default path is unchanged; a warm-up with the switch on and a stop part way is still to do. ## AI-assisted Written with Claude Opus 5.5 (Claude Code); reviewed by a separate Claude Opus 5.5 reviewer instance (stderr line nobody read and a stale size in the log line, both fixed). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
LEONIDA_PRELOAD_SAVE_EVERY=<seconds> (off by default; unset, 0 or not a number
means the library is written once at the end, as before; below 30 reads as 30)
makes the warm's store process save the pipeline library on that period, so a
warm that is stopped keeps what it made. Each save is the existing
temporary-file-then-rename write; the saver runs in a thread scope that ends
before the final save, so the two never write together. One stderr line per
save: bytes, pipelines made or loaded, seconds. Unit tests for the parsing and
the saver loop; switches.md regenerated.

Idea from Darner PR #147 (GPL-3.0-or-later)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The line goes to stdout, where the parent reads the warm's progress: a line that
does not begin with `made` is ignored by it but resets its silence limit. The
report no longer reads the size of an older save: library::save leaves how it
ended (nothing written, written, failed) and the line says "nothing to write",
the size, or "write failed".

Idea from Darner PR #147 (GPL-3.0-or-later)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Member

Merging. Not a rendering change (the switch is off by default). Branch updated with main d78ad89291; the merged tree (5a1dcbe5) is the one tested locally: cargo test --locked -p leonida-gpu -p leonida 738 + 62 + 5 passed, 0 failed; tests/test_d3d12_switches.py 22 OK. Reviewed by a separate reviewer instance (accepted; two medium points fixed). AI-assisted (Claude Opus 5.5).

Merging. Not a rendering change (the switch is off by default). Branch updated with main `d78ad89291`; the merged tree (`5a1dcbe5`) is the one tested locally: `cargo test --locked -p leonida-gpu -p leonida` 738 + 62 + 5 passed, 0 failed; `tests/test_d3d12_switches.py` 22 OK. Reviewed by a separate reviewer instance (accepted; two medium points fixed). AI-assisted (Claude Opus 5.5).
Sign in to join this conversation.
No description provided.