victory-gpu: keep a pipeline library per translation, not one shared one (a translator edit destroyed a 926 MB / 7.5 min cache) #2704
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from Marvisak/VIctory. Originally posted by pes7 on 2026-11-25T18:32:54Z.
victory-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.
Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T18:37:01Z.
Review: CHANGES_REQUESTED
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.
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T18:54:51Z.
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.
Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T19:26:40Z.
Review: APPROVED
No description provided.
Imported from Marvisak/VIctory. Originally posted by welisonzika14-jpg on 2026-11-25T19:18:15Z.
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.f337d94): FAILED, "an unrelated folder was deleted".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.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T19:33:03Z.
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).Imported from Marvisak/VIctory. Originally posted by pes7 on 2026-11-25T19:34:11Z.
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.)Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T19:41:12Z.
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).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:15:55Z.
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
Imported from Marvisak/VIctory. Originally posted by pes7 on 2026-11-25T22:27:09Z.
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).Imported from Marvisak/VIctory. Originally posted by pes7 on 2026-11-26T15:06:20Z.
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).
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T15:50:05Z.
@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.Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T20:17:58Z.
Review: APPROVED
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).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T00:05:55Z.
Review: APPROVED
LGTM — clean scoping and great motivation. Isolating each
victory_shader::SOURCE_HASHintodir/<SOURCE_HASH>while restricting pruning strictly to 16-char lowercase hex directories containinghost-pipelines.binorhost-pipelines.00.binavoids clobbering warm caches across translator edits/bisects and leaves foreign directories untouched.Verified locally with
cargo xtask policy,cargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default and--all-features), andcargo test --locked -p victory-gpu --lib pipeline::library::(12/12 passed both with and without--features diagnostics).A few small non-blocking suggestions if you update the PR:
library.rs:907-941):pruning_leaves_foreign_directories_alonecurrently seeds only one eligible non-current translation directory ("00112233aabbccdd"), soothers.into_iter().skip(KEPT - 1)yields zero items and never exercisesremove_dir_all. Seeding a second/third translation directory (with distinct mtimes, plus ahost-pipelines.00.binshard fixture) would verify both pruning order and shard detection directly.rustfmt --edition 2024 --checkflags line 935 (wrap) and line 942 (extra trailing blank line) inkeyed_tests.skip(KEPT - 1)could remove an active older build's directory by mtime (fine for the typical single-run / 2-build bisect workflow).Imported from Marvisak/VIctory. Originally posted by pes7 on 2026-11-27T12:47:57Z.
@andrewpozdnakov7-jpg thanks, you're right: #1653 writes only the shards that changed, so a directory holding only
host-pipelines.15.binwas not recognised and fell out of the two-version retention.Pushed
6be5b71(Co-authored-byyou):library_innow accepts the one-file library or any of the sixteen shard names (host-pipelines.00.bin..host-pipelines.15.bin). The names stay written out rather than usingSHARDS/shard_file, because those don't exist onmainwithout #1653, so this PR still builds and behaves the same whichever lands first. New testany_shard_makes_a_library_directorycovers the legacy file, shard 00, shard 15, shard 16 (rejected), an unrelated file and an empty directory.Local, Windows 11:
cargo clippy -p victory-gpu --all-targets -- -D warningsclean, also with--all-features;cargo test -p victory-gpu pipeline::23 passed / 0 failed;xtaskpolicy tests pass; merges cleanly ontomain63bcca4. No title run for this push (cache-directory classification only).Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T06:33:17Z.
I combined #2706 at
6be5b71with #3685 at35625d7in 31e52f1. Both original heads are retained. The combined branch includes current main through #3685, and its diff from that head is confined to the pipeline library.The lookup still chooses this translator's directory first. It hashes the accepted library only if that directory supplies a prebuilt list. The six synthetic cases produced the same prebuilt keys as before, and a warm library with no list performed zero hashes. Both translation-directory tests and three library tests passed on Windows, including the concurrent WARP loads. Strict GPU Clippy and the asset policy passed.
pes7 or a maintainer can use the tested combination if both PRs land.
Please retain the Git authors on cherry-pick or rebase, or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>if folding this resolution into another commit.AI-assisted with OpenAI Codex.
Imported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-29T08:07:25Z.
A measured report on the limit of two, from a tree that carries this PR's folders (RTX 5090, Linux/Wine 11.22, vkd3d-proton of GE-Proton11-14).
The folder per translation works as described. The limit bit as soon as three or more builds took turns on one cache folder: a candidate,
mainand a branch in one A-B-A-B window, with a second tester's builds in between.host pipeline library saved bytes=248..632 early=0; at the endhost pipelines all made made≈1,900 loaded≈170 started_early=0). 15 of the 20 were builds that had already run that night; 3 were true first runs, 2 I can't tell.What I do on that box now: copy each
<SOURCE_HASH>folder aside after a run and put it back before that build's next run, and count a run only whenmadeis far belowloaded.A suggestion, yours to weigh: the two newest fit a bisection between two builds, but not a merge candidate tested against
mainand its parts, nor two testers on one machine. Folders of game runs are small (320-460 KB here; your 926 MB is the pre-built one), so pruning by total size, or a count one can raise, would keep both cases. I have not written that; if a patch on your branch helps, say so.AI-assisted (Claude); measured on my machine, no game data shared.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.