ci(cache): save GitHub Actions caches only from main - #698
Open
balajinvda wants to merge 1 commit into
Open
Conversation
The repository is at 9.66 GB of its 10 GB cache limit, and most of it is copies no one can read. GitHub scopes a cache entry to the ref that wrote it, so a pull_request or merge_group run writes an entry only that ref can restore: used once, then holding quota until evicted. dependency-docs-bazel held 5.59 GB across four entries, three of them the same key written from main, a PR ref, and a merge-queue ref. That evicts the Bazel build caches, which are what actually make CI fast. Split every actions/cache use into restore + save and gate the save to pushes on main. Runs on any ref can still restore from the default branch, so no reuse is lost. This is the read/write split the remote cache already uses in tools/ci/bazel-cache-upload-mode. Also give the dependency-docs cache a restore-keys prefix; without one, any lock bump meant a fully cold build. Co-authored-by: Balaji Ganesan <bganesan@nvidia.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe workflows now restore Bazel-related caches for all events and save them only after successful pushes to ChangesCache lifecycle controls
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
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.
Why
The repo is at 9.66 GB of its 10 GB Actions cache limit. GitHub scopes a
cache entry to the ref that wrote it, so a
pull_requestormerge_grouprunwrites an entry only that ref can ever restore — used once, then holding quota
until evicted.
dependency-docs-bazelalone held 5.59 GB across four entries, three of themthe same key written from three refs:
refs/heads/mainrefs/pull/693/mergegh-readonly-queue/main/pr-649Those copies evict the Bazel build caches, which are the ones that actually make
CI fast.
What changed
Every
actions/cacheuse is split intoactions/cache/restore+actions/cache/save, with the save gated to pushes onmain. Runs on any refstill restore from the default branch, so no reuse is lost. This is the same
read/write split the remote cache already uses in
tools/ci/bazel-cache-upload-mode.Also added a
restore-keysprefix to the dependency-docs cache; without one,any lock bump meant a fully cold build.
Testing
Both workflows parse; every restore has a matching save with identical
pathand
key; each save is gated to a main push and carries its restore's ownconditions (
precheck.skip, the byoo subtree guard). Verified with a script,not by eye. The quota effect can only be confirmed after this runs on main.
Summary by CodeRabbit