Repository navigation
fix(build-cache): list the generation prefix as the first restore key (#682) - #686
Merged
Merged
Conversation
…#682) #685 passed `<exact>-g` as the primary key, but @actions/cache checks the primary for an exact match only. The next restore key, the bare `<exact>`, then exact-hit the stale bare entry: FastLED/fbuild run 44726574726 restored it (727.9 MB) instead of the 770 MB generation run 44718162695 saved, and missed 64/35/35 units again. restoreKeys is now [`<exact>-g`, `<exact>`, ...job fallbacks], so the newest generation is prefix-matched first and the bare entry is the fallback. The primary stays `<exact>-g`, which names no real entry and always misses; a bare primary would exact-hit the existing stale entry ahead of every restore key. The tests now assert restoreKeys[0] is the `-g` prefix, that the primary is not the bare key, and simulate GitHub's matching order. Local-Gate: v1 tree=1972933c74c8edc4b3bb4bb255dfffce3668d0fd secs=72 lanes=lint:run,typecheck:run,tests:run Ci-Attestation: {"at":1795177396,"gate":"general/all/lint","host":"linux-x86_64","key":"47a5abeb1acd","lane":"lint","parents":["b52b02106d9d01a29550cd33861bdd5e9114ba3f"],"secs":0,"stamp":"3ac0341d8e1e68abb1408cb6cc9fcb2f","tree":"1972933c74c8edc4b3bb4bb255dfffce3668d0fd","v":1,"via":"run"} Ci-Attestation: {"at":1795177396,"gate":"general/all/typecheck","host":"linux-x86_64","key":"0185c533ee08","lane":"typecheck","parents":["b52b02106d9d01a29550cd33861bdd5e9114ba3f"],"secs":4,"stamp":"a0b6f0c6eb49db718acd4f506d8edf26","tree":"1972933c74c8edc4b3bb4bb255dfffce3668d0fd","v":1,"via":"run"} Ci-Attestation: {"at":1795177396,"gate":"general/linux-x86_64/test","host":"linux-x86_64","key":"18d3511b76db","lane":"tests","parents":["b52b02106d9d01a29550cd33861bdd5e9114ba3f"],"secs":67,"stamp":"2085bd697ae84e8ac2a28ec6a732f53b","tree":"1972933c74c8edc4b3bb4bb255dfffce3668d0fd","v":1,"via":"run"}
zackees
added a commit
that referenced
this pull request
Nov 20, 2026
GitHub's cache lookup exact-matches the primary key and every restore key before it tries any prefix. #686's single request, [`<exact>-g`, `<exact>`, ...fallbacks], therefore still exact-hit the bare entry: FastLED/fbuild run 44790566297 restored `...-s57d57d7814452b77` while generation `...-g44767084261` existed, and missed 64/30/30 units again. Restore now makes up to two lookups (`buildCacheRestoreRequests`): 1. `<exact>-g` only. Nothing is saved under that literal name, so the exact pass misses and the prefix pass returns the newest generation. 2. Only on a miss: the pre-#685 request, bare `<exact>` plus the job fallback. It exact-hits this lockfile's bare entry, which is warm. Dropping the bare key and relying on the job prefix alone would let a newer generation of another lockfile beat this lockfile's bare entry; that donor restore is not warm, so the run would never start its own generation. The simulation tests now model GitHub's real order (exact pass over all keys, then prefix per restore key, newest first) as well as the documented order, and include the bare + g1 regression and the other-lockfile case. Local-Gate: v1 tree=cb1a7ccac16dd739fba43be6e9d8c25b94ea4ba9 secs=182 lanes=lint:run,typecheck:run,tests:run Ci-Attestation: {"at":1795206848,"gate":"general/all/lint","host":"linux-x86_64","key":"47a9b02285f9","lane":"lint","parents":["1e1ae41b04c5a0b050e637d0a4d3f8cd30bfb83e"],"secs":0,"stamp":"0cf6a1d079c03e2e4952d6cfb22db7c2","tree":"cb1a7ccac16dd739fba43be6e9d8c25b94ea4ba9","v":1,"via":"run"} Ci-Attestation: {"at":1795206848,"gate":"general/all/typecheck","host":"linux-x86_64","key":"f05ee26cef42","lane":"typecheck","parents":["1e1ae41b04c5a0b050e637d0a4d3f8cd30bfb83e"],"secs":6,"stamp":"235d7b0ea75500b50cde5575fdcefbef","tree":"cb1a7ccac16dd739fba43be6e9d8c25b94ea4ba9","v":1,"via":"run"} Ci-Attestation: {"at":1795206848,"gate":"general/linux-x86_64/test","host":"linux-x86_64","key":"34676ca279e3","lane":"tests","parents":["1e1ae41b04c5a0b050e637d0a4d3f8cd30bfb83e"],"secs":174,"stamp":"23e60f65d68bd73dfc11afe501e6c5a8","tree":"cb1a7ccac16dd739fba43be6e9d8c25b94ea4ba9","v":1,"via":"run"}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes generation restore from #685 (part of #682).
Problem
#685 passed
<exact>-gas the primary key, with restore keys[<exact>, ...job fallbacks].@actions/cachechecks the primary key for an exact match only, and checks each restore key for an exact match before its newest prefix match. So<exact>-gmatched nothing, and the bare<exact>then exact-hit the stale bare entry.FastLED/fbuild evidence: run 44718162695 saved a generation (
warm hit ... compiled 256 new unit(s); saving generation ...). The next run, 44726574726 (job 136255413377), loggedCache hit for restore-key: ...-s57d57d7814452b77, which is the bare key (727.9 MB) rather than the 770 MB generation. It then missed 64/35/35 units again and saved another generation.Fix
buildCacheRestoreRequestnow returnsrestoreKeys: [<exact>-g, <exact>, ...job fallbacks]:<exact>-gcomes first. No entry is ever saved under that literal name, so it prefix-matches and the newest generation wins.<exact>comes next and exact-hits the bare entry when no generation exists yet.The primary stays
<exact>-g, which names no real entry and always misses. I did not make the primary the bare<exact>: that entry exists in every affected repo, and an exact primary hit beats every restore key, so the bare entry would keep winning. A cold run with only the bare entry still restores it through the second restore key, andisWarmBuildCacheMatchtreats that as warm.Nothing else depends on the old shape. The ancestor (
selectedKey) path restores its own key with no restore keys. The ancestor-miss fallback uses the samelegacyRequest.isWarmBuildCacheMatchonly compares the matched key.Eviction under a read-only token
could not delete superseded generations ... (deleted=0 failed=2)is expected when the token lacksactions: write, and the warning stays. With this fix, restore always reads the newest generation, so older generations and the bare entry are never read again. They are the least recently used entries in the family, and GitHub evicts them first (after 7 days without access, or sooner under the 10 GB repository cap). Until then, each warm run that compiles adds about 0.77 GB. Grantingactions: writeto the Dylint job keeps exactly one generation.Tests
__tests__/cache-keys.test.tsnow asserts thatrestoreKeys[0]ends with-g, that the primary is not the bare key and is not a generation key, and that the full order is correct. A new test simulates GitHub's matching order: the newest generation wins over older generations and the bare entry, the bare entry wins when it is alone, and a donor is used when nothing else exists. Both tests failed against #685's shape.npm run typecheck,lint,test:select-checkandnpm testpass (1167 pass, 1 skipped).dist/was rebuilt and the local gate stamped HEAD.Refs #682, #685.