WIP: Preload controls: a limit below Max no longer stops a step from finishing (DARNER_PRELOAD_CONTROLS) #458
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
hle
input
INTEL
lighting
linux-proton
memory
MULDER
needs-info
needs-logs
needs-rebase
NVIDIA
performance
post-merge
pr-diagnostics
pr-docs
pre-merge
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
relevance
high
relevance
low
relevance
medium
relevance
very-high
rendering
report
roadmap-proposal
saves
series-s
shaders
startup
status
blocked-by-rework
status
needs-test-report
status
needs-triage
status
ready-for-review
status
stale
status
superseded
status
wip
tools
ui
upstream
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
TrustNo1/Darner!458
Loading…
Reference in a new issue
No description provided.
Delete branch "Jesper-A/Darner:up-preload-controls-gate-fix"
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 #395
Refs #128
Contributor role (optional)
What it changes
Follow-up to #395 (merged at
02a0edf85). #395 is merged, so this is a new PR. It carries the fix that andrewpozdnakov7-jpg reported on #395: #395 (comment). That fix is not in the merged #395.DARNER_PRELOAD_CONTROLS=1and a preset below Max, a preload step can fail to finish. Workers were parked by slot number. In the translation and child-process steps, the parked workers stayed in the gate after the admitted ones had emptied the queue. In the library step, the parked workers also own fixed slices of the work, so the step waited for them for ever. This is from andrewpozdnakov7-jpg's report (he ran it with a test of the gate on Windows) and from reading the code. I did not run a full preload to see the hang.apps/darner/src/preload_gate.rs). A worker takes a permit before each operation and gives it back after (when the permit is dropped). An operation is one shader, one chunk of child processes with its retries, or one library pipeline. The number of permits isceil(percent x threads / 100), at least one. Any worker may take a free permit, so no worker owns a slot and every slice still gets done, only more slowly.translate.rsandwarm.rs(runandinto_library) ask for the permit before they take their next piece of work.wait_turnreturns at once with nothing to hold, as before.SAFETY:comment on theunsafeblock inpreload_ui::small.translate::a_limit_below_max_still_finishes_the_step(4 workers, 8 shaders, 50 %) must finish within 10 s with every shader done once and no more than 2 at a time.preload_gate::fixed_slices_all_get_done_below_maxdoes the same for the library's fixed slices. The commit message says the first test timed out before the change; I did not re-run the old code for this post.Credit: the counting gate with a permit given back on drop is andrewpozdnakov7-jpg's commit
f088d7d(andrewpozdnakov7-jpg/Darner@f088d7d525), as he asked. Our commit has hisCo-authored-by:trailer. The code here is adapted to main.Please check the
warm.rshunk. It conflicted with #266's chunk queue (merged), and I resolved it by hand. Ininto_librarythe callback is nowlet mut each(it isFnMut: it keeps aturnfor the pipeline in progress) and is passed as&mut each. Inrunthe loop takes its permit first and the chunk second (let _turn = wait_turn(threads), thenchunks.get(next...)), so a worker that waits has taken no chunk. Please read these two places against #266's queue.Merge check: this branch is on main
47d21cd3b. Main is nowd91d8e4d6.git merge-tree --write-tree trustno1/main <branch>gives a clean tree, no conflicts.How it was tested
up-preload-controls-gate-fix@935c00915, based on main47d21cd3b.-p darner; the three workspace gates were not run):cargo test -p darner --bin darner: 195 passed, 1 ignored, in the porter's run on935c00915.cargo xtask policythrough the pre-commit hook: ok.DARNER_PRELOAD_CONTROLSstays off by default; with it off the gate does nothing, as before.--all-features) andcargo test --workspace --locked. There is no CI.darner preloadwith a preset below Max, and the controls window.WIP:comes off:Spec dependence
Checklist
main: the gate limit (with theSAFETY:comment beside it in the same commit).docs/asset-policy.md. (Code and tests only;cargo xtask policyok on the commit through the pre-commit hook.)Checked for overlap
preload_gate.rs(+63/-10),warm.rsandpreload_ui.rs, so expect textual conflicts: whichever lands second is rebased. Which lands first is the maintainer's call; we will rebase ours on request. #234, #270, #365, #165 touchwarm.rs, and #165, #379 and #394 touchtranslate.rs. None touches the gate. Open PRs are searched through the API (220 open on 2026-12-05).This change was made with AI assistance (Claude Code).
I checked the hand merge with #266 on
935c00915. Inwarm::run, the permit is acquired before the chunk index and held across child retries. Ininto_library, a queued range can be reserved before a permit is available, butknown::makeacquires the permit in its before-pipeline callback and releases it in its completion callback. The fixed-slice path uses the same callback.On Windows with an RTX 3060 Laptop GPU, I ran
darner preload --all --jobs 4on 256 distinct project-generated compute pipelines at 50%, withDARNER_PRELOAD_SCHEDULEoff and on. Both runs exited successfully and saved a library withmade=256 loaded=0. A separate fixture exercising the productionwarm::runloop also finished all 205 records exactly once at 50%, with a peak of two chunks in progress.One boundary case affects the promise that Pause hands out no new permits. In an instrumented run with both permits held, I stopped a waiting worker just after it read
paused=false, appliedpause, and let one active chunk finish. Releasing that worker started a new chunk beforegoin 3/3 runs; this was its first child call, not a retry. A fresh request started after Pause was rejected. The checkpoint only controlled timing; this does not estimate how often it happens in normal use.If applying Pause should close admission immediately, making the control update and permit grant mutually exclusive would cover that case. I did not run a game or measure CPU load.
935c00915atode0cce9a25Closing this old-engine PR because post-merge replaced the preload controls and load limit it fixes (
preload.rs:16-21). It can be redone on post-merge if they come back and the problem shows there.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).
WIP: [pr-fix][startup][shaders] Preload controls: a limit below Max no longer stops a step from finishing (DARNER_PRELOAD_CONTROLS)to WIP: Preload controls: a limit below Max no longer stops a step from finishing (DARNER_PRELOAD_CONTROLS)View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.