victory-gpu: keep a pipeline library per translation, not one shared one (a translator edit destroyed a 926 MB / 7.5 min cache) #2706
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2706
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2706"
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?
@pes7 on GitHub · 2026-11-25 18:32 UTC · original
pes7:perf/library-per-translation→main· +102 −2 · 1 files · 2 commits · openvictory-gpu: keep a pipeline library per translation, not one shared one
The library's pipelines are named after the shaders they are made from, so a
change to the translator (victory_shader::SOURCE_HASH) makes every name in
it useless - and the first run after one wrote the few pipelines it made
over the old library. Measured on the title:
That 926 MB was a 7.5 minute warm-up (
translate --cache --pipelines,made=23057 on a cold library). It is not a truncated write -
write_atomicallyis already there - the new library is simply small and replaces the old one.
The cost lands on the loop that needs the cache most: bisecting between two
builds paid the warm-up for each of them, in turn, every time.
So each translation keeps its library in
dir/<SOURCE_HASH>, and the twonewest are kept (
KEPT): the one in use and the previous build's, which iswhat a bisection needs. A run only ever writes its own directory.
Measured (retail title, two runs in a row,
O:\tmp\victory-cache\pipelines):Nothing else moves:
use_pipeline_cachestill takes the same directory, theshader cache's key already worked this way, and the pipeline library of a
build that is not the current one is now left alone instead of being
overwritten.
cargo test --workspace --locked; both clippy configurations with -D
warnings; cargo xtask policy.
What it gives (to decide the merge): a translator edit no longer destroys the pipeline library: measured, a 926 MB cache (27 160 pipelines, a 7.5 minute warm-up) became 612 KB on the next start, and bisecting between two builds paid that warm-up for each of them in turn. Each translation keeps its own directory now, the two newest are kept, and pruning only takes this crate's own directories.
State: MERGEABLE, CI
checkgreen, rebased onto today'smain(f3578e3).Risk: none for a normal run: same directory argument, one level down; a stale cache is left alone instead of overwritten.
The library's pipelines are named after the shaders they are made from, so a change to the translator (`victory_shader::SOURCE_HASH`) makes every name in it useless - and the first run after one wrote the few pipelines it made over the old library. Measured on the title: warm: host pipeline library loaded bytes=970507898 ms=57 (926 MB, 27 160 pipelines) after a translator change, the next start-up says: host pipeline library loaded bytes=626800 (612 KB) That 926 MB was a 7.5 minute warm-up (`translate --cache --pipelines`, made=23057 on a cold library). It is not a truncated write - `write_atomically` is already there, and so is the translator hash in the pre build's list - the new library is simply small and replaces the old one. The cost lands on the loop that needs the cache most: bisecting between two builds paid the warm-up for each of them, in turn, every time. So each translation keeps its library in `dir/<SOURCE_HASH>`, and the two newest are kept (`KEPT`): the one in use and the previous build's, which is what a bisection needs. A run only ever writes its own directory, and pruning takes a directory only when its name is 16 lowercase hex digits and it holds `host-pipelines.bin`, so a `backup/` someone keeps in the cache directory is left alone (there is a test with a sentinel file in one). Measured (retail title, two runs in a row, `O:\tmp\victory-cache\pipelines`): run 1: host pipeline library saved bytes=3086 (no load: first use of this key) host pipeline library saved bytes=7488 run 2: host pipeline library loaded bytes=7488 ms=0 -> O:\tmp\victory-cache\pipelines\94ef170ae2f5e8da\host-pipelines.bin Nothing else moves: `use_pipeline_cache` still takes the same directory, and the pipeline library of a build that is not the current one is now left alone instead of being overwritten. Rebased onto today's `main`: the file gained `tag()` (which holds the translator hash for the pre build's list) and `write_atomically`, so this is the directory part only, applied to those. cargo test --release -p victory-gpu (229 tests); clippy clean; both `victory` configurations build.@kotekompotek on GitHub · 2026-11-25 18:54 UTC · original
Right fix for a real data-loss path: pipeline names embed SOURCE_HASH-derived shader hashes, so a translator edit orphans the whole library - writing a tiny new one over it was the worst possible outcome for bisection. Keying by SOURCE_HASH and keeping the two newest is exactly what alternating-build workflows need, and write_atomically already covers the intra-build case.
One nit worth a second look: keyed() prunes every directory in the cache dir that is not the current hash, not just ones shaped like translations. If the dir is fully dedicated this is fine, but a stray subdirectory a user or another tool left there gets deleted on the next run. Filtering candidates by name shape would be cheap insurance.
@welisonzika14-jpg on GitHub · 2026-11-25 19:18 UTC · original
For @DrDarkDK's point about
keyed(): here is a regression test for it and a small patch, in case @pes7 wants them. Tested on headf337d94, Windows 11, rustc 1.98.1.Test
pruning_leaves_folders_that_are_not_translation_caches(incrates/victory-gpu/src/pipeline/library.rs): in a temp dir it makesbackup/(older) with a sentinel file, then a newer previous cache00000000deadbeef/with a library file, and callskeyed(). It checks that the sentinel and the previous cache both still exist.pipeline::librarypass (cargo test -p victory-gpu --lib --locked pipeline::library), andcargo clippy -p victory-gpu --all-targets --locked -- -D warningsis clean.Patch: only folders named like
SOURCE_HASH(16 lowercase hex digits) are pruning candidates. For those, only the three files this module writes are removed, thenremove_dir(which fails if the folder is not empty). A second test checks the oldest real translation is still pruned.Diff
Written with AI help (Claude/Kiro); the numbers are from runs on my machine.
@fuzeofficlal on GitHub · 2026-11-25 19:33 UTC · original
Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and code review of
f337d94(on13f91ca):Verification (
rustc 1.98.1MSVC)cargo xtask policy: 184 files ok.cargo clippy --locked -p victory-gpu --all-targets -- -D warnings: 0 warnings.cargo test --locked -p victory-gpu --lib pipeline::library::tests: 8 passed, 0 failed.VICTORY_D3D12_WARP=1):cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1: 198 passed, 0 failed, 1 ignored.Review Notes
victory_shader::SOURCE_HASHwithKEPT = 2cleanly prevents a translator edit from overwriting a warm cache, while preserving atomic.tmp -> renamewrites and corrupt-library recovery.library.rs:71prunes any non-current directory (*other != path && other.is_dir()) without validating that the directory name is a 16-hex-charSOURCE_HASH, so unrelated subdirectories placed underpipelines/could be deleted.save()returns early whenadded == 0 && !prebuilt_changed && !USED_CHANGED, directorymtimedoes not refresh on warm cache hits (so anA -> B -> A (all hits) -> Csequence can pruneAinstead ofB).@pes7 on GitHub · 2026-11-25 19:34 UTC · original
Right, and fixed in f34d0b5 - thank you.
keyed()now prunes only directories this crate wrote: a name that is 16 lowercase hex digits (aSOURCE_HASH) and holdinghost-pipelines.bin. Apipelines/backup/- or any other directory, however old - is never touched, soremove_dir_allcan only ever see one of our own library directories.Your suggestion to remove only the cache files and then the empty directory is the narrower version of the same rule; I kept
remove_dir_allfor our own directories because the leftovers of a translation are exactly three files this crate wrote (host-pipelines.bin,early-pipelines.txt,prebuilt-pipelines.txt) and a partially written one has no value.The regression test you described is in:
pipeline::library::keyed_tests::pruning_leaves_foreign_directories_alonebuilds a cache directory with an old translation directory, an olderbackup/with a sentinel, and the current translation, then asserts the sentinel is still there afterkeyed(). (cargo test -p victory-gpu --locked library: 9 passed.)@oni-swr on GitHub · 2026-11-25 19:41 UTC · original
Independent WARP/CPU verification
Head:
8981a0cf9955405e03a5bdb25eeaa727f023c20fBase:
origin/main13f91caee25f2fdf2c062be5f7a27f058e51cbcaStatus: open, non-draft; clean merge tree; no
oni-swrcomment on this head.Environment: Windows x64, WARP selected (
VICTORY_WARP=1,VICTORY_D3D12_WARP=1),dxil.dll1.8.2502.11 from Windows SDK 10.0.26100.0; rustc 1.98.1.Commands (each with
CARGO_TARGET_DIR=D:\victory-warp-2690-targetand the WARP variables above):cargo test --locked -p victory-gpucargo test --locked -p victory-gpu --features diagnosticscargo test --locked -p victory-gpu pruning_leaves_foreign_directories_alonecargo clippy --locked -p victory-gpu --all-targets -- -D warningsResults: default baseline 195 passed, 1 ignored; current PR 196 passed, 1 ignored. Diagnostics baseline 197 passed, 1 failed, 1 ignored; current PR 199 passed, 1 ignored. The baseline-only failure was
memory::tests::a_submission_that_missed_leaves_the_copies_at_once; it passed in the PR run. Clippy passed.Negative control: removed the
is_translationfilter and reran the new targeted test; it still passed (1/1). The test createsbackupafter the valid old directory and does not set modification times, so the foreign directory may be retained merely as the newest one. This is a test-strength nit: set deterministic mtimes sobackupwould be pruned without the filter. No production failure found.Not tested: physical GPU, retail title, release build. AI-assisted: Codex (gpt-6-luna).
@Marvisak on GitHub · 2026-11-25 22:15 UTC · original · edited 2026-11-26 02:15 UTC
Automated triage for the maintainers.
Merge candidate (recommending a look, not an approval). Thanks for the rebase.
use_pipeline_cacheincrates/victory-gpu/src/pipeline/library.rsnow points the library atdir/<SOURCE_HASH>, so a translator change no longer overwrites the previous build's library;keyed()keeps the current and the newest other translation and only prunes directories that are named like a 16-hexSOURCE_HASHand holdhost-pipelines.bin. I checked againstmain:save()already doescreate_dir_all(dir), all readers go throughDIR, and the only caller (d3d12x.rs) is unchanged. It merges cleanly and CIcheckis passing.Minor, not blocking:
pruning_leaves_foreign_directories_alonecreatesbackup/after the old translation directory, so it would also pass without theis_translationfilter (as noted in the thread); givingbackup/the oldest mtime would make the test pin the filter. A library left at the old top-levelpipelines/host-pipelines.binis simply no longer read (one warm-up after upgrading).Generated by Claude Code
@pes7 on GitHub · 2026-11-25 22:27 UTC · original
Rebased onto today's
main(f3578e3) and reduced to the part that is still missing there.maingained, meanwhile,tag()(the translator hash holds for the pre-built list) andwrite_atomically, so the branch is now just the directory part, applied on top of both:use_pipeline_cachesets the library directory todir/<SOURCE_HASH>,keyed()keeps the two newest translation directories (KEPT) and prunes the rest,host-pipelines.bin, so abackup/in the cache directory is not ours to delete (with the test that pins that down),write_atomicallyare untouched.Checked:
cargo test --release -p victory-gpu229 pass, clippy clean, bothvictoryconfigurations build.The measurements in the original description still stand (926 MB -> 612 KB after a translator edit;
pipelines/94ef170ae2f5e8da/host-pipelines.bin, loadedbytes=7488 ms=0on the next run).@pes7 on GitHub · 2026-11-26 15:06 UTC · original
Where this PR meets #1653 (
perf/pipeline-library-shards), which also rewritespipeline/library.rs. Both wereMERGEABLE/green on their own, and git merged them without a textual conflict — but the result did not compile, becauseis_translationlooked forhost-pipelines.bin, which the split removes (LIBRARY_FILEis gone). Left as it was, that is a merge that looks clean and breaks the build.Fixed here (
b621621fd): a directory counts as a library when it holds the file or its first shard.The names are written out rather than taken from
shard_fileso this branch compiles onmaintoday, where the split does not exist yet; the pruning test writes the file by name for the same reason.Verified both ways:
main)pipeline::library9 passed, clippy-D warningscleanshard_file(0)instead of the literal, since the split owns the name);pipeline::24 passed, both the shard tests andpruning_leaves_foreign_directories_aloneamong themThe resolved combination is pushed as
perf/library-per-translation-on-shards(e60d4cbb3), so if #1653 lands first the update here is that one commit rather than a re-derivation.Either order works; the only requirement is that whoever merges second takes that resolution. No other open PR by us touches these files — the rest were checked pairwise against each other and merge clean (see #2936's comment).
@DrDarkDK on GitHub · 2026-11-25 18:37 UTC · original · requested changes
keyed()can recursively delete an unrelated directory on startup. For example, ifpipelines/backup/is older than the previous translation’s cache directory, it entersothersand gets passed toremove_dir_all. The filter currently accepts every directory except the current hash.Could pruning be limited to verified translation-cache entries and remove only the cache files VIctory owns, followed by an empty-directory removal? A temp-directory regression with a newer previous cache and an older
backup/containing a sentinel file would pin this down.AI-assisted with Codex.
@DrDarkDK on GitHub · 2026-11-25 19:26 UTC · original · approved these changes
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 15:50 UTC · original
@pes7 I found one retention case on the published combination
e60d4cbb3. #1653 writes the shards with changes, so a small cache can containhost-pipelines.15.binand no shard 00. The combination's classifier returns false for that directory, and the retention pass consequently leaves it out of the two-version policy.The same synthetic fixture fails on
e60d4cbb3for shard 15 and passes with the follow-up. It checks the legacy file, shard 00 and shard 15, plus a shard outside the valid range and an unrelated directory. Recognition now uses the combined tree's ownSHARDSandshard_file. All 28 pipeline tests passed, including the existing pruning test, plus strict GPU Clippy and policy. Optional commit on the combined branchPlease retain
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>if you fold it in. AI-assisted with Codex.@Dukestar69 on GitHub · 2026-11-26 20:17 UTC · original · approved these changes
LGTM — verified on Windows against
origin/main(63bcca4).cargo test -p victory-gpu --lib pipeline::library:: -- --test-threads=1: 12 passed, 0 failed (includingkeyed_tests::pruning_leaves_foreign_directories_alone).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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.