WIP: [pr-feature][startup][shaders] Preload window: live CPU-load presets and pause/resume (DARNER_PRELOAD_CONTROLS) #395
Loading…
Reference in a new issue
No description provided.
Delete branch "Jesper-A/Darner:up-preload-controls"
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 #288
Contributor role (optional)
What it changes
#288 (tarakanovalexey) asks for two things the preload window cannot do today: lower how much of the PC the preload uses while it runs, and pause and resume it. This adds both, behind a new switch that is off by default. (The third part of #288, moving the cache folder, is already answered in the thread, so this is
Refs, notFixes.)With
DARNER_PRELOAD_CONTROLS=1:darner play) gets a row of buttons: 10 %, 50 %, 80 %, Max, and Pause / Resume, plus a line saying what is in force. The window is 46 px taller (96 dpi) to fit them. A preset button does not close the window.DARNER_PRELOAD_LOAD=<1 to 100>sets the preset the preload starts with (default 100 = no limit). It is not read without the controls.darner preloadchild:limit <pct>,pause,go. Lines not understood are ignored. If the window goes away, the last state stays.How a limit works (
apps/darner/src/preload_gate.rs, a new file): each of the three steps askswait_turn(slot, threads)before it takes its next piece of work. A thread whose slot index is at or abovemax(1, ceil(p x threads / 100))sleeps (100 ms steps) until the limit goes up. A pause parks every thread. Slots are numbered per step when each worker starts, so the same percentage works for steps with different thread counts.Where the gate sits (on
trustno1/mainf3840d73dplus this commit,50ed5a933):apps/darner/src/translate.rs:527(single job) and:539(before each shader).apps/darner/src/warm.rs:277, before a thread takes its next 40-pipeline chunk and starts a child.apps/darner/src/warm.rs:592, in the callback thatknown::makecalls before each pipeline.Unchanged with the switch off:
wait_turnreturns at once, no stdin pipe is created for the child, no thread is started, the window keeps its old height. The only code that runs is one cached env read.Why a cooperative gate and not a job-object CPU cap: a hard CPU cap cannot pause.
warm::run_childkills a child that prints nothing for 180 s, and a stopped child would be killed and blamed. Here a parked thread has no child running, so the watchdog has nothing to time.Limits (please read)
while !rest.is_empty(), restarting a child after a failed start) is not gated. A thread already in it can start another child while paused.Credit: the request is tarakanovalexey's in #288. The design is our own; nothing is ported.
Docs: README table rows for both switches, a note in
docs/findings.md, six new strings inlocales/en.jsonandlocales/zh-CN.json(zh-CN strings not checked by a native speaker).A
// SAFETY:comment will be added to the newunsafeblock inpreload_ui.rs::smallbefore WIP comes off.How it was tested
Tested revision: branch
up-preload-controls@50ed5a933(offtrustno1/mainf3840d73d).Commands and results (taken from the porter's run on that revision; nothing here is CI):
cargo clippy --workspace --all-targets --locked -- -D warnings: cleancargo clippy --workspace --all-targets --all-features --locked -- -D warnings: cleancargo test -p darner --locked preload: 13 passed, 1 ignored (6 of them new, inpreload_gate: line parsing, percent to slots, parked slots, a parked thread resuming, the listener, switch off)cargo test -p darner --locked --bin darner translate: 7 passedcargo xtask policy: okChanges a default: no. Both switches are off by default.
A/B result: the switch is off by default; that was checked by unit tests only (
the_controls_are_off_unless_asked_for). No in-game run, no timing, no CPU measurement.Gates run on that revision: clippy workspace: yes. Clippy workspace with
--all-features: yes. Fullcargo test --workspace --locked: not run (only the two-p darnerfilters above). There is no CI upstream.Gameplay, when relevant: not run in game, and the preload was not run with this change. The window was not opened. Machine for any later run: RTX 2070 SUPER 8 GB (Turing), driver 621.40, ReBAR off, Ryzen 7 5800X (8 cores, 16 threads), 32 GB, Windows 11 Pro Insider 26320, Series S, DLSS Performance.
Shader wave sizes tested, when relevant: not relevant (no shader translation change).
Hardware dependence: likely general (thread parking and a stdin line protocol, no GPU or shader code). How much CPU a preset frees may depend on the CPU and its thread count. Details in "Spec dependence" below.
Coverage gaps: UI layout with the extra row (and at higher dpi), the real CPU effect of 10 / 50 / 80 / Max, Pause in all three steps, the 180 s watchdog after a long pause, the zh-CN strings, the full workspace tests. All of these need a real preload and are to be checked before WIP comes off. Not tested on other CPUs, Wine/Proton, AMD/Intel, Series X.
Checklist
main.docs/asset-policy.md(cargo xtask policy: ok).Spec dependence
Checked for overlap
preload_ui.rslayout andrun,locales/*.json), #165 and #234 (translate.rs/warm.rs), #266 (into_libraryworkers). Whichever lands second rebases; the gate calls are single lines and the UI hunk is the part that needs care.This change was made with AI assistance (Claude Code).
At
50ed5a93, a preset below Max can stop a step from finishing. In the translation and child stages, workers parked by slot number stay inside the gate after the admitted workers drain the queue. In the library stage, those parked workers also own fixed slices of the work, so the step waits for them.f088d7d limits simultaneous operations and lets any worker use a free slot. A slot is held for one shader, one child process (including a retry), or one library pipeline. Pause still lets work in progress finish.
A Windows fixture used the gate from both revisions with four workers, eight operations and the 50% preset. The original timed out waiting for the step to join. The follow-up completed all eight operations exactly once, with two active at peak. All seven gate tests, scoped app Clippy and asset policy passed. The full preload and the window remain to be checked.
If you cherry-pick or rebase this commit, please keep the Git author. If you fold it into another commit, please add this trailer.
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>