Pipeline library: VICTORY_LIBRARY_TRIM=once lets the file's pages go once, not after every burst of loads (off by default) #4921
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!4921
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4920"
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?
@xteral67 on GitHub · 2026-12-01 14:07 UTC · original
xteral67:library-trim-once→main· +133 −12 · 1 files · 3 commits · openWhat it changes
trim()lets go of the whole mapped library file (VirtualUnlock) after every burst of pipeline loads. On a PC with little free memory, the next pipeline new to a street then reads its pages back from disk one fault at a time, and the frame waits: "pipeline library: slow load" lines of 2–13 s, with the driver's own call taking all of it.VICTORY_LIBRARY_TRIM=once: the pages go after the first burst only (the world's load). After that, Windows ages pages out by use and keeps what is read. Unset oralways: as before.0: never, as before.page_faultsduring the load,trims(how many times the whole file was let go),since_trim_sandfree_mb. This tells a wait on paged-out library pages from other waits.How it was tested
once): 6 rides, about 28 minutes in all: 6 slow loads, longest 4.0 s. Four of them were at the world's load (43 s after the one trim). The other two (2.1 and 3.0 s) came with 451 MB of RAM free.cargo test, other cards, the Series S profile, Linux.library.rschange in a tree based on v2026.11.30.03, whereoncewas the default. This branch makes it opt-in; that line is the only difference.Checked for overlap
🤖 Generated with Claude Code
@andrewpozdnakov7-jpg on GitHub · 2026-12-01 14:13 UTC · original
On
c8cbc922, a pipeline load clearsTRIMMEDwhile the background trim can still be in flight. Inoncemode the byte counter stays at zero until that worker finishes, so the next idle period can queue a second trim.1e1c7fee gives
oncemode its own reservation, claimed before the worker starts. If the worker fails to spawn, the reservation is released for the next attempt. Thealwaysmode continues to use the per-burst gate.I ran the exact Windows trim scheduler with a stubbed worker queue and file-page operation. With the first job held pending across another load and idle period, the author head queued two jobs and the patch queued one. In the same fixture, a failed spawn retried,
alwaysqueued twice across two load bursts, and0queued nothing. The staged asset policy passed.Please keep the Git author on cherry-pick or rebase, or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>if folding the change in.AI-assisted with OpenAI Codex.
@gut0to on GitHub · 2026-12-01 14:35 UTC · original · reviewed
AI-assisted review; I used an AI assistant to inspect this diff.
@ -480,0 +493,4 @@}static MODE: OnceLock<Mode> = OnceLock::new();static TRIM_QUEUED_ONCE: AtomicBool = AtomicBool::new(false);let mode = MODE.get_or_init(|| match std::env::var("VICTORY_LIBRARY_TRIM").as_deref().map(str::trim) {@gut0to on GitHub · 2026-12-01 14:35 UTC · original
Could the
Never/Once/Alwayspolicy be extracted into a pure helper and covered with tests for the first trim and the post-load transition? This adds a new environment-controlled mode, but no regression test pins thatoncetrims after the intended burst only whilealwayspreserves the existing re-arm behavior. A CPU-only policy test would make the state transition explicit without mutating process environment or spawning the trim worker. AI-assisted review; I traced the mode selection through the load timestamp and trim gate.@xteral67 on GitHub · 2026-12-01 17:00 UTC · original
Done in
d1b74a65: the mode, the gate choice and the claim are now pure helpers (TrimMode::parse,trim_gate,claim_trim), with five CPU-only tests: parsing, never, always (one trim per burst, re-armed by a load), once (first burst only, also with a load while the worker still runs), and a failed worker start freeing the gate. Not run yet: I have no Windows test run for this branch at hand; I will report the result here.@andrewpozdnakov7-jpg on GitHub · 2026-12-01 17:02 UTC · original
I ran the five
library_trim_*tests fromd1b74a65on Windows. I compiled the exact test bodies,loadfixture, and the three pure helpers withrustc --test. All five passed.The
oncetest confirms that a load during the worker's run only re-arms the burst gate. The failed-spawn case confirms a new claim can succeed. This was the CPU-only check of the gate and retry; the actual mapped file and worker weren't used.@cloph-dsp on GitHub · 2026-12-01 17:49 UTC · original
Verification (independent, AI-assisted: Hy4 flash). Windows, Rust 1.100.0 (Scoop rust-msvc), MSVC, commit-scoped shallow worktree.
Base
5fabb46eaf6ed8771321787f8871051abde69b9b, headd1b74a6516166c70d36b7bf701025592b913d0d1.git diff --numstat→ crates/victory-gpu/src/pipeline/library.rs 133/12.All five test names are new on the base —
git grep -F <name> 5fabb46e -- .→ no match, exit 1 for each: library_trim_mode_parses_the_switch, library_trim_never_has_no_gate, library_trim_always_rearms_after_each_burst, library_trim_once_trims_after_the_first_burst_only, library_trim_gate_freed_when_the_worker_does_not_start.git diff --check "5fabb46e..d1b74a65"→ no output, exit 0.Each of the five:
running 1 test,test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1165 filtered out.What they pin, all through the extracted pure helpers rather than the trim thread:
TrimMode::parse: None, "always" and any unrecognised value → Always; " once " (whitespace trimmed) → Once; "0" → Never.claim_trimwith now=1500, loaded_at=1000, quiet=1000 is false because only 500 ms have passed; at now=2000 it is true; at 9000 the same burst's gate is spent, and only a fresh load re-arms it for 11000.All values are synthetic timestamps and three AtomicBools; no pipeline file, no device. Worth flagging for the reviewer: this covers the gate/claim helpers only — the call sites that invoke them from the load path and the trim worker are not exercised here.
GPU/driver N/A. No game data.
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.