CLI/GPU: avoid rescanning game_dir and re-inflating/re-hashing cached containers during warm prebuild, and stop Named::find early #2785

Open
RVZO6 wants to merge 1 commit from upstream-pr/2787 into main
RVZO6 commented 2026-11-25 20:23:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by RVZO6 on 2026-11-25T20:23:11Z.


Claimed in #1633: https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7172903504

Summary

Speeds up warm victory translate --cache --pipelines and prebuild runs (e.g. the warm-cache overhead reported in #2602) with byte-for-byte identical pipeline keys and zero shader-cache invalidation (shader_cache.rs is intentionally untouched):

  1. Avoid rescanning game_dir a second time (apps/victory/src/translate.rs): translate::warm records the paths of files containing containers or the shader pack during its walk and passes only those paths to prebuild::run, avoiding a full second walk and read of the entire game directory.
  2. Zero-inflate, zero-rehash prebuilt key check (apps/victory/src/prebuild.rs, crates/victory-gpu/src/pipeline.rs, crates/victory-gpu/src/pipeline/make.rs):
    • prebuild::run computes and caches each container's 16-char BLAKE3 hex hash once during the initial programs scan.
    • Adds Prebuild::compute_key(hash) and Prebuild::graphics_key(stream, &[(stage, hash)]) (via make::key_from_hashes) so prebuild::run checks pipeline::prebuilt(&key) and wanted_early(&key) for all pack records without re-inflating, double-copying, or re-hashing every container ~55,000+ times before filtering to unbuilt todo jobs.
    • shaders_of reuses the cached hash too.
  3. Early-exit Named::find (crates/victory-game/src/pipelines.rs): skips and breaks out of the 2.49M-iteration depth_space and 478k-iteration raster_space enumerations via ControlFlow::Break as soon as want empties.

Measured on 13f91ca (--release pipeline::tests::bench_prebuild_key_vs_full, median of 3 runs, 4,000 jobs × 64 KiB containers, exact identical keys)

Path Time (4,000 jobs) Speedup
Full Prebuild::{graphics,compute}::key() (13f91ca) 123.37 ms baseline
Prebuild::{graphics_key,compute_key}() 35.20 ms 3.50× (-71.5%)

(In real SGD5 warm pre-build runs this additionally skips ~55,000+ miniz_oxide container inflations and the entire second game_dir disk scan.)

Not a duplicate of

  • Checked #2534 (shaderpack::find, intentionally left untouched), #2592 (rejects VS+GS), #2706 / #2646 (pipeline library file splitting), and #2211 (pipeline::shader() + Translated.atomics64). None overlaps these changes.

Verification

  • Verified on windows-latest MSVC + WARP SM 6.6 CI (both clippy -D warnings profiles, xtask policy 6/6, victory-game 16/16 including space_enumerations_stop_early_when_wanted_empties, victory-gpu 198/198 including prebuild_key_shortcuts_match_full_prebuild_keys): https://github.com/RVZO6/VIctory/actions/runs/45693633259
  • Not run: the title; any hardware GPU.

AI-assisted: T3 Code (Antigravity, gemini-4-neon)

<!-- greyfinch-sync:Marvisak/VIctory:issue:5498566799 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2787). Originally posted by [RVZO6](https://github.com/RVZO6) on 2026-11-25T20:23:11Z. --- Claimed in #1633: https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7172903504 ### Summary Speeds up warm `victory translate --cache --pipelines` and `prebuild` runs (e.g. the warm-cache overhead reported in #2602) with **byte-for-byte identical pipeline keys** and **zero shader-cache invalidation** (`shader_cache.rs` is intentionally untouched): 1. **Avoid rescanning `game_dir` a second time (`apps/victory/src/translate.rs`):** `translate::warm` records the paths of files containing containers or the shader pack during its walk and passes only those paths to `prebuild::run`, avoiding a full second walk and read of the entire game directory. 2. **Zero-inflate, zero-rehash prebuilt key check (`apps/victory/src/prebuild.rs`, `crates/victory-gpu/src/pipeline.rs`, `crates/victory-gpu/src/pipeline/make.rs`):** - `prebuild::run` computes and caches each container's 16-char BLAKE3 hex hash once during the initial `programs` scan. - Adds `Prebuild::compute_key(hash)` and `Prebuild::graphics_key(stream, &[(stage, hash)])` (via `make::key_from_hashes`) so `prebuild::run` checks `pipeline::prebuilt(&key)` and `wanted_early(&key)` for all pack records without re-inflating, double-copying, or re-hashing every container ~55,000+ times before filtering to unbuilt `todo` jobs. - `shaders_of` reuses the cached hash too. 3. **Early-exit `Named::find` (`crates/victory-game/src/pipelines.rs`):** skips and breaks out of the 2.49M-iteration `depth_space` and 478k-iteration `raster_space` enumerations via `ControlFlow::Break` as soon as `want` empties. ### Measured on `13f91ca` (`--release pipeline::tests::bench_prebuild_key_vs_full`, median of 3 runs, 4,000 jobs × 64 KiB containers, exact identical keys) | Path | Time (4,000 jobs) | Speedup | |---|---:|---:| | Full `Prebuild::{graphics,compute}::key()` (`13f91ca`) | `123.37 ms` | baseline | | `Prebuild::{graphics_key,compute_key}()` | `35.20 ms` | **3.50× (-71.5%)** | *(In real SGD5 warm pre-build runs this additionally skips ~55,000+ `miniz_oxide` container inflations and the entire second `game_dir` disk scan.)* ### Not a duplicate of - Checked #2534 (`shaderpack::find`, intentionally left untouched), #2592 (rejects VS+GS), #2706 / #2646 (pipeline library file splitting), and #2211 (`pipeline::shader()` + `Translated.atomics64`). None overlaps these changes. ### Verification - Verified on `windows-latest` MSVC + WARP SM 6.6 CI (both clippy `-D warnings` profiles, `xtask` policy 6/6, `victory-game` 16/16 including `space_enumerations_stop_early_when_wanted_empties`, `victory-gpu` 198/198 including `prebuild_key_shortcuts_match_full_prebuild_keys`): https://github.com/RVZO6/VIctory/actions/runs/45693633259 - **Not run:** the title; any hardware GPU. AI-assisted: T3 Code (Antigravity, gemini-4-neon)
kotekompotek commented 2026-11-25 21:03:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T20:40:15Z.


The hot path is right: hashing each container's trimmed bytes once up front (0x18..0x1c size field) means warm prebuild keying never re-inflates. The claimed equivalence key_of == prepare(job).map(|p| p.key()) is the load-bearing invariant - from reading, compute takes the single stage hash and graphics take vs.or(gs) then ps, which matches the pipeline key order. A unit test asserting both paths agree on a synthetic container set would make the invariant durable.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7174014661 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2787#issuecomment-7174014661). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T20:40:15Z. --- The hot path is right: hashing each container's trimmed bytes once up front (0x18..0x1c size field) means warm prebuild keying never re-inflates. The claimed equivalence key_of == prepare(job).map(|p| p.key()) is the load-bearing invariant - from reading, compute takes the single stage hash and graphics take vs.or(gs) then ps, which matches the pipeline key order. A unit test asserting both paths agree on a synthetic container set would make the invariant durable.
oni-swr commented 2026-11-25 21:03:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T20:58:49Z.


WARP/CPU verification of head 38614b414ce21a5a3b7e53e69d67702ace984aef

Environment: Windows 11 x64, rustc/cargo 1.98.1, WARP/CPU only (VICTORY_WARP=1, VICTORY_D3D12_WARP=1), no physical GPU, no game files. DXIL validation with Windows SDK 10.0.26100.0 x64 dxil.dll 1.8.2502.11. PR head merged cleanly onto origin/main 13f91caee2.

Tests (cargo test --no-fail-fast -p victory -p victory-game -p victory-gpu)

  • origin/main baseline: victory 10 + census 2; victory-game 15; victory-gpu 195 passed, 1 ignored. 0 failed.
  • With this PR: victory 10 + census 2 (unchanged); victory-game 16; victory-gpu 196 passed, 2 ignored (+1 space_enumerations_stop_early_when_wanted_empties, +1 prebuild_key_shortcuts_match_full_prebuild_keys, +1 ignored bench_prebuild_key_vs_full, not run). 0 failed.

Negative control (each applied alone, then reverted)

  • graphics_key drops the graphics state: prebuild_key_shortcuts_match_full_prebuild_keys fails.
  • compute_key uses the wrong stage name: same test fails.
  • Early-exit disabled (f(b)? becomes let _ = f(b) in the space enumerators): space_enumerations_stop_early_when_wanted_empties fails.
  • Dropping the stage name inside the shared key_from_hashes is not caught, since the test compares against the full path, which calls the same function (expected for a comparison test).

Lint: cargo clippy --all-targets -- -D warnings clean. cargo fmt --check: +6 hunks (891 on main, 897 with the PR): apps/victory/src/prebuild.rs +1, apps/victory/src/translate.rs +1, crates/victory-game/src/pipelines.rs +2 (the two over-long fn raster_space/fn depth_space signatures), crates/victory-gpu/src/pipeline.rs +2 (test code). Note: cargo fmt --check is already red on origin/main here (891 hunks, none from these PRs), so I compared per-file hunk counts against that baseline.

Review: read the full diff. The shortcut key matches the full key for compute, VS+PS, VS-only and MS+PS streams; stream(..) only stores the shader pointers, so passing empty slices is safe; translate::warm's relevant list uses the same predicate (shader pack magic or non-empty sources) and the same size filter as prebuild::run's own file scan, so the pack, databases and containers it sees are unchanged. Gaps: no test covers key_of end to end or the relevant filtering (both run only against a game directory, which I did not use), and the speed-up itself is unmeasured here (the benchmark is #[ignore]). No game files, dumps, shader names, or retail hashes.

AI disclosure: this verification was done by Claude Code (Claude Sonnet 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7174447240 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2787#issuecomment-7174447240). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-25T20:58:49Z. --- **WARP/CPU verification of head `38614b414ce21a5a3b7e53e69d67702ace984aef`** **Environment:** Windows 11 x64, rustc/cargo 1.98.1, WARP/CPU only (VICTORY_WARP=1, VICTORY_D3D12_WARP=1), no physical GPU, no game files. DXIL validation with Windows SDK 10.0.26100.0 x64 dxil.dll 1.8.2502.11. PR head merged cleanly onto origin/main 13f91caee25f2fdf2c062be5f7a27f058e51cbca. **Tests (`cargo test --no-fail-fast -p victory -p victory-game -p victory-gpu`)** - `origin/main` baseline: victory 10 + census 2; victory-game 15; victory-gpu 195 passed, 1 ignored. 0 failed. - With this PR: victory 10 + census 2 (unchanged); victory-game 16; victory-gpu 196 passed, 2 ignored (+1 `space_enumerations_stop_early_when_wanted_empties`, +1 `prebuild_key_shortcuts_match_full_prebuild_keys`, +1 ignored `bench_prebuild_key_vs_full`, not run). 0 failed. **Negative control** (each applied alone, then reverted) - `graphics_key` drops the graphics state: `prebuild_key_shortcuts_match_full_prebuild_keys` fails. - `compute_key` uses the wrong stage name: same test fails. - Early-exit disabled (`f(b)?` becomes `let _ = f(b)` in the space enumerators): `space_enumerations_stop_early_when_wanted_empties` fails. - Dropping the stage name inside the shared `key_from_hashes` is **not** caught, since the test compares against the full path, which calls the same function (expected for a comparison test). **Lint:** `cargo clippy --all-targets -- -D warnings` clean. `cargo fmt --check`: **+6 hunks** (891 on main, 897 with the PR): `apps/victory/src/prebuild.rs` +1, `apps/victory/src/translate.rs` +1, `crates/victory-game/src/pipelines.rs` +2 (the two over-long `fn raster_space`/`fn depth_space` signatures), `crates/victory-gpu/src/pipeline.rs` +2 (test code). Note: `cargo fmt --check` is already red on `origin/main` here (891 hunks, none from these PRs), so I compared per-file hunk counts against that baseline. **Review:** read the full diff. The shortcut key matches the full key for compute, VS+PS, VS-only and MS+PS streams; `stream(..)` only stores the shader pointers, so passing empty slices is safe; `translate::warm`'s `relevant` list uses the same predicate (shader pack magic or non-empty `sources`) and the same size filter as `prebuild::run`'s own file scan, so the pack, databases and containers it sees are unchanged. Gaps: no test covers `key_of` end to end or the `relevant` filtering (both run only against a game directory, which I did not use), and the speed-up itself is unmeasured here (the benchmark is `#[ignore]`). No game files, dumps, shader names, or retail hashes. AI disclosure: this verification was done by Claude Code (Claude Sonnet 5.5).
fuzeofficlal commented 2026-11-25 22:04:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T21:13:20Z.


Reviewed and benchmarked 38614b41 on Windows 11 (RTX 5090 + WARP + dxil.dll) against main (13f91ca).

Code review

  • Filtering &relevant in translate::warm via data.starts_with(shaderpack::MAGIC) || !jobs.is_empty() matches prebuild.rs:53 while leaving VICTORY_PREBUILD_KEYS on full &paths.
  • Caching 16-byte BLAKE3 hex digests and hashing via Prebuild::{compute_key, graphics_key} (make::key_from_hashes) matches full Prebuild::key() (prebuild_key_shortcuts_match_full_prebuild_keys), and Named::find stopping early with ControlFlow::Break once want.depth/want.raster empty is equivalent.
  • Merge note: clean git merge-tree vs 13f91ca, #2664, #2784, #2785, #2786; conflicts in apps/victory/src/prebuild.rs with #2592 (which rejects vs && gs instead of silently dropping gs via vs.or(gs)—worth keeping key_of aligned with prepare if both land).

Verification & same-machine --release benchmark (rustc 1.98.1 MSVC)

  • victory CLI: 12/12 passed; victory-game: 16/16 passed (including space_enumerations_stop_early_when_wanted_empties); victory-gpu (pipeline:: & shader_cache::) on both RTX 5090 and WARP: 19/19 passed.
  • cargo clippy --locked -p victory -p victory-gpu -p victory-game --all-targets -- -D warnings: 0 warnings; cargo xtask policy: 184 files ok.
  • pipeline::tests::bench_prebuild_key_vs_full (--release, 3-run median, 4,000 jobs × 64 KiB): 126.91 ms -> 22.00 ms (5.77× / -82.7%).
<!-- greyfinch-sync:Marvisak/VIctory:comment:7174776354 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2787#issuecomment-7174776354). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T21:13:20Z. --- Reviewed and benchmarked `38614b41` on Windows 11 (RTX 5090 + WARP + `dxil.dll`) against `main` (`13f91ca`). ### Code review - Filtering `&relevant` in `translate::warm` via `data.starts_with(shaderpack::MAGIC) || !jobs.is_empty()` matches `prebuild.rs:53` while leaving `VICTORY_PREBUILD_KEYS` on full `&paths`. - Caching 16-byte BLAKE3 hex digests and hashing via `Prebuild::{compute_key, graphics_key}` (`make::key_from_hashes`) matches full `Prebuild::key()` (`prebuild_key_shortcuts_match_full_prebuild_keys`), and `Named::find` stopping early with `ControlFlow::Break` once `want.depth`/`want.raster` empty is equivalent. - **Merge note**: clean `git merge-tree` vs `13f91ca`, `#2664`, `#2784`, `#2785`, `#2786`; conflicts in `apps/victory/src/prebuild.rs` with `#2592` (which rejects `vs && gs` instead of silently dropping `gs` via `vs.or(gs)`—worth keeping `key_of` aligned with `prepare` if both land). ### Verification & same-machine `--release` benchmark (`rustc 1.98.1` MSVC) - `victory` CLI: **12/12 passed**; `victory-game`: **16/16 passed** (including `space_enumerations_stop_early_when_wanted_empties`); `victory-gpu` (`pipeline::` & `shader_cache::`) on both **RTX 5090** and **WARP**: **19/19 passed**. - `cargo clippy --locked -p victory -p victory-gpu -p victory-game --all-targets -- -D warnings`: **0 warnings**; `cargo xtask policy`: **184 files ok**. - `pipeline::tests::bench_prebuild_key_vs_full` (`--release`, 3-run median, 4,000 jobs × 64 KiB): `126.91 ms` -> **`22.00 ms`** (**5.77× / -82.7%**).
Marvisak commented 2026-11-26 00:03:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:25:23Z.


Automated triage for the maintainers.

This speeds up warm pre-builds in three ways, all without changing the pipeline keys. translate::warm passes prebuild::run only the files that hold containers or the pack; the predicate is the same as prebuild::run's own file filter. prebuild::run hashes each container once during its scan and keys jobs with the new Prebuild::compute_key/graphics_key (through make::key_from_hashes, which make::key now uses as well) instead of copying and re-hashing containers per job. Named::find stops the depth and raster enumerations once nothing is left to find. I checked that the hash matches Shader::new (BLAKE3 of the container trimmed to its own size, first 16 hex digits). A job that key_of accepts but prepare would refuse now reaches the make loop and is skipped there, so the skip counts stay the same. Expect a conflict in apps/victory/src/prebuild.rs with #2592; key_of should follow whatever prepare does about VS+GS if both land. CI passes.

This is a recommendation for a maintainer to look, not an approval.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177538763 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2787#issuecomment-7177538763). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T23:25:23Z. --- <!-- victory-triage v1 head=38614b414ce21a5a3b7e53e69d67702ace984aef verdict=merge-candidate at=2026-11-25T23:25:13Z --> Automated triage for the maintainers. This speeds up warm pre-builds in three ways, all without changing the pipeline keys. `translate::warm` passes `prebuild::run` only the files that hold containers or the pack; the predicate is the same as `prebuild::run`'s own file filter. `prebuild::run` hashes each container once during its scan and keys jobs with the new `Prebuild::compute_key`/`graphics_key` (through `make::key_from_hashes`, which `make::key` now uses as well) instead of copying and re-hashing containers per job. `Named::find` stops the depth and raster enumerations once nothing is left to find. I checked that the hash matches `Shader::new` (BLAKE3 of the container trimmed to its own size, first 16 hex digits). A job that `key_of` accepts but `prepare` would refuse now reaches the make loop and is skipped there, so the skip counts stay the same. Expect a conflict in `apps/victory/src/prebuild.rs` with #2592; `key_of` should follow whatever `prepare` does about VS+GS if both land. CI passes. This is a recommendation for a maintainer to look, not an approval. --- _Generated by [Claude Code](https://claude.ai/code)_
Dukestar69 commented 2026-11-26 03:51:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T03:51:35Z.

Review: APPROVED


Tested merged onto origin/main (63bcca4) on Windows 11 x64:

  • cargo test -p victory-game --lib pipelines::: 8 passed, 0 failed (including new space_enumerations_stop_early_when_wanted_empties).
  • cargo test -p victory-gpu --lib pipeline::tests: 5 passed, 0 failed, 1 ignored (including new prebuild_key_shortcuts_match_full_prebuild_keys).
  • cargo clippy -p victory-game -p victory-gpu -p victory --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6068310451 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2787#pullrequestreview-6068310451). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T03:51:35Z. **Review:** APPROVED --- Tested merged onto `origin/main` (`63bcca4`) on Windows 11 x64: - `cargo test -p victory-game --lib pipelines::`: **8 passed, 0 failed** (including new `space_enumerations_stop_early_when_wanted_empties`). - `cargo test -p victory-gpu --lib pipeline::tests`: **5 passed, 0 failed, 1 ignored** (including new `prebuild_key_shortcuts_match_full_prebuild_keys`). - `cargo clippy -p victory-game -p victory-gpu -p victory --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal commented 2026-11-26 14:39:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T14:39:32Z.

Review: APPROVED


Reviewed 38614b414ce21a5a3b7e53e69d67702ace984aef merged cleanly onto main (63bcca43c6a0) and verified on Windows 11 x64 (Ryzen 9 9950X, NVIDIA GeForce RTX 5090 + Microsoft WARP, VICTORY_D3D12_DEBUG=1, Rust 1.98.1).

Code Review

  • Directory rescan avoidance (apps/victory/src/translate.rs:341,359,436): Recording relevant paths with data.starts_with(shaderpack::MAGIC) || !jobs.is_empty() under the same MAX_FILE bound matches prebuild::run's filter (apps/victory/src/prebuild.rs:50-52) identically, while VICTORY_PREBUILD_KEYS continues scanning full &paths.
  • Zero-inflate / zero-rehash keying (apps/victory/src/prebuild.rs:31,97,129-180,275, crates/victory-gpu/src/pipeline.rs:627,637, crates/victory-gpu/src/pipeline/make.rs:95,112):
    • Each container is validated against its 0x18..0x1c size field (rejecting truncated or empty slices) and hashed once to the same 16-char BLAKE3 hex prefix used by Shader::new.
    • victory_game::pipelines::stream only writes (ptr, len) into shader bytecode subobjects without reading shader bytes, Prebuild::graphics_key reads the identical GraphicsState via read_stream(stream, |_, _| None) without dereferencing shader pointers, and make::key_from_hashes is bit-for-bit identical to make::key (omitting update(&[]) for None is a BLAKE3 no-op).
  • Early-exit Named::find (crates/victory-game/src/pipelines.rs:91-110,167,203): Because try_one gates insertion on want.remove(&hash), once want.depth or want.raster empties no subsequent candidate can insert or overwrite anything, so ControlFlow::Break preserves exact selection semantics.
  • Merge-batch note: Conflicts in apps/victory/src/prebuild.rs with #2592 (vs && gs handling); if both land, keep key_of aligned with prepare.

Verification (9950X + RTX 5090 + WARP + VICTORY_D3D12_DEBUG=1, Rust 1.98.1)

  • cargo run --locked -p xtask -- policy: 191 files ok.
  • cargo clippy --workspace --all-targets --locked -- -D warnings (default and --all-features): 0 warnings.
  • victory CLI: 18/18 passed (14 unit + 2 census + 1 census_unreadable + 1 translate).
  • victory-game: 16/16 passed (including space_enumerations_stop_early_when_wanted_empties).
  • victory-gpu pipeline:: (VICTORY_D3D12_DEBUG=1): 24/24 passed (1 benchmark ignored) on RTX 5090; 27/27 passed (1 benchmark ignored) on WARP (--features diagnostics), including prebuild_key_shortcuts_match_full_prebuild_keys.
  • --release pipeline::tests::bench_prebuild_key_vs_full on Ryzen 9 9950X (4,000 jobs × 64 KiB containers): full=122.71 ms, key_only=22.11 ms (5.55x).

LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:review:6075994876 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2787#pullrequestreview-6075994876). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T14:39:32Z. **Review:** APPROVED --- Reviewed `38614b414ce21a5a3b7e53e69d67702ace984aef` merged cleanly onto `main` (`63bcca43c6a0`) and verified on Windows 11 x64 (Ryzen 9 9950X, NVIDIA GeForce RTX 5090 + Microsoft WARP, `VICTORY_D3D12_DEBUG=1`, Rust `1.98.1`). ### Code Review - **Directory rescan avoidance (`apps/victory/src/translate.rs:341,359,436`)**: Recording `relevant` paths with `data.starts_with(shaderpack::MAGIC) || !jobs.is_empty()` under the same `MAX_FILE` bound matches `prebuild::run`'s filter (`apps/victory/src/prebuild.rs:50-52`) identically, while `VICTORY_PREBUILD_KEYS` continues scanning full `&paths`. - **Zero-inflate / zero-rehash keying (`apps/victory/src/prebuild.rs:31,97,129-180,275`, `crates/victory-gpu/src/pipeline.rs:627,637`, `crates/victory-gpu/src/pipeline/make.rs:95,112`)**: - Each container is validated against its `0x18..0x1c` size field (rejecting truncated or empty slices) and hashed once to the same 16-char BLAKE3 hex prefix used by `Shader::new`. - `victory_game::pipelines::stream` only writes `(ptr, len)` into shader bytecode subobjects without reading shader bytes, `Prebuild::graphics_key` reads the identical `GraphicsState` via `read_stream(stream, |_, _| None)` without dereferencing shader pointers, and `make::key_from_hashes` is bit-for-bit identical to `make::key` (omitting `update(&[])` for `None` is a BLAKE3 no-op). - **Early-exit `Named::find` (`crates/victory-game/src/pipelines.rs:91-110,167,203`)**: Because `try_one` gates insertion on `want.remove(&hash)`, once `want.depth` or `want.raster` empties no subsequent candidate can insert or overwrite anything, so `ControlFlow::Break` preserves exact selection semantics. - **Merge-batch note**: Conflicts in `apps/victory/src/prebuild.rs` with `#2592` (`vs && gs` handling); if both land, keep `key_of` aligned with `prepare`. ### Verification (9950X + RTX 5090 + WARP + `VICTORY_D3D12_DEBUG=1`, Rust `1.98.1`) - `cargo run --locked -p xtask -- policy`: `191 files ok`. - `cargo clippy --workspace --all-targets --locked -- -D warnings` (default and `--all-features`): 0 warnings. - `victory` CLI: **18/18 passed** (14 unit + 2 `census` + 1 `census_unreadable` + 1 `translate`). - `victory-game`: **16/16 passed** (including `space_enumerations_stop_early_when_wanted_empties`). - `victory-gpu` `pipeline::` (`VICTORY_D3D12_DEBUG=1`): **24/24 passed** (1 benchmark ignored) on RTX 5090; **27/27 passed** (1 benchmark ignored) on WARP (`--features diagnostics`), including `prebuild_key_shortcuts_match_full_prebuild_keys`. - `--release` `pipeline::tests::bench_prebuild_key_vs_full` on Ryzen 9 9950X (4,000 jobs × 64 KiB containers): `full=122.71 ms`, `key_only=22.11 ms` (**5.55x**). LGTM.
andrewpozdnakov7-jpg commented 2026-11-26 16:05:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T15:57:18Z.


I checked the #2592 conflict raised in review. Integration 3e2bb33 combines exact 38614b4, dd2d861 and 63bcca4, preserving both PR histories.

The fast cache-key path and full preparation now share the stage check. Both reject VS+GS before looking up a container, even if the vertex key would already be cached. Diagnostics list all stages and reuse their cached hashes. The regression checks that VS+PS and MS+PS get identical keys via both paths. Restoring the old fast-path stage selection makes that test fail specifically at the VS+GS lookup.

On synthetic inputs, all 19 CLI tests, 8 game pipeline tests and the GPU key-equivalence test passed. Strict all-feature Clippy for the affected packages and the asset-policy check passed. The integration branch is available when you choose the merge order.

Please retain the Git authors on pickup. If folding the integration or its test into another commit, use Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7196977801 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2787#issuecomment-7196977801). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T15:57:18Z. --- I checked the #2592 conflict raised in review. [Integration `3e2bb33`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/3e2bb33f614cdd6b123e37aa117e1afa63c537d9) combines exact `38614b4`, `dd2d861` and `63bcca4`, preserving both PR histories. The fast cache-key path and full preparation now share the stage check. Both reject VS+GS before looking up a container, even if the vertex key would already be cached. Diagnostics list all stages and reuse their cached hashes. The regression checks that VS+PS and MS+PS get identical keys via both paths. Restoring the old fast-path stage selection makes that test fail specifically at the VS+GS lookup. On synthetic inputs, all 19 CLI tests, 8 game pipeline tests and the GPU key-equivalence test passed. Strict all-feature Clippy for the affected packages and the asset-policy check passed. The [integration branch](https://github.com/andrewpozdnakov7-jpg/VIctory/tree/codex/prebuild-2787-2592) is available when you choose the merge order. Please retain the Git authors on pickup. If folding the integration or its test into another commit, use `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`.
andrewpozdnakov7-jpg commented 2026-11-27 18:26:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T18:26:07Z.


I checked how this optimization combines with #3568. Git flags the key scheduling block because both PRs touch it. The tested resolution preserves this PR's key_of(job) path and checks for duplicates before the library lookup. The diagnostic path still prepares and lists each record.

On app-local WARP, a pack of 17 synthetic records for two keys made both pipelines with zero redundant library loads. The warm run found the same two saved keys, and the diagnostic listing matched all 17 rows from main. With one worker and one key in the early list, that key was built first. All 18 application tests with diagnostics, strict Clippy and the asset policy passed.

The next step is for the authors or maintainers to choose the integration order. If reusing the resolution, please retain the original Git authors. For my part, please add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding it into another commit. AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7225484755 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2787#issuecomment-7225484755). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-27T18:26:07Z. --- I checked how this optimization combines with #3568. Git flags the key scheduling block because both PRs touch it. [The tested resolution](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/9a8283780af8d7a6cdddc014d64ca27ac3fef80d) preserves this PR's `key_of(job)` path and checks for duplicates before the library lookup. The diagnostic path still prepares and lists each record. On app-local WARP, a pack of 17 synthetic records for two keys made both pipelines with zero redundant library loads. The warm run found the same two saved keys, and the diagnostic listing matched all 17 rows from `main`. With one worker and one key in the early list, that key was built first. All 18 application tests with diagnostics, strict Clippy and the asset policy passed. The next step is for the authors or maintainers to choose the integration order. If reusing the resolution, please retain the original Git authors. For my part, please add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding it into another commit. AI-assisted with Codex.
andrewpozdnakov7-jpg commented 2026-11-27 19:36:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T19:36:53Z.


I checked how the warmup file prefilter here combines with #3589. In the exact clean merge of 38614b4 and e5eb57a, normal translate --cache --pipelines still reports no pack for an SGD5 archive containing only the compressed pipeline pack. Both separate shader containers translate. The prefilter drops the archive before the new lookup sees it.

Paired test branch keeps both original commits and adds e0e2276 to retain the recognized SGD5 paths. On Windows WARP with the same synthetic inputs, the cold run creates two distinct pipelines and the warm run finds all 17 records in the library. The standalone-pack control has the same counts before and after. The unmarked archive is still skipped.

All 18 CLI tests with diagnostics, strict all-feature CLI Clippy, rustfmt and the asset policy check passed.

@RVZO6 can apply the prefilter change when the two PRs are combined. If you cherry-pick or rebase my follow-up, please retain its Git author. If you fold it into another commit, please include Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7226701122 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2787#issuecomment-7226701122). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-27T19:36:53Z. --- I checked how the warmup file prefilter here combines with #3589. In the exact clean merge of `38614b4` and `e5eb57a`, normal `translate --cache --pipelines` still reports no pack for an SGD5 archive containing only the compressed pipeline pack. Both separate shader containers translate. The prefilter drops the archive before the new lookup sees it. [Paired test branch](https://github.com/andrewpozdnakov7-jpg/VIctory/commits/codex2/pr2787-sgd5-prefilter) keeps both original commits and adds `e0e2276` to retain the recognized SGD5 paths. On Windows WARP with the same synthetic inputs, the cold run creates two distinct pipelines and the warm run finds all 17 records in the library. The standalone-pack control has the same counts before and after. The unmarked archive is still skipped. All 18 CLI tests with diagnostics, strict all-feature CLI Clippy, rustfmt and the asset policy check passed. @RVZO6 can apply the prefilter change when the two PRs are combined. If you cherry-pick or rebase my follow-up, please retain its Git author. If you fold it into another commit, please include `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`.
andrewpozdnakov7-jpg commented 2026-11-27 21:18:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T21:18:22Z.


I resolved the overlap between the path prefilter in 38614b4 and #3610, and included the #3589 archive handling from the earlier SGD5 follow-up. The combined branch preserves all three PR heads in its history. Combined commit e13fdd6

I tested the normal CLI with a parent input directory, a nested directory and an explicit duplicate file. For both a standalone pack and the same pack inside a shaderless SGD5 archive, the CLI read the four distinct files in shader warm-up and the three relevant ones in prebuild. The unrelated file was read once. All 17 diagnostic keys match the original main fixture. Both cold WARP runs made two distinct pipelines and both repeat runs found all 17 records in the library.

All 19 CLI tests and 16 victory-game tests passed. Strict all-feature Clippy for victory, victory-game and victory-gpu and the asset policy check also passed. The local read counters were temporary.

If reusing the combined resolution, please retain the Git authors when cherry-picking or rebasing. If folding my changes into another commit, please add the trailer below.

Co-authored-by: andrewpozdnakov7-jpg [email protected]

<!-- greyfinch-sync:Marvisak/VIctory:comment:7228324002 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2787#issuecomment-7228324002). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-27T21:18:22Z. --- I resolved the overlap between the path prefilter in `38614b4` and #3610, and included the #3589 archive handling from the [earlier SGD5 follow-up](https://github.com/Marvisak/VIctory/pull/2787#issuecomment-7226701122). The combined branch preserves all three PR heads in its history. [Combined commit e13fdd6](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/e13fdd660c4f1cb019ca2a6a94624e1685c896e1) I tested the normal CLI with a parent input directory, a nested directory and an explicit duplicate file. For both a standalone pack and the same pack inside a shaderless SGD5 archive, the CLI read the four distinct files in shader warm-up and the three relevant ones in prebuild. The unrelated file was read once. All 17 diagnostic keys match the original main fixture. Both cold WARP runs made two distinct pipelines and both repeat runs found all 17 records in the library. All 19 CLI tests and 16 victory-game tests passed. Strict all-feature Clippy for victory, victory-game and victory-gpu and the asset policy check also passed. The local read counters were temporary. If reusing the combined resolution, please retain the Git authors when cherry-picking or rebasing. If folding my changes into another commit, please add the trailer below. Co-authored-by: andrewpozdnakov7-jpg <[email protected]>
andrewpozdnakov7-jpg commented 2026-11-28 07:56:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T07:56:05Z.


I resolved the overlap between #3692 and the existing warmup-input composition e13fdd6 in 80071f8. That composition contains this PR at 38614b4, #3589 and #3610. The resolution is confined to prebuild.rs. The ordinary warmup keeps the fast key_of(job) lookup, and diagnostic runs write keys and skipped rows in record order.

The signed app-local WARP run matched all 2,048 lines from #3692 byte for byte across six runs with one and eight workers. Normal prebuild on a separate generated pack created two pipelines on a cold cache and found all 17 records in the library on the next run. The CLI and game tests, strict app/GPU/game Clippy and the asset policy passed.

RVZO6 or a maintainer can pick up the resolution if both changes land together. 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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7236254995 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2787#issuecomment-7236254995). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T07:56:05Z. --- I resolved the overlap between #3692 and the existing warmup-input composition [e13fdd6](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/e13fdd660c4f1cb019ca2a6a94624e1685c896e1) in [80071f8](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/80071f883d0c8f6baab8f9e8ad4d2bb51ca09026). That composition contains this PR at `38614b4`, #3589 and #3610. The resolution is confined to `prebuild.rs`. The ordinary warmup keeps the fast `key_of(job)` lookup, and diagnostic runs write keys and skipped rows in record order. The signed app-local WARP run matched all 2,048 lines from #3692 byte for byte across six runs with one and eight workers. Normal prebuild on a separate generated pack created two pipelines on a cold cache and found all 17 records in the library on the next run. The CLI and game tests, strict app/GPU/game Clippy and the asset policy passed. RVZO6 or a maintainer can pick up the resolution if both changes land together. 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.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2787:upstream-pr/2787'
git switch 'upstream-pr/2787'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/2787'
git switch 'upstream-pr/2787'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2787'
git switch 'upstream-pr/2787'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2787'
git switch 'main'
git merge --squash 'upstream-pr/2787'
git switch 'main'
git merge --ff-only 'upstream-pr/2787'
git switch 'main'
git merge 'upstream-pr/2787'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2785
No description provided.