fix(warm): fix warm --used, add --route-file, scope shader repair #549
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/lobomfz--VIctory-xmem!549
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-549"
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?
@chefulano on GitHub · 2026-12-05 02:46 UTC · original
chefulano:pr4/warm-used-and-route-file→main· +459 −34 · 3 files · 2 commits · openProblem
On current
main,nativeis alwaysSome(...), sovictory warm --usedis unconditionally a no-op that warms the entire catalog, and the post-warm durability check asserts every catalog entry exists on disk. Because./run.sh warmpasseswarm --used, users on constrained 8 GiB VRAM / 16 GiB RAM systems (e.g., AMD RDNA 3 / RX 7600M XT 8 GiB) end up translating and compiling the full catalog instead of the boot/used subset. Fixedall.chunks(256)batches also under-utilize worker processes on small or medium warm subsets, andrepair_shadersalways scans every shader inknown-shaders.bineven when warming a small subset.Change
--usedwith native artifacts:select_pipelines()(taking groupedSelectInputs<'a>) andpipeline_in_scope()filter toearly-pipelines.txt ∪ compute_indices(wherecompute_indicesis a small superset ofmake::early()that also includesof_buildercompute entries) and scope the post-warm durability check to that subset. Since./run.sh warmpasses--used, whenearly-pipelines.txtis missing or empty--usedprints a stderr note explaining that only compute pipelines will be warmed (runvictory warmwithout--usedfor the full catalog).--route-file <path>: Reads newline-delimited 32-hex pipeline keys (stripping a leading UTF-8 BOM for PowerShell 5.1 files, ignoring blank lines and#comments, normalizing case, validating 32-hex format, and rejecting empty or comment-only files instead of exiting 0 with0 of 0), includes(expected UTF-8 text)in read errors, marks--route-fileasconflicts_with = "used"in clap, warns if any requested key is absent fromknown-pipelines.bin(missing_route_keys()), and warms strictly the listed subset.16..=256): Replaces fixedall.chunks(256)withbatch_chunk_size(total, jobs) = (total / (jobs * 4).max(1)).clamp(16, 256), improving worker utilization whenever the remaining workload supplies enough chunks above the 16-entry floor while keeping 256-pipeline chunks for large full-catalog runs (total >= jobs * 1024).known::repair_shaders_for(&dir, &all)when--usedor--route-fileis passed so./run.sh warm(warm --used) and--route-filerepair only shaders referenced by remaining in-scope pipelines (skipping repair if--limit 0leavesallempty). Defaultvictory warmretainsif limit.is_none() && !keys.is_empty()known::repair_shaders(&dir).Measured impact
Not separately timed as a standalone branch; motivated by cutting iterative warm/re-warm turnaround on constrained 8 GiB VRAM / 16 GiB RAM AMD RDNA 3 (RX 7600M XT 8 GiB) setups where full-catalog warming takes far longer than warming
early-pipelines.txt ∪ computeor a route subset.Verification
main(a5c6484), independent of open PR#465and companion GPU PRs.cargo xtask policy:368 files ok;cargo test -p xtask -- policy::tests:7 passed, 0 failed;cargo test -p xtask -- switches::documented_switches_are_read:1 passed, 0 failed.cargo check --locked --target x86_64-pc-windows-msvc -p victory-gpu -p victory --testsandcargo clippy --no-deps --locked --target x86_64-pc-windows-msvc -p victory-gpu -p victory --all-targets: 0 errors, 0 new warnings.warm::tests::(7 passed, 0 failed, including BOM + CRLF comment-first/key-first parsing, empty route-file rejection,--usednative filtering,--route-filestrict filtering, and dynamic chunk sizing) andpipeline::known::tests::(6 passed, 0 failed, includingcompute_indices_and_route_scoped_shader_ranges).@Kal0s-design on GitHub · 2026-12-05 06:17 UTC · original
Checked
511c197on native Windows (didn't run the game or use any game data).The base is
b581f7e, which is still main. I used toolchain 1.98.1 offline, targeting x86_64-pc-windows-msvc.The bug is real, and wider than the description says. On main
nativeis set unconditionally (let native = Some(known::artifacts(&dir))atwarm.rs:64). That means the(!used || early.contains(key))filter at mainwarm.rs:110sits in a branch that never runs. So--usedwas a no-op for everyone, not just when native artifacts happen to exist, and the post-warm check at mainwarm.rs:230always counted the whole catalogue.--againand thewarm-done.txtpath are in the same dead branch, andselect_pipelinesstill carries them (warm.rs:114). This PR doesn't have to fix that, but a comment there would save the next reader some time.I reproduced the scope fix without any real warming. I pointed both builds at a throwaway config and cache dir holding a hand-written four-entry
known-pipelines.bin(one early graphics entry, one compute, two unused graphics) and anearly-pipelines.txtnaming the first. There was noknown-shaders.bin, and every run used--limit 0 --jobs 1, soallstays empty and nothing is repaired or spawned. The last line printed is the size of the in-scope set.warm --usedprinted 0 of 4 native pipelines on diskwarmprinted 0 of 4warm --usedprinted 0 of 2, early plus compute as intended--usedandearly-pipelines.txtmoved away printed the new stderr note and 0 of 1, compute only--route-fileprinted 0 of 2CRLF route files work.
str::lines()drops the\r, andtrim()would catch it anyway. Uppercase keys, blank lines,#comment lines andkey # noteall parsed correctly from a CRLF file.A UTF-8 BOM fails on line 1. With a key on the first line the error is
invalid pipeline key on line 1: expected 32 hex chars, got "\u{feff}3030...". With a# headerfirst line it reportsgot "\u{feff}#", which is confusing because that line really is a comment.Out-File -Encoding utf8andSet-Content -Encoding utf8on Windows PowerShell 5.1 both write a BOM, so people will hit this. Stripping a leading'\u{feff}'fromcontentsbefore the loop atwarm.rs:46would fix it.UTF-16 is what a plain
>redirect writes on Windows PowerShell 5.1. It fails withstream did not contain valid UTF-8under thecould not read --route-filecontext. That's a clean error and fine as it is, though mentioning the encoding in the message would help.key#notewith no space before the#is rejected as an invalid key.key garbage hereis accepted and the trailing words are silently ignored. Both are defensible, I'm only pointing them out. An unknown key prints the "not found in known-pipelines.bin" warning and carries on, as described. Every path form I tried worked, namely relative with forward slashes, relative with backslashes, absolute with a drive letter, a file name containing spaces, and a\\?\verbatim path. Nothing in this path canonicalizes, so prefixes don't come into it.Two cases are silent and maybe shouldn't be.
Some(empty set), warms nothing, prints0 of 0 native pipelines on diskand exits 0. Most likely the user pointed at the wrong file, so I'd make this an error or at least a warning.--used --route-filetakes the intersection (pipeline_in_scope,warm.rs:69). With a route file of two unused graphics keys that gave0 of 0and no message, and the empty-early note is suppressed whenever a route file is given (warm.rs:197). The description says the route file warms "strictly the listed subset", which reads as if--usedis ignored. Either reject the combination in clap withconflicts_with, or say in the help text that it's an intersection.On safety, the scoped repair passes a subset of the same container ranges to the unchanged
on_diskandprecompileas main. The diff adds no removal of its own. The only deletion on that path is the existing one inshader_cache.rs(cached_by, around line 304 and line 324), which drops a stale or unreadable entry for the one shader being translated and writes it again. That was already there and only touches the shader in hand, so scoping makes it touch fewer files, not more.pipeline_shader_hashesandcompute_indiceswalk the file with the samewalk_pipelinesaswarm_catalog, so the indices line up. The hash is the same blake3 of the container thatnote()writes into both catalogue files.The repair scope is still a behaviour change worth a sentence in the description.
./run.sh warmpasses--used, and on main that repaired every known shader on each run when--limitwasn't given. Now it only repairs the shaders of pipelines still left to make (warm.rs:234), and nothing at all once everything in scope is native. If play time relies on the full repair leaving every translation present, run.sh users lose that. If it doesn't, this is fine. Separately,--used --limit Nused to skip repair and now repairs for those N, which looks better to me.Compute parity with boot is close but not exact. Boot only preloads a compute pipeline when
of_builderis false (pipeline.rs:758).of_builder(pipeline.rs:299) matches single compute shaders whose DXIL has spilled programs.compute_indices(known.rs:406) takes every entry whose graphics flag is 0, so it includes those as well, and--usedends up a small superset of what boot starts early. That's harmless and probably wanted, but "matching boot-time make::early()" isn't quite accurate.batch_chunk_size(warm.rs:134) also changes default full runs whenever the total is underjobs * 1024. I found nothing else inrun_batchestied to the old 256, and resume slices bymade, so smaller chunks look fine. Thebatch_chunk_size(100, 0) == 100test case can't happen in practice, becausejobsgoes through.max(1)before it gets there.cargo build -p victorysucceeds.cargo test -p victorypasses 30 on the PR against 27 on main, so the three newwarm::testspass and the module is 7 of 7. Run single-threaded,pipeline::known::testsis 6 of 6, including the newcompute_indices_and_route_scoped_shader_ranges.A full
cargo test -p victory-gpudies with an access violation partway through on both main and the PR, at a different point in each of my two runs. The same four GPU tests (indirect::tests::host_list_*andpipeline::host::tests::*_loads_*) fail on both before the crash. The PR run also listedwatch::tests::a_write_opens_the_view_it_goes_throughas failed, but main's run crashed before reaching it. Rerun single-threaded, that test passes on the PR, andwatch::tests::the_rest_of_the_one_asking_has_a_number_of_its_ownfails on both main and the PR. The PR doesn't touchwatch, so I don't think any of this comes from it.clippy with
--all-targetsonvictoryandvictory-gpugives the same warnings as main. The only difference is the existingunwraponnativemoving from line 219 to line 342. The newselect_pipelinesavoidstoo_many_argumentswith an#[allow]. A small struct for the filter inputs would read better than twelve positional arguments, three of themHashSet<&str>side by side, but that's a style call.I didn't test any real warm with worker processes, real pipeline compiles or driver cache writes. I also didn't run shader repair against a real
known-shaders.bin, the post-warm check with artifacts actually on disk, run.sh itself, Wine or Linux, or timings for the chunk size change.AI-assisted: yes
511c197786tob6b0b3467d@chefulano on GitHub · 2026-12-05 20:22 UTC · original
Pushed a follow-up commit rebased onto current
main(a5c6484) addressing every actionable review point from @Kal0s-design:parse_route_keys()now strips a leading\u{feff}before iterating lines (covered by a new CRLF + BOM unit test for both comment-first and key-first files), and the--route-fileread error now includes(expected UTF-8 text)for PowerShell UTF-16 redirects.parse_route_keys()now returns an error when zero keys are parsed instead of silently exiting 0 with0 of 0.--used --route-fileconflict: Marked--route-filewithconflicts_with = "used"in clap so the CLI matches the documented behavior ("strictly the listed subset") rather than silently intersecting.select_pipelines()filter inputs intoSelectInputs<'a>(dropping#[allow(clippy::too_many_arguments)]), added a short comment notingnativeis currently alwaysSome(...)onmain, and updated the PR description to clarify unconditional--usedno-op behavior onmain, thecompute_indicessuperset (of_buildercompute entries), and scoped shader repair on./run.sh warm(warm --used).Verified on
a5c6484:cargo xtask policy(368 files ok),policy::tests(7/7),switches::documented_switches_are_read(1/1),cargo check+cargo clippy --no-deps(0new warnings),warm::tests::(7/7),pipeline::known::tests::(6/6).@tevanc14 on GitHub · 2026-12-05 22:52 UTC · original
I independently validated
--route-fileon an RX 6800 XT with Proton Experimental. I built the PR head (b6b0b34) and a local merge intomainat8c4e663, then ranvictory.exe warm --jobs 4 --route-file downtown-keys.txtfrom copies of the same starting cache. The route file listed 422 pipeline keys collected from earlier downtown runs.Both builds produced exactly those 422 new native PSOs out of a 94,204-entry catalog, with zero refusals and zero worker failures. All 422 PSOs matched the benchmark's prepared files byte for byte. The local merge added 285 MiB of PSOs and about 402 MiB total including shader and Mesa caches. Preparation took about 85 seconds with four workers. Rerunning it queued zero jobs and verified all 422 artifacts.
To measure the effect of the prepared artifacts, I ran the same unmodified
8c4e663gameplay executable twice per cache, alternating in original → downtown → full → full → downtown → original order. Each run covered a full fixed downtown lap at 1920×1080 with ray tracing off, with about 330 seconds measured after a 30-second settle. Automatic warm-up was disabled at launch so each run started with its assigned cache.The downtown subset gave a similar average FPS to full preparation and captured most of the process-RAM and 1% low improvement on this route. Full preparation cut first-use misses further and added 6.95 GiB to the starting cache. The gameplay figures compare cache contents using the same executable. The direct PR test above verifies that the CLI reproduces the downtown PSOs locally.
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.