CLI/GPU: avoid rescanning game_dir and re-inflating/re-hashing cached containers during warm prebuild, and stop Named::find early #2787
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2787
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@RVZO6 on GitHub · 2026-11-25 20:23 UTC · original
RVZO6:rvzo/prebuild-warm-fast→main· +368 −35 · 5 files · 1 commits · openClaimed in #1633: #1633
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)
@kotekompotek on GitHub · 2026-11-25 20:40 UTC · original
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 on GitHub · 2026-11-25 20:58 UTC · original
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).
@fuzeofficlal on GitHub · 2026-11-25 21:13 UTC · original
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%).@Marvisak on GitHub · 2026-11-25 23:25 UTC · original
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
@Dukestar69 on GitHub · 2026-11-26 03:51 UTC · original · approved these changes
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 on GitHub · 2026-11-26 14:39 UTC · original · approved these changes
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.
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 15:57 UTC · original
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]>.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.