[pr-fix][performance][shaders][memory] Compile memory gate: a compile a draw waits on goes first (#70) #350
Loading…
Reference in a new issue
No description provided.
Delete branch "tommy66/Darner:compile-gate-waited-first"
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?
Fixes the freezes in #70: a pass over the screen waiting seconds for its pipeline while the PC is short of free RAM.
What was wrong
Under the soft floor of free memory (
DARNER_MEMORY_FLOOR_MB, 1024 MB) the gate incompilemem.rslets one driver compile run at a time. Every other compile, the ones a frame is waiting on and the workers' early compiles alike, waits on the same condition variable, and afternotify_allwhichever thread takes the lock first starts. The workers' queue already puts a waited-on pipeline first (Queue::expedite) and raises its worker's priority (boost), but once that worker reaches the gate it has no precedence there. So a frame's pipeline could lose its turn to early compiles again and again, until the screen-wait cap (10 s).The change
DARNER_COMPILE_WAITED_FIRSTis on by default;0brings back the old behaviour.compilemem::asked: itswaiters, orkept_up). Threads other than the workers count as waited on, as before. The gate asks again on every look, because a draw may come to wait while the compile is queued. A draw that starts waiting wakes the gate (compilemem::nudge).DARNER_COMMIT_FLOOR_MB, the hard limit) and the half second after a failed allocation still hold for it, so it adds at most one compile's memory under the soft floor, never under the hard one.Measured
RTX 3090 24 GB, driver 610.88, Ryzen 7 9800X3D, 32 GB, Windows 11 26200. Series X, 1440p, hardware RT, DLAA, DLSS FG 2x. A scripted run (keyboard walk from the save) of 5 min in the world each. Every run started from the same host pipeline library snapshot, with Darner's NVIDIA driver cache files emptied before each run (set aside and restored after), and a helper process holding 12 GB of RAM, which leaves free RAM about where #70's 32 GB PC had it.
DARNER_COMPILE_WAITED_FIRSTTests
5 new unit tests in
compilemem.rs:askedprobe nests and resetscargo test -p darner-gpu --lib compilemem: 18 passed.pipeline::: 125 passed.Written with AI assistance.
Code review only (read the diff at
5e9513a), nothing built or run.begin()leaves the waited-on count,countedfollows the waiter state while it waits, the worker's probe only reads atomics under the gate lock, and the commit floor and just-failed rule still hold for the compile let run beside. Anudgethat races the wait is lost but bounded by the 200 ms look.waitersstays 0 and the worker's retry counts as unwaited here, and is held behind every waited-on compile. If both land, a pass refused under real memory pressure may stay missing longer. Maybekept_up, or a "refused once" flag, could count as waited.Reviewed with Claude Code (AI-assisted); findings checked by a human before posting.
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.