play: preload pipeline books recorded after an empty-cache start #4486
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!4486
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4485"
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?
@nidea1 on GitHub · 2026-11-30 21:05 UTC · original
nidea1:fix/preload-empty-cache-book→main· +579 −37 · 5 files · 6 commits · closed without mergingRelated: #4177
What it changes
Starting from an empty cache (or after clearing the shader cache via
F1 -> CLEAR SHADER CACHE/ manual deletion):warmup_markrunsvictory preloadbeforeknown-pipelines.binexists, sowarm::runsees 0 known pipelines, creates a 0-bytewarm-done.txt, andfinish_preloadwrites%LOCALAPPDATA%\victory\warmed\<exe-hash>. The first play session then populatesknown-pipelines.bin,early-pipelines.txt, and a partialadapters/<gpu>/host-pipelines.binwhilewarm-done.txtstays empty/missing.warmup_markis already written, sopreload_needed()falls back toneeds_pipelines(). Becauseneeds_pipelines()only checkedknown-pipelines.bin.is_file() && !made_in(pipelines), Session 1's partialhost-pipelines.bincaused it to returnfalse, so the newly recorded pipeline book was never preloaded.needs_pipelines()walked all ofadapters/(so a library built forgpu0suppressed preload when running ongpu1), ignoredVICTORY_LIBRARY_DIR, and could loop indefinitely when a tiny book with emptyearly/slowlists produced nohost-pipelines.bin.This PR fixes those gaps without adding new dependencies, environment variables, or forcing
--all:crates/victory-gpu/src/pipeline/library.rs,known.rs): extractsadapter_dir_name(&DXGI_ADAPTER_DESC1)foradapter_dir()and exposesknown::adapter_dir_name()via a pure DXGIhardware_adapter()+GetDesc1()query (respectsVICTORY_ADAPTER, no D3D12 device created).apps/victory/src/play.rs,main.rs): addspipelines/preloaded.txt(<adapter_key> <book_bytes> <0|1>) removed alongsideadapters/,warm-done.txt,warm-bad.txt, andhost-pipelines.*on translator updates (is_stale_pipeline_entry) while keepingknown-pipelines.bin.play::record_preloaded()runs at the end ofCommand::Preloadonly aftertranslate::precompile,warm::run, andwarm::into_libraryall succeed, and skips writing whenknown-pipelines.binis missing or 0 bytes (empty-cache Start 1).VICTORY_LIBRARY_DIR-awareneeds_pipelines_for()(apps/victory/src/play.rs):host-pipelines.bin*/host-pipelines.nextonly in the active adapter directory + legacy top-level fallback underVICTORY_LIBRARY_DIR(orpipelines), ignoring other adapters and lock/temp files.preloaded.txtrecord exists for the active adapter, re-triggers only if a previously created library was deleted (had_library && !has_library) orknown-pipelines.bingrew>= 2x, preventing infinite preload loops on tiny books or emptyearly/slowlists.preloaded.txtrecord exists yet for the active adapter and a host library is present, checks whetherwarm-done.txthas at least one non-empty line — triggering Start-2 preload after an un-preloaded empty-cache first session while avoiding spurious re-preloads on already-warmed caches from earlier builds.How it was tested
host-pipelines.binand skipping preload; switching adapters saw another adapter'shost-pipelines.bin;VICTORY_LIBRARY_DIRwas ignored; tiny books producing no library loopedneeds_pipelines() == true.pipelines/preloaded.txtper adapter upon completion, preserves legacy preloaded caches (non-emptywarm-done.txt) without re-preloading, handles multi-adapter switching andVICTORY_LIBRARY_DIR, re-triggers on deleted libraries or>= 2xbook growth, and wipespreloaded.txton translator updates.cargo testpassed for the crates it touches: yescargo test -j 4 -p victory: 96 unit + 1cache_paths+ 2census= 99 passed, 0 failed (updateda_book_without_made_pipelines_is_preloaded+ 5 new regression tests).cargo test -j 4 -p victory-gpu --lib -- pipeline::library: 21 passed, 0 failed (includingadapter_dir_name_matches_adapter_dir_layout).cargo clippy -j 4 -p victory -p victory-gpu --all-targetsand--all-features: 0 warnings invictoryand 0 warnings in touchedvictory-gpufiles.cargo run -j 4 -p xtask -- policy --staged:asset policy: 4 files ok.Checked for overlap
#4231(merged) preserved the pipeline book across translator updates; this PR closes the remaining empty-cache Start-2 gap on#4176.#3588surfaces I/O errors readingknown-pipelines.bininwarm.rs/known.rs(orthogonal).#4256adds opt-invictory warm --waited(VICTORY_WARM_WAITED=1, orthogonal).65b435f030to02f2fa3eec@andrewpozdnakov7-jpg on GitHub · 2026-12-01 11:52 UTC · original
Two preloads can finish on different adapters against the same pipeline book. On
02f2fa3e, both can read the samepreloaded.txtand then each replace the whole file. Whichever writes last drops the other adapter's mark, which can trigger another preload at its next launch.d9a7ad44c50bc6d016862de1c53407cda51725b3 appends a complete record. The existing reader already uses the latest valid line for each adapter, so older records continue to work. Review commit
I used a two-writer Windows fixture with the exact marker functions. A barrier after the original snapshot reads reproduced the lost row deterministically. With the patch both adapter rows and the existing row survived, and a later complete record took precedence after an interrupted line.
cargo xtask policy --stagedpassed forplay.rs.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.
@nidea1 on GitHub · 2026-12-01 14:44 UTC · original · edited 2026-12-01 15:09 UTC
Thanks @andrewpozdnakov7-jpg for catching the cross-adapter overwrite race and providing the append-only fix!
Cherry-picked
d9a7ad44c5onto this branch asb7ef87fc80with your original Git author preserved, hardenedread_preloaded_recordto decodepreloaded.txtline-by-line from raw bytes (90a7ebb0cf) so an interrupted/corrupted non-UTF-8 byte in an earlier append cannot poison newer valid appends into an infinite preload loop, and addedappending_preloaded_records_preserves_multiple_adapters_and_recovers_from_partial_line(ed8945ade0,90a7ebb0cf) covering 4-thread x 16-append multi-adapter contention, partial trailing lines, and non-UTF-8 corruption recovery.Verified on
90a7ebb0cfwithcargo test --locked -p victory(97 unit + 1cache_paths+ 2censuspassed, 0 failed),cargo clippy --locked -p victory --all-targets -- -D warnings(0 warnings), andcargo xtask policy(464 files ok).@andrewpozdnakov7-jpg on GitHub · 2026-12-01 15:42 UTC · original
A related caller on
90a7ebb0still looks only at the shared root. WhenVICTORY_WARM_SHARED=1,warm --useddiscards its existing completion marks if the library is underadapters/<selected adapter>/. That can compile the same pipelines again even when their library is present.1bc46671 reuses this PR’s adapter-aware library check. It accepts the current adapter’s installed or pending library and the legacy root file. Only the actual cache file names count.
A focused Windows fixture exercised the real file checks with a stub adapter name. The selected adapter’s installed and pending files changed from rejected to recognized. The other adapter’s file and a backup stayed outside the warm decision, and the legacy file still worked. The staged asset policy passed. The patch combined cleanly with the #3895 marker follow-up and #4959.
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.
@nidea1 on GitHub · 2026-12-01 18:31 UTC · original
Thanks @andrewpozdnakov7-jpg for catching the
VICTORY_WARM_SHARED=1shared-root check and tighteningis_library_file!Cherry-picked
1bc46671c8onto this branch as99a2e5b009with your original Git author preserved, then inf7aadea3b0extractedwarm::shared_library_present(reusingplay::made_in_flatfor the unidentified-adapter legacy root fallback so zero-byte legacy files are rejected and pendinghost-pipelines.nextfiles at the legacy root are recognized, matchingpipeline/library.rs::load_cache) and added unit tests inplay.rs(made_in_for_matches_exact_non_empty_library_files_for_selected_adapter) andwarm.rs(shared_library_present_follows_selected_adapter_and_legacy_root) covering installed/pending adapter libraries, legacy root fallback, backup files, zero-byte files, directories, and other adapters.Verified on
f7aadea3b0withcargo test -j 4 --locked -p victory(99 unit + 1cache_paths+ 2censuspassed, 0 failed),cargo clippy -j 4 --locked -p victory --all-targets -- -D warningsand--all-features(0 warnings), andcargo xtask policy(464 files ok;--staged2 files ok).@trustno1-coder on GitHub · 2026-12-01 18:40 UTC · original
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