Repository navigation
CLI/GPU: avoid rescanning game_dir and re-inflating/re-hashing cached containers during warm prebuild, and stop Named::find early - #2787
Conversation
… containers during warm prebuild, and stop Named::find early Speed up warm `translate --cache --pipelines` and `prebuild` runs without touching `shader_cache.rs` (zero cache invalidation) or changing any pipeline key: - `translate::warm`: record files containing containers or the shader pack during its walk and pass only those paths to `prebuild::run`, avoiding a full second walk/read of the entire game directory. - `prebuild::run`: compute and cache each container's 16-char BLAKE3 hex hash during the single initial `programs` scan, and check `pipeline::prebuilt(&key)` / `wanted_early(&key)` via new `Prebuild::compute_key` and `Prebuild::graphics_key` shortcuts (backed by `make::key_from_hashes`) instead of re-inflating, copying, and re-hashing every container in the pack before filtering to unbuilt `todo` jobs. - `victory-game::pipelines`: skip and early-exit `depth_space` / `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 x 64 KiB containers, exact identical keys): - Full Prebuild::{graphics,compute}::key(): 123.37 ms - Prebuild::{graphics_key,compute_key}(): 35.20 ms (3.50x, -71.5%) (In real SGD5 prebuild runs this also skips ~55,000+ zlib inflates on warm caches and the full second game_dir scan.) Assisted-by: T3 Code (Antigravity, gemini-4-neon)
|
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. |
|
WARP/CPU verification of head 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 13f91ca. Tests (
Negative control (each applied alone, then reverted)
Lint: Review: read the full diff. The shortcut key matches the full key for compute, VS+PS, VS-only and MS+PS streams; AI disclosure: this verification was done by Claude Code (Claude Sonnet 5.5). |
|
Reviewed and benchmarked Code review
Verification & same-machine
|
|
Automated triage for the maintainers. This speeds up warm pre-builds in three ways, all without changing the pipeline keys. This is a recommendation for a maintainer to look, not an approval. Generated by Claude Code |
Dukestar69
left a comment
There was a problem hiding this comment.
Tested merged onto origin/main (63bcca4) on Windows 11 x64:
cargo test -p victory-game --lib pipelines::: 8 passed, 0 failed (including newspace_enumerations_stop_early_when_wanted_empties).cargo test -p victory-gpu --lib pipeline::tests: 5 passed, 0 failed, 1 ignored (including newprebuild_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
left a comment
There was a problem hiding this comment.
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): Recordingrelevantpaths withdata.starts_with(shaderpack::MAGIC) || !jobs.is_empty()under the sameMAX_FILEbound matchesprebuild::run's filter (apps/victory/src/prebuild.rs:50-52) identically, whileVICTORY_PREBUILD_KEYScontinues 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..0x1csize field (rejecting truncated or empty slices) and hashed once to the same 16-char BLAKE3 hex prefix used byShader::new. victory_game::pipelines::streamonly writes(ptr, len)into shader bytecode subobjects without reading shader bytes,Prebuild::graphics_keyreads the identicalGraphicsStateviaread_stream(stream, |_, _| None)without dereferencing shader pointers, andmake::key_from_hashesis bit-for-bit identical tomake::key(omittingupdate(&[])forNoneis a BLAKE3 no-op).
- Each container is validated against its
- Early-exit
Named::find(crates/victory-game/src/pipelines.rs:91-110,167,203): Becausetry_onegates insertion onwant.remove(&hash), oncewant.depthorwant.rasterempties no subsequent candidate can insert or overwrite anything, soControlFlow::Breakpreserves exact selection semantics. - Merge-batch note: Conflicts in
apps/victory/src/prebuild.rswith#2592(vs && gshandling); if both land, keepkey_ofaligned withprepare.
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.victoryCLI: 18/18 passed (14 unit + 2census+ 1census_unreadable+ 1translate).victory-game: 16/16 passed (includingspace_enumerations_stop_early_when_wanted_empties).victory-gpupipeline::(VICTORY_D3D12_DEBUG=1): 24/24 passed (1 benchmark ignored) on RTX 5090; 27/27 passed (1 benchmark ignored) on WARP (--features diagnostics), includingprebuild_key_shortcuts_match_full_prebuild_keys.--releasepipeline::tests::bench_prebuild_key_vs_fullon Ryzen 9 9950X (4,000 jobs × 64 KiB containers):full=122.71 ms,key_only=22.11 ms(5.55x).
LGTM.
|
I checked the #2592 conflict raised in review. Integration 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 |
…rescanning/re-hashing
Claimed in #1633: #1633 (comment)
Summary
Speeds up warm
victory translate --cache --pipelinesandprebuildruns (e.g. the warm-cache overhead reported in #2602) with byte-for-byte identical pipeline keys and zero shader-cache invalidation (shader_cache.rsis intentionally untouched):game_dira second time (apps/victory/src/translate.rs):translate::warmrecords the paths of files containing containers or the shader pack during its walk and passes only those paths toprebuild::run, avoiding a full second walk and read of the entire game directory.apps/victory/src/prebuild.rs,crates/victory-gpu/src/pipeline.rs,crates/victory-gpu/src/pipeline/make.rs):prebuild::runcomputes and caches each container's 16-char BLAKE3 hex hash once during the initialprogramsscan.Prebuild::compute_key(hash)andPrebuild::graphics_key(stream, &[(stage, hash)])(viamake::key_from_hashes) soprebuild::runcheckspipeline::prebuilt(&key)andwanted_early(&key)for all pack records without re-inflating, double-copying, or re-hashing every container ~55,000+ times before filtering to unbuilttodojobs.shaders_ofreuses the cached hash too.Named::find(crates/victory-game/src/pipelines.rs): skips and breaks out of the 2.49M-iterationdepth_spaceand 478k-iterationraster_spaceenumerations viaControlFlow::Breakas soon aswantempties.Measured on
13f91ca(--release pipeline::tests::bench_prebuild_key_vs_full, median of 3 runs, 4,000 jobs × 64 KiB containers, exact identical keys)Prebuild::{graphics,compute}::key()(13f91ca)123.37 msPrebuild::{graphics_key,compute_key}()35.20 ms(In real SGD5 warm pre-build runs this additionally skips ~55,000+
miniz_oxidecontainer inflations and the entire secondgame_dirdisk scan.)Not a duplicate of
shaderpack::find, intentionally left untouched), CLI: reject VS+GS graphics pipelines in prebuild #2592 (rejects VS+GS), victory-gpu: keep a pipeline library per translation, not one shared one (a translator edit destroyed a 926 MB / 7.5 min cache) #2706 / GPU: a WARP host keeps its pipeline library in a file of its own (#2637) #2646 (pipeline library file splitting), and GPU: hash shaders once in pipeline::shader() and cache SFI0 atomics64 on Translated #2211 (pipeline::shader()+Translated.atomics64). None overlaps these changes.Verification
windows-latestMSVC + WARP SM 6.6 CI (both clippy-D warningsprofiles,xtaskpolicy 6/6,victory-game16/16 includingspace_enumerations_stop_early_when_wanted_empties,victory-gpu198/198 includingprebuild_key_shortcuts_match_full_prebuild_keys): https://github.com/RVZO6/VIctory/actions/runs/45693633259AI-assisted: T3 Code (Antigravity, gemini-4-neon)