victory-gpu: keep a pipeline library per translation, not one shared one (a translator edit destroyed a 926 MB / 7.5 min cache) #2706

Open
github-bot wants to merge 2 commits from github-bot/gh-2706 into main AGit
Owner

@⁠pes7 on GitHub · 2026-11-25 18:32 UTC · original
pes7:perf/library-per-translation → main · +102 −2 · 1 files · 2 commits · open

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:

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 - 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.

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, the
shader 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 check green, rebased onto today's main (f3578e3).

Risk: none for a normal run: same directory argument, one level down; a stale cache is left alone instead of overwritten.

**@⁠pes7** on GitHub · 2026-11-25 18:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/2706) `pes7:perf/library-per-translation` → `main` · +102 −2 · 1 files · 2 commits · open 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: 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 - 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. 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, the shader 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 `check` green, rebased onto today's `main` (`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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:12:27 +00:00
Author
Owner

@⁠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.

**@⁠kotekompotek** on GitHub · 2026-11-25 18:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/2706#issuecomment-7171572886) 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.
Author
Owner

@⁠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 head f337d94, Windows 11, rustc 1.98.1.

Test pruning_leaves_folders_that_are_not_translation_caches (in crates/victory-gpu/src/pipeline/library.rs): in a temp dir it makes backup/ (older) with a sentinel file, then a newer previous cache 00000000deadbeef/ with a library file, and calls keyed(). It checks that the sentinel and the previous cache both still exist.

  • On the PR head (f337d94): FAILED, "an unrelated folder was deleted".
  • With the patch: passes. All 10 tests in pipeline::library pass (cargo test -p victory-gpu --lib --locked pipeline::library), and cargo clippy -p victory-gpu --all-targets --locked -- -D warnings is 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, then remove_dir (which fails if the folder is not empty). A second test checks the oldest real translation is still pruned.

