translate --cache on a Mac: translate the containers earlier runs kept #327
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/327"
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 LakshanSivakumar/Native-Victory-macOS. Originally posted by ItsMariusBC on 2026-11-27T11:43:56Z.
What this changes
On a Mac,
victory translate --cachenow warms the native host's shader cache. Before, it stopped with "translate needs a Windows host for now".There is no issue for this yet, so it is a draft: I can open one and claim it if you want the change.
Why not from the game's files, as on Windows. The title hands the native host pieces (code, metadata;
graphics_containers,compute_container) and the container is put together in the host, so a container found in the shader archive is other bytes with another cache key. I tried the Windows walk first: of 25,985 distinct containers found in the files, 58 were ones a run had cached.What it does instead.
<cache>/native-shaders/containers(prewarm::keep, called fromShader::native). It sits besidefirst-binds.txt, outside the build folders, so it outlives a changed translator.victory translate --cache(no paths) translates the kept containers on every core, throughnative::shaders::translate, the call a run's prewarm makes. A file whose bytes are not its name's is counted and skipped.Cost, and a question. A run to the world keeps 21,596 containers, 322 MB, for every user. There is no switch of its own;
VICTORY_NO_SHADER_CACHEturns it off with the cache. Say if you would rather have it opt-in.Not covered: the translations a run asks for by how a shader is drawn (rectangle lists, extra parameters, thread counts), and Metal libraries and pipelines.
--pipelinesstays Windows-only.shader_cache.rs,victory-shaderandCargo.lockare untouched, so no cache is invalidated.How it was tested
cargo test -p victory-hle -p victory -p victory-gpu -p xtask(arm64 host), and-p victorywith--target x86_64-apple-darwin. Not run:-p victory-loader.cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings, andcargo xtask policyAll of that was on main
c1b9587. Main has moved since; the branch merges without conflict, and I have not rerun the gates on the merge.New tests:
warm::tests::the_warm_up_translates_what_a_run_kept(it fails with the translation taken out) andprewarm::tests::kept_containers_read_back_and_damaged_ones_do_not.Game, Apple M5 Pro, 24 GB, Series S:
shaders_cached=21564 shaders_translated=2at frame 1920 (VICTORY_TRACE_SHADER_CACHE=1), and its prewarm was done 19 s in.Checklist
VICTORY_*variable and documented (none added; the warm-up is documented in docs/native-host.md)Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by reefbluesky on 2026-11-27T13:15:07Z.
A tester's data point for this, from an M2 Pro (10 cores: 6 performance, 4 efficiency), 32 GB, macOS 27.2, series-x.
Why keeping the containers outside the build folders helps. I rebuild after each merge to main. This morning that made four build folders under
native-shaders/(6909d8c1, dbde7124, d09afb17, 714755fc: three main commits up toc5d7f4dand one local build of main + #250 #296 #318 #335), each about 580 MB and each filled from nothing by a run to the world. With this PR,victory translate --cacheafter each rebuild would refill them before the first run.A question about finding the code ahead of any run. nxnative (the Switch port, MIT) translates every shader before the first run: it scans every file of the game, finds each shader by a hash of its control section and its code, and looks it up by that key at run time (docs/agents/04-graphics.md). Your finding that only 58 of 25,985 file containers match what a run caches says the assembled container cannot be the key here. Could the key be the code part alone? If the code bytes the title passes (
graphics_containers,compute_container) can be found as they are in the shader pack, a first run could start with most translations done, and only the metadata the title builds at run time would be missing. I have not checked whether the code is stored unchanged in the pack.I can run this branch here and report the kept container count and the time
translate --cachetakes on an M2 Pro if that helps.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T16:15:24Z.
Merged in
4cf84c83. The containers stay on by default with the cache, as you have it. Before pushing I ran the tests (native arm64), Windows clippy, the policy check, a release build, and one headless game run of the exact tree (170 s, Series S): menus at 30 fps, the world entered at about 81 s and kept presenting to the end at about 1 frame a second, 0 GPU errors, no crash. I did not run translate --cache myself. Thanks.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by reefbluesky on 2026-11-27T18:35:09Z.
Ran
victory translate --cacheon an M2 Pro (10 cores, 32 GB, macOS 27.2), mainb998bb65.translate --cachetook 0.5 s (all cached).VICTORY_CACHE_DIRholding only those containers): 106.6 s wall, 835 s CPU, 1.16 GB peak RSS; 19,306 translated, 2,266 refused, 0 damaged, 712 MB of translations.In the run itself the same translations came at about 1,000 a minute with the world at about 0.9 fps, so two minutes ahead of the first run replace about twenty minutes of stalls. Not measured yet: a run right after the warm-up.