Shader cache key hashes the whole Cargo.lock: any dependency change makes the next launch cold #334

Closed
opened 2026-11-27 12:26:58 +00:00 by github-bot · 3 comments
Owner

@⁠derz92 on GitHub · 2026-11-27 12:23 UTC · original

Summary

victory-shader/build.rs folds the whole workspace Cargo.lock into VICTORY_SHADER_SOURCE_HASH, which keys the native shader disk cache (shader_cache::build). So adding or bumping a dependency anywhere in the workspace (an app crate, a test-only crate) invalidates every cached translation, about 16,000 shaders, even though the translator did not change. The next launch is then a cold start: the prewarm pool translates everything again for the first ~50 s, and the boot stutters (#332).

I hit this by adding one path dependency to apps/victory: the next run translated 3,483 shaders before the story load, against 0 on the run before.

Proposed change

Hash only what the translator is built from: its own sources and manifest, build.rs, the rustc version, and the Cargo.lock entries of the packages victory-shader depends on (its dependency closure), not the whole lock file. Bumping a crate the translator uses still changes the key. Changes elsewhere in the workspace no longer do.

I'd like to take this one and will send a PR.

**@⁠derz92** on GitHub · 2026-11-27 12:23 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/334) ## Summary `victory-shader/build.rs` folds the whole workspace `Cargo.lock` into `VICTORY_SHADER_SOURCE_HASH`, which keys the native shader disk cache (`shader_cache::build`). So adding or bumping a dependency anywhere in the workspace (an app crate, a test-only crate) invalidates every cached translation, about 16,000 shaders, even though the translator did not change. The next launch is then a cold start: the prewarm pool translates everything again for the first ~50 s, and the boot stutters (#332). I hit this by adding one path dependency to `apps/victory`: the next run translated 3,483 shaders before the story load, against 0 on the run before. ## Proposed change Hash only what the translator is built from: its own sources and manifest, `build.rs`, the rustc version, and **the `Cargo.lock` entries of the packages `victory-shader` depends on** (its dependency closure), not the whole lock file. Bumping a crate the translator uses still changes the key. Changes elsewhere in the workspace no longer do. I'd like to take this one and will send a PR.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 12:26:58 +00:00
Author
Owner

@⁠derz92 on GitHub · 2026-11-27 12:23 UTC · original

/claim

**@⁠derz92** on GitHub · 2026-11-27 12:23 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/334#issuecomment-7218185075) /claim
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-27 12:23 UTC · original

Claimed by @⁠derz92. Open a draft pull request with Refs #334 in its description within 24 hours, or the claim expires.

**@⁠github-actions[bot]** on GitHub · 2026-11-27 12:23 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/334#issuecomment-7218193047) Claimed by @⁠derz92. Open a draft pull request with `Refs #334` in its description within 24 hours, or the claim expires.
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-28 00:35 UTC · original

Thank you, and thanks to derz92 for the fix. The shader cache key now hashes only the lock entries of the packages victory-shader depends on, not the whole Cargo.lock (#343, on main), with unit tests in lock_tests.rs. I have not measured a cold start myself. Closing. Please tell me if adding an app-only dependency still makes the next launch cold on a6a58361.

**@⁠LakshanSivakumar** on GitHub · 2026-11-28 00:35 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/334#issuecomment-7231036826) Thank you, and thanks to derz92 for the fix. The shader cache key now hashes only the lock entries of the packages victory-shader depends on, not the whole Cargo.lock (#343, on main), with unit tests in lock_tests.rs. I have not measured a cold start myself. Closing. Please tell me if adding an app-only dependency still makes the next launch cold on a6a58361.
This discussion has been locked. Commenting is limited to contributors.
No description provided.