Diff
diff --git a/crates/victory-gpu/src/pipeline/library.rs b/crates/victory-gpu/src/pipeline/library.rs
index fd3add4..eabc1ec 100644
--- a/crates/victory-gpu/src/pipeline/library.rs
+++ b/crates/victory-gpu/src/pipeline/library.rs
@@ -68,7 +68,7 @@ fn keyed(dir: &Path) -> PathBuf {
     let mut others: Vec<(std::time::SystemTime, PathBuf)> = entries
         .flatten()
         .map(|entry| entry.path())
-        .filter(|other| *other != path && other.is_dir())
+        .filter(|other| *other != path && other.is_dir() && is_translation_dir(other))
         .filter_map(|other| {
             let at = other.metadata().ok()?.modified().ok()?;
             Some((at, other))
@@ -77,12 +77,25 @@ fn keyed(dir: &Path) -> PathBuf {
     others.sort_by_key(|(at, _)| std::cmp::Reverse(*at));
     for (_, older) in others.into_iter().skip(KEPT - 1) {
         // A library and a list or two: gone with the translation that made
-        // them. Nothing this run reads is ever one of them.
-        let _ = std::fs::remove_dir_all(&older);
+        // them. Nothing this run reads is ever one of them. Only the files
+        // this module writes go; a folder holding anything else stays.
+        for file in [LIBRARY_FILE, EARLY_FILE, PREBUILT_FILE] {
+            let _ = std::fs::remove_file(older.join(file));
+        }
+        let _ = std::fs::remove_dir(&older);
     }
     path
 }
 
+/// Whether `dir` is named like a `SOURCE_HASH` (16 lowercase hex digits).
+fn is_translation_dir(dir: &Path) -> bool {
+    dir.file_name().and_then(|n| n.to_str()).is_some_and(|n| {
+        n.len() == victory_shader::SOURCE_HASH.len()
+            && n.bytes()
+                .all(|b| b.is_ascii_digit() || (b'a'..=b'f').contains(&b))
+    })
+}
+
 /// Host pipelines created, loaded from the library, and title pipelines
 /// started at creation, since the start.
 pub(crate) static MADE: AtomicU64 = AtomicU64::new(0);
@@ -496,6 +509,44 @@ mod tests {
         assert_ne!(a, name("graphics", b"root", &[b"vsp", b"s"], "state"));
     }
 
+    /// Pruning touches only translation caches: a folder of another name
+    /// stays, whatever its age, and the previous translation is kept.
+    #[test]
+    fn pruning_leaves_folders_that_are_not_translation_caches() {
+        let dir = tempfile::tempdir().unwrap();
+        let backup = dir.path().join("backup");
+        std::fs::create_dir(&backup).unwrap();
+        std::fs::write(backup.join("sentinel.txt"), b"keep").unwrap();
+        std::thread::sleep(std::time::Duration::from_millis(50));
+        let previous = dir.path().join("00000000deadbeef");
+        std::fs::create_dir(&previous).unwrap();
+        std::fs::write(previous.join(LIBRARY_FILE), b"old").unwrap();
+
+        let path = keyed(dir.path());
+
+        assert_eq!(path, dir.path().join(victory_shader::SOURCE_HASH));
+        assert!(backup.join("sentinel.txt").exists(), "an unrelated folder was deleted");
+        assert!(previous.join(LIBRARY_FILE).exists(), "the previous translation is kept");
+    }
+
+    /// The oldest translation beyond `KEPT` still goes, with its files.
+    #[test]
+    fn pruning_still_removes_the_oldest_translation() {
+        let dir = tempfile::tempdir().unwrap();
+        let oldest = dir.path().join("00000000000000aa");
+        std::fs::create_dir(&oldest).unwrap();
+        std::fs::write(oldest.join(LIBRARY_FILE), b"old").unwrap();
+        std::thread::sleep(std::time::Duration::from_millis(50));
+        let previous = dir.path().join("00000000000000bb");
+        std::fs::create_dir(&previous).unwrap();
+        std::fs::write(previous.join(LIBRARY_FILE), b"prev").unwrap();
+
+        keyed(dir.path());
+
+        assert!(!oldest.exists());
+        assert!(previous.join(LIBRARY_FILE).exists());
+    }
+
     /// This run's keys stay in the list; earlier runs' fill it up to the cap.
     #[test]
     fn the_early_list_keeps_this_run_first() {

Written with AI help (Claude/Kiro); the numbers are from runs on my machine.

**@⁠welisonzika14-jpg** on GitHub · 2026-11-25 19:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/2706#issuecomment-7172111231) For @⁠DrDarkDK's point about `keyed()`: here is a regression test for it and a small patch, in case @⁠pes7 wants them. Tested on head `f337d94`, Windows 11, rustc 1.98.1. **Test** `pruning_leaves_folders_that_are_not_translation_caches` (in `crates/victory-gpu/src/pipeline/library.rs`): in a temp dir it makes `backup/` (older) with a sentinel file, then a newer previous cache `00000000deadbeef/` with a library file, and calls `keyed()`. It checks that the sentinel and the previous cache both still exist. - On the PR head (f337d94): FAILED, "an unrelated folder was deleted". - With the patch: passes. All 10 tests in `pipeline::library` pass (`cargo test -p victory-gpu --lib --locked pipeline::library`), and `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` is 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, then `remove_dir` (which fails if the folder is not empty). A second test checks the oldest real translation is still pruned. <details><summary>Diff</summary> ```diff diff --git a/crates/victory-gpu/src/pipeline/library.rs b/crates/victory-gpu/src/pipeline/library.rs index fd3add4..eabc1ec 100644 --- a/crates/victory-gpu/src/pipeline/library.rs +++ b/crates/victory-gpu/src/pipeline/library.rs @@ -68,7 +68,7 @@ fn keyed(dir: &Path) -> PathBuf { let mut others: Vec<(std::time::SystemTime, PathBuf)> = entries .flatten() .map(|entry| entry.path()) - .filter(|other| *other != path && other.is_dir()) + .filter(|other| *other != path && other.is_dir() && is_translation_dir(other)) .filter_map(|other| { let at = other.metadata().ok()?.modified().ok()?; Some((at, other)) @@ -77,12 +77,25 @@ fn keyed(dir: &Path) -> PathBuf { others.sort_by_key(|(at, _)| std::cmp::Reverse(*at)); for (_, older) in others.into_iter().skip(KEPT - 1) { // A library and a list or two: gone with the translation that made - // them. Nothing this run reads is ever one of them. - let _ = std::fs::remove_dir_all(&older); + // them. Nothing this run reads is ever one of them. Only the files + // this module writes go; a folder holding anything else stays. + for file in [LIBRARY_FILE, EARLY_FILE, PREBUILT_FILE] { + let _ = std::fs::remove_file(older.join(file)); + } + let _ = std::fs::remove_dir(&older); } path } +/// Whether `dir` is named like a `SOURCE_HASH` (16 lowercase hex digits). +fn is_translation_dir(dir: &Path) -> bool { + dir.file_name().and_then(|n| n.to_str()).is_some_and(|n| { + n.len() == victory_shader::SOURCE_HASH.len() + && n.bytes() + .all(|b| b.is_ascii_digit() || (b'a'..=b'f').contains(&b)) + }) +} + /// Host pipelines created, loaded from the library, and title pipelines /// started at creation, since the start. pub(crate) static MADE: AtomicU64 = AtomicU64::new(0); @@ -496,6 +509,44 @@ mod tests { assert_ne!(a, name("graphics", b"root", &[b"vsp", b"s"], "state")); } + /// Pruning touches only translation caches: a folder of another name + /// stays, whatever its age, and the previous translation is kept. + #[test] + fn pruning_leaves_folders_that_are_not_translation_caches() { + let dir = tempfile::tempdir().unwrap(); + let backup = dir.path().join("backup"); + std::fs::create_dir(&backup).unwrap(); + std::fs::write(backup.join("sentinel.txt"), b"keep").unwrap(); + std::thread::sleep(std::time::Duration::from_millis(50)); + let previous = dir.path().join("00000000deadbeef"); + std::fs::create_dir(&previous).unwrap(); + std::fs::write(previous.join(LIBRARY_FILE), b"old").unwrap(); + + let path = keyed(dir.path()); + + assert_eq!(path, dir.path().join(victory_shader::SOURCE_HASH)); + assert!(backup.join("sentinel.txt").exists(), "an unrelated folder was deleted"); + assert!(previous.join(LIBRARY_FILE).exists(), "the previous translation is kept"); + } + + /// The oldest translation beyond `KEPT` still goes, with its files. + #[test] + fn pruning_still_removes_the_oldest_translation() { + let dir = tempfile::tempdir().unwrap(); + let oldest = dir.path().join("00000000000000aa"); + std::fs::create_dir(&oldest).unwrap(); + std::fs::write(oldest.join(LIBRARY_FILE), b"old").unwrap(); + std::thread::sleep(std::time::Duration::from_millis(50)); + let previous = dir.path().join("00000000000000bb"); + std::fs::create_dir(&previous).unwrap(); + std::fs::write(previous.join(LIBRARY_FILE), b"prev").unwrap(); + + keyed(dir.path()); + + assert!(!oldest.exists()); + assert!(previous.join(LIBRARY_FILE).exists()); + } + /// This run's keys stay in the list; earlier runs' fill it up to the cap. #[test] fn the_early_list_keeps_this_run_first() { ``` </details> Written with AI help (Claude/Kiro); the numbers are from runs on my machine.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 19:33 UTC · original

Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and code review of f337d94 (on 13f91ca):

Verification (rustc 1.98.1 MSVC)

  • cargo xtask policy: 184 files ok.
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings: 0 warnings.
  • RTX 5090: cargo test --locked -p victory-gpu --lib pipeline::library::tests: 8 passed, 0 failed.
  • WARP (VICTORY_D3D12_WARP=1): cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1: 198 passed, 0 failed, 1 ignored.

Review Notes

  • Keying pipeline library subdirectories by victory_shader::SOURCE_HASH with KEPT = 2 cleanly prevents a translator edit from overwriting a warm cache, while preserving atomic .tmp -> rename writes and corrupt-library recovery.
  • Minor non-blocking edge cases worth keeping in mind:
    • library.rs:71 prunes any non-current directory (*other != path && other.is_dir()) without validating that the directory name is a 16-hex-char SOURCE_HASH, so unrelated subdirectories placed under pipelines/ could be deleted.
    • Because save() returns early when added == 0 && !prebuilt_changed && !USED_CHANGED, directory mtime does not refresh on warm cache hits (so an A -> B -> A (all hits) -> C sequence can prune A instead of B).
**@⁠fuzeofficlal** on GitHub · 2026-11-25 19:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/2706#issuecomment-7172451897) Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and code review of `f337d94` (on `13f91ca`): ### Verification (`rustc 1.98.1` MSVC) - `cargo xtask policy`: **184 files ok**. - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings`: **0 warnings**. - **RTX 5090:** `cargo test --locked -p victory-gpu --lib pipeline::library::tests`: **8 passed, 0 failed**. - **WARP (`VICTORY_D3D12_WARP=1`):** `cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1`: **198 passed, 0 failed, 1 ignored**. ### Review Notes - Keying pipeline library subdirectories by `victory_shader::SOURCE_HASH` with `KEPT = 2` cleanly prevents a translator edit from overwriting a warm cache, while preserving atomic `.tmp -> rename` writes and corrupt-library recovery. - Minor non-blocking edge cases worth keeping in mind: - `library.rs:71` prunes any non-current directory (`*other != path && other.is_dir()`) without validating that the directory name is a 16-hex-char `SOURCE_HASH`, so unrelated subdirectories placed under `pipelines/` could be deleted. - Because `save()` returns early when `added == 0 && !prebuilt_changed && !USED_CHANGED`, directory `mtime` does not refresh on warm cache hits (so an `A -> B -> A (all hits) -> C` sequence can prune `A` instead of `B`).
Author
Owner

@⁠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 (a SOURCE_HASH) and holding host-pipelines.bin. A pipelines/backup/ - or any other directory, however old - is never touched, so remove_dir_all can 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_all for 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_alone builds a cache directory with an old translation directory, an older backup/ with a sentinel, and the current translation, then asserts the sentinel is still there after keyed(). (cargo test -p victory-gpu --locked library: 9 passed.)

**@⁠pes7** on GitHub · 2026-11-25 19:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/2706#issuecomment-7172477778) Right, and fixed in f34d0b5 - thank you. `keyed()` now prunes only directories this crate wrote: a name that is 16 lowercase hex digits (a `SOURCE_HASH`) **and** holding `host-pipelines.bin`. A `pipelines/backup/` - or any other directory, however old - is never touched, so `remove_dir_all` can 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_all` for 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_alone` builds a cache directory with an old translation directory, an older `backup/` with a sentinel, and the current translation, then asserts the sentinel is still there after `keyed()`. (`cargo test -p victory-gpu --locked library`: 9 passed.)
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 19:41 UTC · original

Independent WARP/CPU verification

Head: 8981a0cf9955405e03a5bdb25eeaa727f023c20f
Base: origin/main 13f91caee25f2fdf2c062be5f7a27f058e51cbca
Status: open, non-draft; clean merge tree; no oni-swr comment on this head.

Environment: Windows x64, WARP selected (VICTORY_WARP=1, VICTORY_D3D12_WARP=1), dxil.dll 1.8.2502.11 from Windows SDK 10.0.26100.0; rustc 1.98.1.

Commands (each with CARGO_TARGET_DIR=D:\victory-warp-2690-target and the WARP variables above):

  • Baseline and PR: cargo test --locked -p victory-gpu
  • Baseline and PR diagnostics: cargo test --locked -p victory-gpu --features diagnostics
  • PR targeted: cargo test --locked -p victory-gpu pruning_leaves_foreign_directories_alone
  • PR lint: cargo clippy --locked -p victory-gpu --all-targets -- -D warnings

Results: 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_translation filter and reran the new targeted test; it still passed (1/1). The test creates backup after 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 so backup would be pruned without the filter. No production failure found.

Not tested: physical GPU, retail title, release build. AI-assisted: Codex (gpt-6-luna).

**@⁠oni-swr** on GitHub · 2026-11-25 19:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/2706#issuecomment-7172633328) Independent WARP/CPU verification Head: `8981a0cf9955405e03a5bdb25eeaa727f023c20f` Base: `origin/main` `13f91caee25f2fdf2c062be5f7a27f058e51cbca` Status: open, non-draft; clean merge tree; no `oni-swr` comment on this head. Environment: Windows x64, WARP selected (`VICTORY_WARP=1`, `VICTORY_D3D12_WARP=1`), `dxil.dll` 1.8.2502.11 from Windows SDK 10.0.26100.0; rustc 1.98.1. Commands (each with `CARGO_TARGET_DIR=D:\victory-warp-2690-target` and the WARP variables above): - Baseline and PR: `cargo test --locked -p victory-gpu` - Baseline and PR diagnostics: `cargo test --locked -p victory-gpu --features diagnostics` - PR targeted: `cargo test --locked -p victory-gpu pruning_leaves_foreign_directories_alone` - PR lint: `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` Results: 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_translation` filter and reran the new targeted test; it still passed (1/1). The test creates `backup` after 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 so `backup` would be pruned without the filter. No production failure found. Not tested: physical GPU, retail title, release build. AI-assisted: Codex (gpt-6-luna).
Author
Owner

@⁠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_cache in crates/victory-gpu/src/pipeline/library.rs now points the library at dir/<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-hex SOURCE_HASH and hold host-pipelines.bin. I checked against main: save() already does create_dir_all(dir), all readers go through DIR, and the only caller (d3d12x.rs) is unchanged. It merges cleanly and CI check is passing.

Minor, not blocking: pruning_leaves_foreign_directories_alone creates backup/ after the old translation directory, so it would also pass without the is_translation filter (as noted in the thread); giving backup/ the oldest mtime would make the test pin the filter. A library left at the old top-level pipelines/host-pipelines.bin is simply no longer read (one warm-up after upgrading).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 22:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/2706#issuecomment-7176143893) · edited 2026-11-26 02:15 UTC <!-- victory-triage v1 head=da38ab49ce06fa556605e2dd183eb448ae49cc9c verdict=merge-candidate at=2026-11-26T02:15:30Z --> Automated triage for the maintainers. **Merge candidate** (recommending a look, not an approval). Thanks for the rebase. `use_pipeline_cache` in `crates/victory-gpu/src/pipeline/library.rs` now points the library at `dir/<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-hex `SOURCE_HASH` and hold `host-pipelines.bin`. I checked against `main`: `save()` already does `create_dir_all(dir)`, all readers go through `DIR`, and the only caller (`d3d12x.rs`) is unchanged. It merges cleanly and CI `check` is passing. Minor, not blocking: `pruning_leaves_foreign_directories_alone` creates `backup/` after the old translation directory, so it would also pass without the `is_translation` filter (as noted in the thread); giving `backup/` the oldest mtime would make the test pin the filter. A library left at the old top-level `pipelines/host-pipelines.bin` is simply no longer read (one warm-up after upgrading). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠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. main gained, meanwhile, tag() (the translator hash holds for the pre-built list) and write_atomically, so the branch is now just the directory part, applied on top of both:

  • use_pipeline_cache sets the library directory to dir/<SOURCE_HASH>,
  • keyed() keeps the two newest translation directories (KEPT) and prunes the rest,
  • pruning takes a directory only when its name is 16 lowercase hex digits and it holds host-pipelines.bin, so a backup/ in the cache directory is not ours to delete (with the test that pins that down),
  • the crates' other library tests and write_atomically are untouched.

Checked: cargo test --release -p victory-gpu 229 pass, clippy clean, both victory configurations build.

The measurements in the original description still stand (926 MB -> 612 KB after a translator edit; pipelines/94ef170ae2f5e8da/host-pipelines.bin, loaded bytes=7488 ms=0 on the next run).

**@⁠pes7** on GitHub · 2026-11-25 22:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/2706#issuecomment-7176379089) Rebased onto today's `main` (`f3578e3`) and reduced to the part that is still missing there. `main` gained, meanwhile, `tag()` (the translator hash holds for the pre-built list) and `write_atomically`, so the branch is now just the directory part, applied on top of both: - `use_pipeline_cache` sets the library directory to `dir/<SOURCE_HASH>`, - `keyed()` keeps the two newest translation directories (`KEPT`) and prunes the rest, - pruning takes a directory only when its name is 16 lowercase hex digits **and** it holds `host-pipelines.bin`, so a `backup/` in the cache directory is not ours to delete (with the test that pins that down), - the crates' other library tests and `write_atomically` are untouched. Checked: `cargo test --release -p victory-gpu` 229 pass, clippy clean, both `victory` configurations build. The measurements in the original description still stand (926 MB -> 612 KB after a translator edit; `pipelines/94ef170ae2f5e8da/host-pipelines.bin`, loaded `bytes=7488 ms=0` on the next run).
`is_translation` decided whether a directory in the cache is one this crate
wrote by looking for `host-pipelines.bin`. #1653 splits that library into
`host-pipelines.NN.bin` shards and drops the single file, so the two changes
read each other's directories as foreign: pruned ones would never be pruned,
and with #1653 first this file does not even compile (`LIBRARY_FILE` is gone).

`library_in(dir)` accepts either, and the pruning test writes the file by its
name, so this lands the same way before or after the split - checked by
merging the two branches and running `cargo test -p victory-gpu pipeline::`
(24 passed, both the shard tests and the pruning test among them).
Author
Owner

@⁠pes7 on GitHub · 2026-11-26 15:06 UTC · original

Where this PR meets #1653 (perf/pipeline-library-shards), which also rewrites pipeline/library.rs. Both were MERGEABLE/green on their own, and git merged them without a textual conflict — but the result did not compile, because is_translation looked for host-pipelines.bin, which the split removes (LIBRARY_FILE is 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.

fn library_in(dir: &Path) -> bool {
    dir.join(LIBRARY_FILE).is_file() || dir.join("host-pipelines.00.bin").is_file()
}

The names are written out rather than taken from shard_file so this branch compiles on main today, where the split does not exist yet; the pruning test writes the file by name for the same reason.

Verified both ways:

tree result
this branch alone (on main) builds; pipeline::library 9 passed, clippy -D warnings clean
this branch merged into #1653 builds after a 6-line resolution (shard_file(0) instead of the literal, since the split owns the name); pipeline:: 24 passed, both the shard tests and pruning_leaves_foreign_directories_alone among them

The 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).

**@⁠pes7** on GitHub · 2026-11-26 15:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/2706#issuecomment-7195788172) Where this PR meets #1653 (`perf/pipeline-library-shards`), which also rewrites `pipeline/library.rs`. Both were `MERGEABLE`/green on their own, and git merged them **without a textual conflict** — but the result did not compile, because `is_translation` looked for `host-pipelines.bin`, which the split removes (`LIBRARY_FILE` is 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. ```rust fn library_in(dir: &Path) -> bool { dir.join(LIBRARY_FILE).is_file() || dir.join("host-pipelines.00.bin").is_file() } ``` The names are written out rather than taken from `shard_file` so this branch compiles on `main` today, where the split does not exist yet; the pruning test writes the file by name for the same reason. **Verified both ways:** | tree | result | |---|---| | this branch alone (on `main`) | builds; `pipeline::library` 9 passed, clippy `-D warnings` clean | | this branch merged into #1653 | builds after a 6-line resolution (`shard_file(0)` instead of the literal, since the split owns the name); `pipeline::` **24 passed**, both the shard tests and `pruning_leaves_foreign_directories_alone` among them | The 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).
Author
Owner

@⁠DrDarkDK on GitHub · 2026-11-25 18:37 UTC · original · requested changes

keyed() can recursively delete an unrelated directory on startup. For example, if pipelines/backup/ is older than the previous translation’s cache directory, it enters others and gets passed to remove_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 18:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/2706#pullrequestreview-6062997670) · **requested changes** `keyed()` can recursively delete an unrelated directory on startup. For example, if `pipelines/backup/` is older than the previous translation’s cache directory, it enters `others` and gets passed to `remove_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.*
Author
Owner

@⁠DrDarkDK on GitHub · 2026-11-25 19:26 UTC · original · approved these changes

**@⁠DrDarkDK** on GitHub · 2026-11-25 19:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/2706#pullrequestreview-6063696124) · **approved these changes**
Author
Owner

@⁠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 contain host-pipelines.15.bin and 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 e60d4cbb3 for 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 own SHARDS and shard_file. All 28 pipeline tests passed, including the existing pruning test, plus strict GPU Clippy and policy. Optional commit on the combined branch

Please retain Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if you fold it in. AI-assisted with Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 15:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/2706#issuecomment-7196813929) @⁠pes7 I found one retention case on the published combination `e60d4cbb3`. #1653 writes the shards with changes, so a small cache can contain `host-pipelines.15.bin` and 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 `e60d4cbb3` for 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 own `SHARDS` and `shard_file`. All 28 pipeline tests passed, including the existing pruning test, plus strict GPU Clippy and policy. [Optional commit on the combined branch](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/3529af0cca91582e6a999b0b48a93a5d143bc3ae) Please retain `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if you fold it in. AI-assisted with Codex.
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 20:17 UTC · original · approved these changes

LGTM — verified on Windows against origin/main (63bcca4).

  • Keying pipeline libraries per translator version and pruning old keyed directories (while leaving foreign directories untouched) prevents translator edits from wiping out a warm pipeline cache.
  • cargo test -p victory-gpu --lib pipeline::library:: -- --test-threads=1: 12 passed, 0 failed (including keyed_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).

**@⁠Dukestar69** on GitHub · 2026-11-26 20:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/2706#pullrequestreview-6080050273) · **approved these changes** LGTM — verified on Windows against `origin/main` (`63bcca4`). - Keying pipeline libraries per translator version and pruning old keyed directories (while leaving foreign directories untouched) prevents translator edits from wiping out a warm pipeline cache. - `cargo test -p victory-gpu --lib pipeline::library:: -- --test-threads=1`: 12 passed, 0 failed (including `keyed_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).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2706/head:github-bot/gh-2706'
git switch 'github-bot/gh-2706'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2706'
git switch 'github-bot/gh-2706'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2706'
git switch 'github-bot/gh-2706'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2706'
git switch 'main'
git merge --squash 'github-bot/gh-2706'
git switch 'main'
git merge --ff-only 'github-bot/gh-2706'
git switch 'main'
git merge 'github-bot/gh-2706'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2706
No description provided.