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

Closed
opened 2026-11-27 12:23:22 +00:00 by derz92 · 3 comments
derz92 commented 2026-11-27 12:23:22 +00:00 (Migrated from github.com)
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by derz92 on 2026-11-27T12:23:22Z.


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.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6646353966 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/334). Originally posted by [derz92](https://github.com/derz92) on 2026-11-27T12:23:22Z. --- ## 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 commented 2026-11-27 12:23:26 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by derz92 on 2026-11-27T12:23:26Z.


/claim

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7218185075 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/334#issuecomment-7218185075). Originally posted by [derz92](https://github.com/derz92) on 2026-11-27T12:23:26Z. --- /claim
github-actions[bot] commented 2026-11-27 12:23:48 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-27T12:23:48Z.


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

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7218193047 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/334#issuecomment-7218193047). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-27T12:23:48Z. --- Claimed by @derz92. Open a draft pull request with `Refs #334` in its description within 24 hours, or the claim expires.
LakshanSivakumar commented 2026-11-28 00:35:41 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-28T00:35:41Z.


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 (#342, 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.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7231036826 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/334#issuecomment-7231036826). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-28T00:35:41Z. --- 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 (#342, 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.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
LakshanSivakumar/Native-Victory-macOS#334
No description provided.