Pipelines: the slow list counts only compiles; the pipeline library can be read ahead (VICTORY_LIBRARY_PREFETCH=1) #443
No reviewers
Labels
No labels
accessibility
already-solved
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
merged
needs-decision
needs-game-run
needs-rebase
not-merged
nvidia
obsolete
question
security
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/avatarmanz--VIctory-7900XTX!443
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-443"
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?
@Jesper-Andersson on GitHub · 2026-11-27 08:28 UTC · original
Jesper-Andersson:pipeline-prefetch→main· +329 −13 · 2 files · 1 commits · openFixes #442.
slow-pipelines.txtis meant for compiles that hold a worker for tens of seconds, butlibrary::note_time(crates/victory-gpu/src/pipeline/library.rs:741-752, called fromPending::makeinpipeline/make.rs:91) times the wholeHostPipeline::new, so a load from the pipeline library that takes a second goes on the list too. That happens often: on a SATA disk, while the title streams, a load can fault in cold pages of the mapped library. Nothing ever comes off the list, either. In one cache here the list held 1,817 of 3,224 early keys, many of them pipelines the library had.Queue::pushsends every listed early pipeline toQueue::slow, where at most a quarter of the workers (slow_limit) take them, after all the others. So pipelines that would load in milliseconds waited in a queue meant for long compiles, and a large share of the early pipelines were still not made when the world began to draw.Change
library::note_time,slow_change,compiles_only). A make now knows how it came about:library::came_ofruns it and reads what the library calls on its thread did (Came::Loaded,Compiled, orNothingfor a refusal or a pipeline on the bad list), keeping the most telling one. A compile of 1 s or more adds the key (or raises its time), as before. A compile under 1 s takes the key off. A load does neither. This is a fix of what is counted, so it is on by default;VICTORY_PIPELINE_SLOW_LIST=0restores the old rule (any make of a second is added, nothing removed). Lists that already hold load-made keys lose them as those pipelines are compiled again (a new driver, a rejected library). A key whose pipeline only ever loads stays on until then, but no new ones are added.VICTORY_LIBRARY_PREFETCH=1(off by default) reads the mapped library ahead (library::prefetch, called fromopenwhen the blob is a mapped file). A thread of its own, in background mode (THREAD_MODE_BACKGROUND_BEGIN: lowest CPU, I/O and memory priority), callsPrefetchVirtualMemoryover the view, 64 MB at a time (prefetch_part). It checks free physical memory before each part and stops below 6 GB. Per the API's remarks, the pages go to the system file cache (standby list), not to the process's working set or private bytes. The early loads then find them there instead of faulting them in one at a time. It logshost pipeline library read ahead (VICTORY_LIBRARY_PREFETCH)with the bytes, the time taken and the free memory at the end.early pipelines all made, is written each time the early pipelines started at creation (make::early) are all made (at least 10 more since the last line). It gives the count loaded, compiled and neither,slow_queued,slow_list_added/removedandms_since_first_early. This is the number to compare.Where it does nothing
VICTORY_PIPELINE_SLOW=0(no slow queue): the list is still kept, but nothing reads it.the_slow_list_counts_compiles_only,a_slow_key_that_compiles_quickly_comes_off_the_list,came_of_tells_the_most_telling_call,the_read_ahead_goes_in_parts_while_memory_is_free,early_pipelines_are_counted_once_by_how_they_came.Measured
These numbers come from a local branch, not from main: main plus about 50 merged PRs, with this change (and an experimental third switch,
VICTORY_PIPELINE_SLOW_LOAD_FIRST, left out of this PR because both runs with it alone crashed in the menus). All runs used the same exe and the same unattended scripted route from start to world entry. Machine: RTX 2070 SUPER 8 GB (driver 621.14), Ryzen 7 5800X, 32 GB, Windows 11, game and cache on a SATA QLC SSD. Diag build, Xbox Series S profile, DLSS upscaling.VICTORY_LIBRARY_PREFETCH=1SLOW_LOAD_FIRST=1)The read-ahead took only 33-55 ms because the file was already in the OS file cache. So the gain is not disk reads saved. It comes from the process's own page faults on the mapping during loading, which the prefetch takes out of the loads' path.
What it does not fix: the first run after a rebuild (new shaders, so the library misses) without
victory warm --usedstill has a backlog, because the driver has to compile those pipelines. The read-ahead only helps pipelines the library has.Checks
cargo test --locked -p victory-gpu --lib pipeline: 31 passed (5 new)cargo clippy --locked -p victory-gpu --all-targets: no warnings in the changed files (4 warnings already on main inlist.rs,host/panel.rs,host/place.rs,watch.rs)cargo xtask policy --staged(pre-commit hook): 2 files okNot checked
ms_since_first_earlyin theearly pipelines all madeline and the pipelines still waiting at world entry.Related
VICTORY_PIPELINE_LOW_MEMORY=1) also schedules slow-listed pipelines, at first use and for screen passes. It does not change what goes on the list, so the two fit together.This change was made with AI assistance (Claude Code).
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.