CLI/GPU: avoid rescanning game_dir and re-inflating/re-hashing cached containers during warm prebuild, and stop Named::find early #2785
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2787"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by 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 --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), #2592 (rejects VS+GS), #2706 / #2646 (pipeline library file splitting), and #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)
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.
Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T20:58:49Z.
WARP/CPU verification of head
38614b414ce21a5a3b7e53e69d67702ace984aefEnvironment: 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/mainbaseline: victory 10 + census 2; victory-game 15; victory-gpu 195 passed, 1 ignored. 0 failed.space_enumerations_stop_early_when_wanted_empties, +1prebuild_key_shortcuts_match_full_prebuild_keys, +1 ignoredbench_prebuild_key_vs_full, not run). 0 failed.Negative control (each applied alone, then reverted)
graphics_keydrops the graphics state:prebuild_key_shortcuts_match_full_prebuild_keysfails.compute_keyuses the wrong stage name: same test fails.f(b)?becomeslet _ = f(b)in the space enumerators):space_enumerations_stop_early_when_wanted_emptiesfails.key_from_hashesis 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 warningsclean.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-longfn raster_space/fn depth_spacesignatures),crates/victory-gpu/src/pipeline.rs+2 (test code). Note:cargo fmt --checkis already red onorigin/mainhere (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'srelevantlist uses the same predicate (shader pack magic or non-emptysources) and the same size filter asprebuild::run's own file scan, so the pack, databases and containers it sees are unchanged. Gaps: no test coverskey_ofend to end or therelevantfiltering (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).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T21:13:20Z.
Reviewed and benchmarked
38614b41on Windows 11 (RTX 5090 + WARP +dxil.dll) againstmain(13f91ca).Code review
&relevantintranslate::warmviadata.starts_with(shaderpack::MAGIC) || !jobs.is_empty()matchesprebuild.rs:53while leavingVICTORY_PREBUILD_KEYSon full&paths.Prebuild::{compute_key, graphics_key}(make::key_from_hashes) matches fullPrebuild::key()(prebuild_key_shortcuts_match_full_prebuild_keys), andNamed::findstopping early withControlFlow::Breakoncewant.depth/want.rasterempty is equivalent.git merge-treevs13f91ca,#2664,#2784,#2785,#2786; conflicts inapps/victory/src/prebuild.rswith#2592(which rejectsvs && gsinstead of silently droppinggsviavs.or(gs)—worth keepingkey_ofaligned withprepareif both land).Verification & same-machine
--releasebenchmark (rustc 1.98.1MSVC)victoryCLI: 12/12 passed;victory-game: 16/16 passed (includingspace_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%).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::warmpassesprebuild::runonly the files that hold containers or the pack; the predicate is the same asprebuild::run's own file filter.prebuild::runhashes each container once during its scan and keys jobs with the newPrebuild::compute_key/graphics_key(throughmake::key_from_hashes, whichmake::keynow uses as well) instead of copying and re-hashing containers per job.Named::findstops the depth and raster enumerations once nothing is left to find. I checked that the hash matchesShader::new(BLAKE3 of the container trimmed to its own size, first 16 hex digits). A job thatkey_ofaccepts butpreparewould refuse now reaches the make loop and is skipped there, so the skip counts stay the same. Expect a conflict inapps/victory/src/prebuild.rswith #2592;key_ofshould follow whateverpreparedoes about VS+GS if both land. CI passes.This is a recommendation for a maintainer to look, not an approval.
Generated by Claude Code
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 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).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T14:39:32Z.
Review: APPROVED
Reviewed
38614b414ce21a5a3b7e53e69d67702ace984aefmerged cleanly ontomain(63bcca43c6a0) and verified on Windows 11 x64 (Ryzen 9 9950X, NVIDIA GeForce RTX 5090 + Microsoft WARP,VICTORY_D3D12_DEBUG=1, Rust1.98.1).Code Review
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.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):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).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.apps/victory/src/prebuild.rswith#2592(vs && gshandling); if both land, keepkey_ofaligned withprepare.Verification (9950X + RTX 5090 + WARP +
VICTORY_D3D12_DEBUG=1, Rust1.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.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T15:57:18Z.
I checked the #2592 conflict raised in review. Integration
3e2bb33combines exact38614b4,dd2d861and63bcca4, 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]>.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.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
38614b4ande5eb57a, normaltranslate --cache --pipelinesstill 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
e0e2276to 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]>.Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T21:18:22Z.
I resolved the overlap between the path prefilter in
38614b4and #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 e13fdd6I 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]
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 toprebuild.rs. The ordinary warmup keeps the fastkey_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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.