Pipelines made at first use: what a frame waits on goes first and its worker is raised, siblings made ahead, held-back library saves follow #4255
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4255"
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?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Lyrnc on 2026-11-30T17:51:29Z.
Problem
Pipelines made at first use are the big drops players feel at camera cuts, character switches and shootouts.
VICTORY_PIPELINE_WAIT_ALL, on): up to 10 s a frame, as a pass over the screen; before that, 500 ms;WAIT_ALL, main takes "a hitch once (the library has the pipeline the next run)" over "a picture with things missing". So what is left to shorten is each hitch and the number of them, and "the next run has it" has to hold.Root cause
p.make()inready()). The boost is never applied on that path, so the build runs atTHREAD_PRIORITY_LOWESTbehind a title that keeps every core busy.library::wanted_early). So a cut to something new brings each of them in turn, each its own hitch.VICTORY_PIPELINE_WAIT_ALL=0, the wait does not know whether it can win. A dropped draw is drawn again next frame, but the frame was held up to 500 ms first, and the next frame waited again for the rest of the compile.Fix
Three commits.
#3819 (Remag501), cherry-picked:
VICTORY_PIPELINE_WAIT_ONCE_MS. A pipeline is waited for at most its cap in the whole run, counted over all frames (Pending::waited_ms). Off by default, as in #3819. Its reservation goes through main'sreserve_wait(#2414).The waited-on first and raised, siblings made ahead (
make.rs):Queue::expedite;VICTORY_PIPELINE_WAITED_FIRST=0: as before). When a draw or dispatch begins waiting on a pipeline that is requested but not taken yet:blockedlist, which workers take right after the passes over the screen. The workers that take only what draws wait on (VICTORY_PIPELINE_ASKED_WORKERS) take it too;WAIT_ALL, every draw) moves to the front of the screen list, so passes over the screen still go first.VICTORY_PIPELINE_NOW_FIRST(off) had the same reason: a cold library's requests waited 10-175 s behind the requests of scenes the title had left.Pending::expedited, cleared when it is queued again after a deferral).ready()counts as a waiter and boosts the worker that has the build, aswait()already does. The dispatch still waits for the build. Nothing that waited before is dropped now.warm_siblings;VICTORY_PIPELINE_SIBLINGS=n, default 8;0: none):FAMILIES): its shaders' stages and hashes without the state (Pending::family, from the key's hasher before the state goes in). The notes are weak references.library::note_usednow says so) and not made, up to 8 of its family are queued. Those are the title's pipelines of the same shaders with another key, not queued, made, left out or paused.sibling_limit), andkeep_freeapplies.pipelines queued ahead with a sibling's first drawat powers of two (queued, asked for later, found made). The same counts are on thehost pipelines all madeline.VICTORY_PIPELINE_WAIT_ALL=0only:has_fallback: graphics, not passes over the screen, first-scene producers or skinned meshes waited for as one) wait 100 ms once in the run (VICTORY_PIPELINE_DRAW_ONCE_MS, #3819's cap for them alone;0: as before), then are dropped while the pipeline compiles;keep_up;VICTORY_PIPELINE_BOOST_KEEP,0: as before).WAIT_ALLon (main's default), no draw has a fallback, and neither applies: main's choice of waiting over pop-in (the trees that went missing) stands. Dispatches and passes over the screen are never capped by it. #2580 shortened those too and was reverted for the black shadows of a dropped one-shot dispatch.Held-back saves follow (
library.rs,follow_up;VICTORY_LIBRARY_SAVE_FOLLOW=0: as before):save(false)is held back by its interval or byVICTORY_LIBRARY_SAVE_QUIETwhile pipelines are not saved yet (added > 0), a threadvictory-pipelines-save-duesaves once the interval is over.store_waitingafter a save get a follow-up one interval later.Verification
Windows 11, rustc 1.98.1 (the pinned toolchain), Ryzen 7 9800X3D, target directory of its own.
On
59c13224, in a build slot, with its own target directory:cargo check -p victory-gpu --locked -j 4: passes. The crate's one warning is on main's lines (shadow.rs:7197,rangednever used).cargo test -p victory-gpu --lib --locked -j 4 -- pipeline::make pipeline::library: 73 passed, 0 failed, 0 ignored. This includes #3819's three tests and these new ones:the_draw_once_wait_is_on_by_default: the cap's value is 100 ms unless set;0turns it off.only_draws_with_a_fallback_have_the_draw_cap:WAIT_ALLoff;once_cap_forcombines it with #3819's switch.a_capped_draw_waits_once_then_drops: a pipeline nobody finishes is waited for its 100 ms in one frame. The next frame does not wait at all, under whichever budget it waits with.a_pipeline_a_frame_waits_on_goes_first:blockedlist once and is taken first;workers_stay_raised_for_dropped_draws_a_few_at_a_time:0, when every draw waits, when the pipeline is made or put off, for a pass over the screen, or for a dispatch.a_dispatch_waiting_on_a_worker_raises_it: a real thread atTHREAD_PRIORITY_LOWESTholds the build. A dispatch (ready()on a compute pipeline) blocks on it, and the worker readsTHREAD_PRIORITY_NORMALwhile the dispatch waits. The dispatch gets the worker's result, and the waiter count is back at 0.siblings_are_the_same_shaders_in_another_state:siblings_wait_behind_the_rest_and_are_taken_once:a_new_first_use_queues_its_siblings: withadopt(),note_used()andfirst_use(), a first use new to the book queues its sibling. Another family stays unqueued.a_save_is_held_back_for_the_rest_of_its_interval,the_earlier_follow_up_save_wins,a_used_key_is_new_once.cargo clippy -p victory-gpu --all-targets --locked -j 4: no warning inmake.rsorlibrary.rs. The two it gives are on main's lines:shadow.rs:7197, andhost.rs:5092(manual_is_multiple_of).perf/warm-waitedand #3347's rework) merge with each other without conflicts (git merge-tree).NOT tested
found_madecount), and the CPU and library growth they cost. They also keep the workers busy longer, so the save when the queue runs dry comes later;WAIT_ALL=0: pop-in at cuts, and 2 workers kept at normal priority beside the title's threads.WAIT_ALL=0) are picked, not measured.Bench steps:
Not run. To run the bench:
84bd61e2plus #3703 (the long-frame line).make.rswith both: put its feeds inwait()/wait_capped()and the inline compute make.host-pipelines.bin,early-pipelines.txt,slow-pipelines.txt,warm-done.txt.cache\shaders, so translation is not what differs.long frame N ms ... pipeline waits P (graphics G; compute C; screen S ...)lines, count frames with N ≥ 250 ms and P ≥ N/2. Count them all, and by the largest part.a pass over the screen was waited forlines; withWAIT_ALL, every draw waits as one.pipelines queued ahead with a sibling's first drawgives queued, asked for and found made. The siblings' hit rate is found made / queued; their cost is the extramadeagainst A.host pipelines all made: siblings_*, boosted, waited_out.the save its interval held back.VICTORY_PIPELINE_WAITED_FIRST=0;VICTORY_PIPELINE_SIBLINGS=0;VICTORY_PIPELINE_BOOST=0(all raising off, #283's too);VICTORY_LIBRARY_SAVE_FOLLOW=0.VICTORY_PIPELINE_WAIT_ALL=0on both arms (the old 500 ms budget). On B this brings in the 100 ms cap and the kept boost.draws dropped for pipelines not made yet, and how many consecutive frames each key is dropped.VICTORY_BVH_BUILDER=1), one pair from a cold library.loadedagainstmade, no hitch there.Overlap
Searched with
gh pr list --state open --search: "pipeline wait", "pipeline priority", "pipeline queue", "warm pipelines", "preload", "sibling", "pipeline family", "first use", "compile grace", "boost", "stutter pipeline", "hitch". Merges were checked withgit merge-treeagainst main84bd61e2and against this branch.reserve_wait. If #3819 merges first, drop that commit; the next two apply on top.3fa588eb) for black shadowed surfaces after a cold run.WAIT_ALL=0: 100 ms once for draws that have a fallback, through library loads and translations. Main'sWAIT_ALLnow goes the other way. Itscompile_beginshook is not taken.warm --waitedpart is in a separate branch,perf/warm-waited(Kajcsi as author).66124155(main, v2026.11.30.02):VICTORY_PIPELINE_WAIT_ALL, every draw waits for its pipeline as a pass over the screen (up to 10 s a frame), because dropped draws took stands of trees away for a second. This branch keeps that default. The 100 ms cap for draws with a fallback applies only withWAIT_ALL=0, and the waited-on-first move works in the screen list thatWAIT_ALLputs every draw in.wait(). #3788 already conflicts with main inmake.rs, and with this branch in the same place.library.rs(it is on41adb551), not newly with this branch.ready(). To resolve, keep the boost around #3700'swait_made.make.rs(on41adb551). This branch adds no new conflicting files for them.wait()and the inline compute make. A rebase onto this branch puts its feed around the new waiters code.VICTORY_PIPELINE_ASKED_WORKERSis already on main. Those workers take the newblockedlist too.AI use
Claude Code (Claude Opus 5.5) wrote the change and its unit tests, resolved the cherry-pick of #3819 onto main, ran the checks listed above, and wrote this note. Nothing was run in game.
🤖 Generated with Claude Code
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by IRennie74 on 2026-11-30T18:23:08Z.
The waited-on-first queue and raising the worker a dispatch blocks on both look like clear wins: nothing is dropped that main would not drop. My concern is with siblings being on by default (
VICTORY_PIPELINE_SIBLINGS, 8), since the PR says those defaults are "picked, not measured".Compile memory. On a Ryzen 5 5600X + RTX 3060 12 GB + 32 GB (Series S), compiles do hit memory limits in play:
make.rsfix);refused.rs).Eight speculative siblings per new first use add driver compiles in exactly the bursts (cuts, new areas) where those limits are reached.
keep_freehelps with the workers, but not with the driver's memory.CPU. On that 6-core the CPU is close to saturation in the world (the title about 3 cores, list threads 1.7).
sibling_limitgives 2 of 9 workers to guesses. They run below the title, but they still take the cores that the boosted, waited-on build and our submitting thread compete for.Library growth. Every sibling that is made goes into the library and is saved with it. The PR already notes 100 s save intervals at 1.3 GB and 6 min at 4.78 GB.
Could siblings ship with
0as the default (or behindasked_for!) until a run reportsfound_made / queuedfrom the new line? The rest of the PR does not depend on them.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:44:58Z.
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed