WIP: Preload step 3 goes on from a stopped pass (DARNER_PRELOAD_SAVE_PARTIAL, off by default) #450

Draft
Jesper-A wants to merge 2 commits from Jesper-A/Darner:up-preload-library-progress-v2 into Main
Collaborator

Refs #128 (stage 3 of the plan in that issue; not a full fix)

Contributor role (optional)

  • Fluxer ID:

What it changes

  • The problem on main: read from the code only, no log line yet. #147 (DARNER_PRELOAD_SAVE_EVERY, on main as 144038871) saves the pipeline library every N seconds during step 3, so a stopped preload's pipelines are in host-pipelines.bin. But the next pass still takes the whole list: it reads each pipeline, translates or looks up its shaders, names it and loads it from the library. Nothing records which pipelines a save holds, so nothing is skipped. A pipeline the library lacks only comes back through the driver's own disk cache.

New switch DARNER_PRELOAD_SAVE_PARTIAL=1, off by default. With it on:

  • Step 3 saves the library in chunks, at DARNER_PRELOAD_SAVE_EVERY's interval, or every 180 s when that is not set. SAVE_EVERY itself is unchanged.
  • After each save that wrote the file, pipelines/library-progress.txt is written (temporary file, then rename). It holds a version, the translator-and-settings key (known::fingerprint()), the card, a stamp of the exact library file that save wrote (length plus blake3 of its first and last 64 KiB), the count, and the keys of the pipelines finished before the save began. A record without its last line end counts for nothing.
  • At the next start the library is opened first. The record counts only if it is whole and its key, card and stamp all match the library the host accepted. Then those pipelines are left out of step 3. In any other case (no record, a torn record, another translator, driver or card, a library a game run saved since, a library the host rejected) step 3 makes everything, as on main.
  • When step 3 finishes, the record is removed.
  • Two new lines (switch on only): DARNER_PRELOAD_SAVE_PARTIAL: N pipelines are in the library an earlier preload saved, M left to make, and ... library-progress.txt is for another library, translator, driver or card; making them all.
  • With the switch on, "opening the pipeline library" is printed before the "into the pipeline library: M" line, because the library has to open first. #215's parser reads both orders (test added).
  • Graceful stop (second commit, same switch). Play now and Quit no longer kill step 3 at once. The window starts the preload with a pipe on its stdin and DARNER_PRELOAD_STOP_STDIN=1 (set by the window, not a switch to set by hand), and writes the line stop (Control::Stop of #395's control protocol; one reader of stdin, which with DARNER_PRELOAD_CONTROLS=1 is the controls' reader, else warm/stop.rs). The preload finishes the pipelines in hand (known::make_while checks before each one, also in DARNER_PRELOAD_SCHEDULE's queue), saves the library with the same stamped save the chunks use, keeps the record and exits. The window stays open saying "Saving what is done, then stopping. This can take a minute." until the preload ends, at most 60 s, then kills it as before. Only step 3 is asked; steps 1 and 2 are killed at once as on main. A stopped pass prints stopped early: ..., not N of M in the pipeline library in S s, so the window and #140's record do not take it for finished. A closed pipe (the window gone) is a stop too. While it stops, the gate lets every thread through and the load and Pause buttons do nothing. With the switch off nothing changes: no pipe, taskkill as before.

With the switch off no record is read or written, no stamp is computed, there are no extra saves, and the output lines are the same as on main.

Why a stamp and not just the list: skipping is only a time saving, and it must never claim a pipeline the library does not hold, because that pipeline would then be compiled in the game. Microsoft's docs say serialized library data is invalidated by a runtime or driver update and is not portable across hardware, and that CreatePipelineLibrary rejects a corrupt or foreign blob (Serialize, CreatePipelineLibrary). The stamp is taken from the bytes the host actually loaded, and the save's stamp from the temporary file it wrote, so a later game run or another PR that changes which file is read cannot make the record match a different library.

Why periodic saves as well: Play now and Quit end the preload with a taskkill /PID <child> /T /F call after the window closes (preload_ui.rs), which the graceful stop replaces for step 3 only; a crash, a kill, a step 1 or 2 stop and a stop that takes over 60 s still lose what was made since the last chunk save.

Files:

  • apps/darner/src/warm/progress.rs (new): the record, its parse, write, read and clear, left_to_make, save_round, tests.
  • apps/darner/src/warm.rs: resume_from_record, the wiring in into_library, save_partial_on.
  • apps/darner/src/preload_ui.rs: the window hint treats the switch as "saving on the way"; a parser test for the new line order; the stop (pipe, "stopping" text, 60 s wait).
  • apps/darner/src/main.rs (6 lines): warm::stop::listen() before the preload starts, and an early return when a stop was already requested before step 3.
  • apps/darner/src/warm/stop.rs (new), apps/darner/src/preload_gate.rs (Control::Stop), locales/en.json, locales/zh-CN.json: the stop.
  • crates/darner-gpu/src/pipeline/library.rs: stamps (stamp_of, file_stamp, opened_stamp, save_stamped), taken only when the switch is on; a test.
  • crates/darner-gpu/src/pipeline/known.rs: library_stamp, keep_library_stamped.
  • README.md (a switch row), docs/findings.md (a section).

The branch is two commits on main (47d21cd3b), which already has #140, #142, #153, #215, #264 and #266: 7636f3d29 (the record, the stamp and the skip) and 2919c85a5 (the graceful stop). git diff --stat trustno1/main...HEAD: 12 files, +951/-45.

main has since moved to d91d8e4d6 (the F2 RAM-speed note: README, locales, host/). The branch was not rebased; a trial merge with it is clean (checked 2026-12-05).

Credit: the idea is from the plan in #128 and builds on #147 (ours). Nothing is ported from another fork.

Known limits

  • A store the driver refuses with an error other than E_INVALIDARG still returns a pipeline, so it would be listed though it is not in the library. It is then made in the game, as main already does for such pipelines at every start.
  • Every chunk save writes the whole library file (about 2 GB on a warmed install), as SAVE_EVERY does. The cost is not measured.
  • The gain is expected to be small where the driver's cache kept the pipelines. On our PC, in one split preload run, the driver cache alone brought back about 6,500 step-3 pipelines in about 10 s. It should help more where the driver cache dropped them (size limit, cleared cache) and in no longer depending on it.
  • Combined with #234 (final save on a thread-spawn error): a step that ends with a spawn error keeps its last chunk record, but #234's final save changes the file, so the stamp no longer matches and the next pass makes everything. Safe, just no skip.

How it was tested

  • Tested revision: branch up-preload-library-progress-v2 @ 2919c85a5, on main @ 47d21cd3b.

  • Commands and results (there is no CI upstream; these are the ones I ran on 2919c85a5):

    • cargo clippy --workspace --all-targets --locked -- -D warnings: clean
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean
    • cargo test -p darner --bin darner --locked: 210 passed, 0 failed, 1 ignored
    • cargo test -p darner-gpu --lib --locked pipeline::known: 15 passed, 0 failed
    • cargo xtask policy: ok (566 files)
    • New tests: in progress.rs, a_record_is_written_and_read_back, a_record_that_is_not_whole_counts_for_nothing (every cut point), a_record_for_another_library_translator_driver_or_card_is_ignored, the_stored_pipelines_are_left_out_in_order, switch_off_saves_as_before_and_writes_no_record, a_save_records_what_it_holds_and_a_save_that_did_not_write_records_nothing, the_interval_is_save_every_or_three_minutes; in library.rs, a_library_stamp_is_the_same_from_memory_and_from_the_file; in preload_ui.rs, the extended what_the_last_line_said_is_the_activity. Graceful stop: in stop.rs, a_stop_line_sets_the_flag_and_other_lines_do_not, the_input_closing_is_a_stop_too, a_pipe_that_is_open_and_quiet_does_not_stop; in known.rs, a_stop_leaves_the_pipeline_in_hand_finished_and_the_rest_unmade; in warm.rs, a_stopped_step_saves_what_it_made_and_records_it_instead_of_publishing, a_step_that_ran_to_its_end_publishes_and_clears_the_record, a_stopped_pass_does_not_print_the_line_that_says_finished; in preload_gate.rs, a_stop_line_opens_the_gate_and_calls_the_stop_and_the_end_of_input_does_too_when_listening; in preload_ui.rs, the_stop_is_a_control_line_and_the_buttons_wait_while_it_is_asked, a_stopped_pass_is_not_read_as_a_finished_one, only_step_three_with_the_switch_and_a_pipe_stops_gracefully_else_it_is_killed_as_before, the_stop_is_one_line_and_the_wait_is_bounded.
  • Changes a default: no. The switch is off by default.

  • A/B result: the switch is off by default, and it was checked by unit tests only (switch_off_saves_as_before_and_writes_no_record). Not run in a game, so there is no A/B and no timing.

    A (off) B (on)
    not measured not run not run
  • Gates run on that revision: clippy workspace: yes. Clippy workspace with --all-features: yes. cargo test -p darner --bin darner --locked and cargo test -p darner-gpu --lib --locked pipeline::known: yes. pipeline::library tests: not run. Full cargo test --workspace --locked: not run. There is no CI upstream.

  • Gameplay: not run in a game. The machine for the later run: RTX 2070 SUPER 8 GB (Turing), driver 621.40, ReBAR off, Ryzen 7 5800X, 32 GB, Windows 11 Pro Insider 26320; Series S, DLSS Performance, frame generation off, ray tracing off.

  • Shader wave sizes tested: not relevant (no translation change).

  • Hardware dependence: likely general; how much time it saves may depend on whether the driver's own cache kept the pipelines. Details in "Spec dependence".

  • Not tested without a game: how long a stop takes, whether 60 s is enough, the pipe with the real window, a stop while paused.

  • Coverage gaps: every game run (the steps below), chunk-save cost on a 2 GB library, other GPUs and drivers, and the full workspace tests.

In-game test, to run before WIP comes off

  1. Preload with DARNER_PRELOAD_SAVE_PARTIAL=1 (optionally DARNER_PRELOAD_SAVE_EVERY=60 for a faster first save) until step 3 has a cold part. Wait past one save (the log says host pipeline library saved, and pipelines/library-progress.txt appears with a count above 0). Then click Play now or Quit.
  2. Start again. The preload log must show DARNER_PRELOAD_SAVE_PARTIAL: N pipelines are in the library an earlier preload saved, M left to make, with N about the count at the last save, and the window's total must be M. Step 3 must finish, the record must be gone, and the done mark written.
  3. Stale cases: change a translator switch, or delete host-pipelines.bin, before the restart. The "is for another library ..." line and the full count must show.
  4. In the game after a finished preload: no rise in in-game compiles compared with a normal finished preload (skipped pipelines must load from the library).
  5. Switch off: the logs are the same as on main, and there is no record file.
  6. Graceful stop: during step 3 click Play now; the window shows "Saving what is done, then stopping. This can take a minute.", the preload prints stopped early, the library is saved, the record is there, the window closes. Start again: the pipelines are skipped. Also with DARNER_PRELOAD_CONTROLS=1, paused, and with DARNER_PRELOAD_SCHEDULE=1.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only).
    • Not ticked: not run in a game yet. The PR stays a draft (WIP) until it has been.
  • This PR contains one change based on main.
    • Not ticked: two commits on main: the record and skip, and the graceful stop that needs it (one feature, one switch).
  • The diff follows docs/asset-policy.md (cargo xtask policy: ok).
  • I recorded this PR's dependencies below.
    • Depends on: none (#153 and #215 are in main).

Spec dependence

  • Likely general (helps any card): the record, the stamp and the skip are file and launcher logic; nothing here is GPU specific.
  • May depend on our specs (RTX 2070 SUPER Turing wave32, 8 GB VRAM near budget, ReBAR off, Ryzen 7 5800X, 32 GB RAM, Series S + DLSS Performance): how much time it saves depends on whether the driver's own cache kept the pipelines (NVIDIA 621.40 here), and chunk saves cost disk time on a large library.
  • Untested elsewhere (other GPU generations, AMD, 12-16 GB, Series X, frame generation, ray tracing): everything, and the driver cache behaviour of AMD and Intel.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #147, #153, #215, #264, #266 (all merged; this builds on them), #140 and #142 (merged; the stop's last line is not read as finished by #140's record), #395 (merged DARNER_PRELOAD_CONTROLS; the stop is one more line of its stdin protocol), #234 (see the known limits), #435.
  • Open PRs touching the same code files (checked in the API file lists of all open PRs, 2026-12-05): warm.rs: #165, #234, #270, #365 (#365 also pipeline/known.rs); pipeline/library.rs: #46, #232, #235, #275, #348; main.rs: #435, plus #47, #48, #80, #130, #164, #205, #302, #315, #354, #368 (each has its own edit there). No open PR touches preload_gate.rs, preload_ui.rs or warm/. README.md, locales/*.json and docs/findings.md are edited by many open PRs; conflicts there are textual only. The earlier trial merge with #232, #275, #235 and #270 (clean) was on the old base and was not repeated on 47d21cd3b.
  • Replaces or overlaps: #234 is likely to conflict in warm.rs and touches the same into_library lines; it is complementary (it makes the final save run on the error path), not the same change. Searches for PRELOAD_SAVE_PARTIAL and library-progress found nothing but #215. #435 (open; it shares main.rs and README.md with this branch) calls record_preload() after into_library: a stopped step 3 must not record; warm::stop::requested() tells, and the second to land adds that check. No open PR does this.

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

Refs #128 (stage 3 of the plan in that issue; not a full fix) ## Contributor role (optional) - Fluxer ID: ## What it changes - The problem on main: read from the code only, no log line yet. #147 (`DARNER_PRELOAD_SAVE_EVERY`, on `main` as `144038871`) saves the pipeline library every N seconds during step 3, so a stopped preload's pipelines are in `host-pipelines.bin`. But the next pass still takes the whole list: it reads each pipeline, translates or looks up its shaders, names it and loads it from the library. Nothing records which pipelines a save holds, so nothing is skipped. A pipeline the library lacks only comes back through the driver's own disk cache. New switch `DARNER_PRELOAD_SAVE_PARTIAL=1`, **off by default**. With it on: - Step 3 saves the library in chunks, at `DARNER_PRELOAD_SAVE_EVERY`'s interval, or every 180 s when that is not set. `SAVE_EVERY` itself is unchanged. - After each save that wrote the file, `pipelines/library-progress.txt` is written (temporary file, then rename). It holds a version, the translator-and-settings key (`known::fingerprint()`), the card, a stamp of the exact library file that save wrote (length plus blake3 of its first and last 64 KiB), the count, and the keys of the pipelines finished before the save began. A record without its last line `end` counts for nothing. - At the next start the library is opened first. The record counts only if it is whole and its key, card and stamp all match the library the host accepted. Then those pipelines are left out of step 3. In any other case (no record, a torn record, another translator, driver or card, a library a game run saved since, a library the host rejected) step 3 makes everything, as on `main`. - When step 3 finishes, the record is removed. - Two new lines (switch on only): `DARNER_PRELOAD_SAVE_PARTIAL: N pipelines are in the library an earlier preload saved, M left to make`, and `... library-progress.txt is for another library, translator, driver or card; making them all`. - With the switch on, "opening the pipeline library" is printed before the "into the pipeline library: M" line, because the library has to open first. #215's parser reads both orders (test added). - **Graceful stop (second commit, same switch).** Play now and Quit no longer kill step 3 at once. The window starts the preload with a pipe on its stdin and `DARNER_PRELOAD_STOP_STDIN=1` (set by the window, not a switch to set by hand), and writes the line `stop` (`Control::Stop` of #395's control protocol; one reader of stdin, which with `DARNER_PRELOAD_CONTROLS=1` is the controls' reader, else `warm/stop.rs`). The preload finishes the pipelines in hand (`known::make_while` checks before each one, also in `DARNER_PRELOAD_SCHEDULE`'s queue), saves the library with the same stamped save the chunks use, keeps the record and exits. The window stays open saying "Saving what is done, then stopping. This can take a minute." until the preload ends, at most 60 s, then kills it as before. Only step 3 is asked; steps 1 and 2 are killed at once as on `main`. A stopped pass prints `stopped early: ...`, not `N of M in the pipeline library in S s`, so the window and #140's record do not take it for finished. A closed pipe (the window gone) is a stop too. While it stops, the gate lets every thread through and the load and Pause buttons do nothing. With the switch off nothing changes: no pipe, `taskkill` as before. **With the switch off** no record is read or written, no stamp is computed, there are no extra saves, and the output lines are the same as on `main`. Why a stamp and not just the list: skipping is only a time saving, and it must never claim a pipeline the library does not hold, because that pipeline would then be compiled in the game. Microsoft's docs say serialized library data is invalidated by a runtime or driver update and is not portable across hardware, and that `CreatePipelineLibrary` rejects a corrupt or foreign blob ([Serialize](https://learn.microsoft.com/windows/win32/api/d3d12/nf-d3d12-id3d12pipelinelibrary-serialize), [CreatePipelineLibrary](https://learn.microsoft.com/windows/win32/api/d3d12/nf-d3d12-id3d12device1-createpipelinelibrary)). The stamp is taken from the bytes the host actually loaded, and the save's stamp from the temporary file it wrote, so a later game run or another PR that changes which file is read cannot make the record match a different library. Why periodic saves as well: Play now and Quit end the preload with a `taskkill /PID <child> /T /F` call after the window closes (`preload_ui.rs`), which the graceful stop replaces for step 3 only; a crash, a kill, a step 1 or 2 stop and a stop that takes over 60 s still lose what was made since the last chunk save. Files: - `apps/darner/src/warm/progress.rs` (new): the record, its parse, write, read and clear, `left_to_make`, `save_round`, tests. - `apps/darner/src/warm.rs`: `resume_from_record`, the wiring in `into_library`, `save_partial_on`. - `apps/darner/src/preload_ui.rs`: the window hint treats the switch as "saving on the way"; a parser test for the new line order; the stop (pipe, "stopping" text, 60 s wait). - `apps/darner/src/main.rs` (6 lines): `warm::stop::listen()` before the preload starts, and an early return when a stop was already requested before step 3. - `apps/darner/src/warm/stop.rs` (new), `apps/darner/src/preload_gate.rs` (`Control::Stop`), `locales/en.json`, `locales/zh-CN.json`: the stop. - `crates/darner-gpu/src/pipeline/library.rs`: stamps (`stamp_of`, `file_stamp`, `opened_stamp`, `save_stamped`), taken only when the switch is on; a test. - `crates/darner-gpu/src/pipeline/known.rs`: `library_stamp`, `keep_library_stamped`. - `README.md` (a switch row), `docs/findings.md` (a section). The branch is two commits on `main` (47d21cd3b), which already has #140, #142, #153, #215, #264 and #266: `7636f3d29` (the record, the stamp and the skip) and `2919c85a5` (the graceful stop). `git diff --stat trustno1/main...HEAD`: 12 files, +951/-45. `main` has since moved to d91d8e4d6 (the F2 RAM-speed note: README, locales, `host/`). The branch was not rebased; a trial merge with it is clean (checked 2026-12-05). Credit: the idea is from the plan in #128 and builds on #147 (ours). Nothing is ported from another fork. ### Known limits - A store the driver refuses with an error other than `E_INVALIDARG` still returns a pipeline, so it would be listed though it is not in the library. It is then made in the game, as `main` already does for such pipelines at every start. - Every chunk save writes the whole library file (about 2 GB on a warmed install), as `SAVE_EVERY` does. The cost is not measured. - **The gain is expected to be small where the driver's cache kept the pipelines.** On our PC, in one split preload run, the driver cache alone brought back about 6,500 step-3 pipelines in about 10 s. It should help more where the driver cache dropped them (size limit, cleared cache) and in no longer depending on it. - Combined with #234 (final save on a thread-spawn error): a step that ends with a spawn error keeps its last chunk record, but #234's final save changes the file, so the stamp no longer matches and the next pass makes everything. Safe, just no skip. ## How it was tested - Tested revision: branch `up-preload-library-progress-v2` @ `2919c85a5`, on `main` @ `47d21cd3b`. - Commands and results (there is no CI upstream; these are the ones I ran on `2919c85a5`): - `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: clean - `cargo test -p darner --bin darner --locked`: 210 passed, 0 failed, 1 ignored - `cargo test -p darner-gpu --lib --locked pipeline::known`: 15 passed, 0 failed - `cargo xtask policy`: ok (566 files) - New tests: in `progress.rs`, `a_record_is_written_and_read_back`, `a_record_that_is_not_whole_counts_for_nothing` (every cut point), `a_record_for_another_library_translator_driver_or_card_is_ignored`, `the_stored_pipelines_are_left_out_in_order`, `switch_off_saves_as_before_and_writes_no_record`, `a_save_records_what_it_holds_and_a_save_that_did_not_write_records_nothing`, `the_interval_is_save_every_or_three_minutes`; in `library.rs`, `a_library_stamp_is_the_same_from_memory_and_from_the_file`; in `preload_ui.rs`, the extended `what_the_last_line_said_is_the_activity`. Graceful stop: in `stop.rs`, `a_stop_line_sets_the_flag_and_other_lines_do_not`, `the_input_closing_is_a_stop_too`, `a_pipe_that_is_open_and_quiet_does_not_stop`; in `known.rs`, `a_stop_leaves_the_pipeline_in_hand_finished_and_the_rest_unmade`; in `warm.rs`, `a_stopped_step_saves_what_it_made_and_records_it_instead_of_publishing`, `a_step_that_ran_to_its_end_publishes_and_clears_the_record`, `a_stopped_pass_does_not_print_the_line_that_says_finished`; in `preload_gate.rs`, `a_stop_line_opens_the_gate_and_calls_the_stop_and_the_end_of_input_does_too_when_listening`; in `preload_ui.rs`, `the_stop_is_a_control_line_and_the_buttons_wait_while_it_is_asked`, `a_stopped_pass_is_not_read_as_a_finished_one`, `only_step_three_with_the_switch_and_a_pipe_stops_gracefully_else_it_is_killed_as_before`, `the_stop_is_one_line_and_the_wait_is_bounded`. - Changes a default: no. The switch is off by default. - A/B result: the switch is off by default, and it was checked by unit tests only (`switch_off_saves_as_before_and_writes_no_record`). Not run in a game, so there is no A/B and no timing. | | A (off) | B (on) | |---|---|---| | not measured | not run | not run | - Gates run on that revision: clippy workspace: yes. Clippy workspace with `--all-features`: yes. `cargo test -p darner --bin darner --locked` and `cargo test -p darner-gpu --lib --locked pipeline::known`: yes. `pipeline::library` tests: **not run**. Full `cargo test --workspace --locked`: **not run**. There is no CI upstream. - Gameplay: **not run in a game.** The machine for the later run: RTX 2070 SUPER 8 GB (Turing), driver 621.40, ReBAR off, Ryzen 7 5800X, 32 GB, Windows 11 Pro Insider 26320; Series S, DLSS Performance, frame generation off, ray tracing off. - Shader wave sizes tested: not relevant (no translation change). - Hardware dependence: likely general; how much time it saves may depend on whether the driver's own cache kept the pipelines. Details in "Spec dependence". - Not tested without a game: how long a stop takes, whether 60 s is enough, the pipe with the real window, a stop while paused. - Coverage gaps: every game run (the steps below), chunk-save cost on a 2 GB library, other GPUs and drivers, and the full workspace tests. ### In-game test, to run before WIP comes off 1. Preload with `DARNER_PRELOAD_SAVE_PARTIAL=1` (optionally `DARNER_PRELOAD_SAVE_EVERY=60` for a faster first save) until step 3 has a cold part. Wait past one save (the log says `host pipeline library saved`, and `pipelines/library-progress.txt` appears with a count above 0). Then click **Play now** or **Quit**. 2. Start again. The preload log must show `DARNER_PRELOAD_SAVE_PARTIAL: N pipelines are in the library an earlier preload saved, M left to make`, with N about the count at the last save, and the window's total must be M. Step 3 must finish, the record must be gone, and the done mark written. 3. Stale cases: change a translator switch, or delete `host-pipelines.bin`, before the restart. The "is for another library ..." line and the full count must show. 4. In the game after a finished preload: no rise in in-game compiles compared with a normal finished preload (skipped pipelines must load from the library). 5. Switch off: the logs are the same as on `main`, and there is no record file. 6. Graceful stop: during step 3 click Play now; the window shows "Saving what is done, then stopping. This can take a minute.", the preload prints `stopped early`, the library is saved, the record is there, the window closes. Start again: the pipelines are skipped. Also with `DARNER_PRELOAD_CONTROLS=1`, paused, and with `DARNER_PRELOAD_SCHEDULE=1`. ## Checklist - [ ] I ran this change in the game, or say below why it can't be (docs, tests only). - Not ticked: not run in a game yet. The PR stays a draft (WIP) until it has been. - [ ] This PR contains one change based on `main`. - Not ticked: two commits on `main`: the record and skip, and the graceful stop that needs it (one feature, one switch). - [x] The diff follows `docs/asset-policy.md` (`cargo xtask policy`: ok). - [x] I recorded this PR's dependencies below. - Depends on: none (#153 and #215 are in `main`). ## Spec dependence - Likely general (helps any card): the record, the stamp and the skip are file and launcher logic; nothing here is GPU specific. - May depend on our specs (RTX 2070 SUPER Turing wave32, 8 GB VRAM near budget, ReBAR off, Ryzen 7 5800X, 32 GB RAM, Series S + DLSS Performance): how much time it saves depends on whether the driver's own cache kept the pipelines (NVIDIA 621.40 here), and chunk saves cost disk time on a large library. - Untested elsewhere (other GPU generations, AMD, 12-16 GB, Series X, frame generation, ray tracing): everything, and the driver cache behaviour of AMD and Intel. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #147, #153, #215, #264, #266 (all merged; this builds on them), #140 and #142 (merged; the stop's last line is not read as finished by #140's record), #395 (merged `DARNER_PRELOAD_CONTROLS`; the stop is one more line of its stdin protocol), #234 (see the known limits), #435. - Open PRs touching the same code files (checked in the API file lists of all open PRs, 2026-12-05): `warm.rs`: #165, #234, #270, #365 (#365 also `pipeline/known.rs`); `pipeline/library.rs`: #46, #232, #235, #275, #348; `main.rs`: #435, plus #47, #48, #80, #130, #164, #205, #302, #315, #354, #368 (each has its own edit there). No open PR touches `preload_gate.rs`, `preload_ui.rs` or `warm/`. README.md, locales/*.json and docs/findings.md are edited by many open PRs; conflicts there are textual only. The earlier trial merge with #232, #275, #235 and #270 (clean) was on the old base and was not repeated on `47d21cd3b`. - Replaces or overlaps: #234 is likely to conflict in `warm.rs` and touches the same `into_library` lines; it is complementary (it makes the final save run on the error path), not the same change. Searches for `PRELOAD_SAVE_PARTIAL` and `library-progress` found nothing but #215. #435 (open; it shares `main.rs` and `README.md` with this branch) calls `record_preload()` after `into_library`: a stopped step 3 must not record; `warm::stop::requested()` tells, and the second to land adds that check. No open PR does this. This change was made with AI assistance (Claude Code).
DARNER_PRELOAD_SAVE_EVERY (#147) keeps a stopped step 3's pipelines in the
host pipeline library, but the next pass still reads, translates, names and
loads every one of them again, and gets back from the driver's own disk cache
only what that cache still holds.

With DARNER_PRELOAD_SAVE_PARTIAL=1 step 3 saves in chunks (SAVE_EVERY's
interval, else 180 s) and after each save writes pipelines/library-progress.txt
(temp file + rename): the translator/driver/sampler key, the card, a stamp of
the exact library file that save wrote (length + hash of its first and last
64 KiB) and the title keys finished before the save began. The next pass
opens the library first and leaves those keys out only when the record is
whole and key, card and stamp match the library the host accepted; anything
else and it makes everything as before. A finished step removes the record.
Switch off: nothing is read, written or stamped.

This change was made with AI assistance (Claude Code).
With the switch on, the window starts the preload with a pipe on its stdin and writes a
`stop` line to it (the pipe closing, the window gone, is a stop too). Step 3 checks it
before each pipeline (known::make_while): the workers finish the one in hand, are joined,
and the final save runs as the chunked ones do, writing library-progress.txt for what it
holds. The window stays open saying "Saving what is done" and kills the preload as before
after 60 s. Steps 1 and 2 are killed at once as before. Switch off: nothing changes.

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

I tested the interrupted-save path in 2919c85. With an earlier record on disk and one new pipeline pending, final_save returned success and the final line said “library saved” even when the writer returned no stamp. The record on disk still held only the earlier pipeline. The control writer returned a stamp and persisted both keys.

This used the PR's actual final_save, final_line, and save_round with a simulated writer refusal. The real writer can return that result when it cannot acquire its lock. Could the stopped run report whether new progress actually reached disk, while still letting Play now and Quit proceed?

I tested the interrupted-save path in `2919c85`. With an earlier record on disk and one new pipeline pending, `final_save` returned success and the final line said “library saved” even when the writer returned no stamp. The record on disk still held only the earlier pipeline. The control writer returned a stamp and persisted both keys. This used the PR's actual `final_save`, `final_line`, and `save_round` with a simulated writer refusal. The real writer can return that result when it cannot acquire its lock. Could the stopped run report whether new progress actually reached disk, while still letting Play now and Quit proceed?
Jesper-A force-pushed up-preload-library-progress-v2 from 2919c85a52 to 1ba759518f 2026-12-05 16:39:50 +00:00 Compare
Author
Collaborator

Closing this old-engine PR because post-merge replaced the preload code it changes: it has no separate step 3 resume file, every pipeline made is on disk at once (preload.rs:16-21). It can be redone on post-merge if the problem shows there.

Written with AI assistance (Claude Code).

Closing this old-engine PR because post-merge replaced the preload code it changes: it has no separate step 3 resume file, every pipeline made is on disk at once (`preload.rs:16-21`). It can be redone on post-merge if the problem shows there. Written with AI assistance (Claude Code).
Jesper-A closed this pull request 2026-12-06 01:25:56 +00:00
Jesper-A reopened this pull request 2026-12-06 01:51:44 +00:00
Author
Collaborator

Reopened: Main is the default branch again, so the close note above no longer applies.

Written with AI assistance (Claude Code).

Reopened: Main is the default branch again, so the close note above no longer applies. Written with AI assistance (Claude Code).
TrustNo1 changed title from WIP: [pr-feature][startup][shaders] Preload step 3 goes on from a stopped pass (DARNER_PRELOAD_SAVE_PARTIAL, off by default) to WIP: Preload step 3 goes on from a stopped pass (DARNER_PRELOAD_SAVE_PARTIAL, off by default) 2026-12-06 03:28:55 +00:00
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'up-preload-library-progress-v2:Jesper-A-up-preload-library-progress-v2'
git switch 'Jesper-A-up-preload-library-progress-v2'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'Main'
git merge --no-ff 'Jesper-A-up-preload-library-progress-v2'
git switch 'Jesper-A-up-preload-library-progress-v2'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'Jesper-A-up-preload-library-progress-v2'
git switch 'Jesper-A-up-preload-library-progress-v2'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'Jesper-A-up-preload-library-progress-v2'
git switch 'Main'
git merge --squash 'Jesper-A-up-preload-library-progress-v2'
git switch 'Main'
git merge --ff-only 'Jesper-A-up-preload-library-progress-v2'
git switch 'Main'
git merge 'Jesper-A-up-preload-library-progress-v2'
git push origin 'Main'
Sign in to join this conversation.
No reviewers
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!450
No description provided.