Only save rust cache on master - #1824
Open
emmanuelist wants to merge 1 commit into
Open
Conversation
Swatinem/rust-cache saves on every run, so each PR writes its own copy. Those entries run 0.1 to 1.5 GiB and account for 9.52 GiB of the 10 GB Actions cache quota, which is what evicts everything else and makes identical cache keys hit or miss depending on which PR ran last (payjoin#1131). Gate saving on master so PRs restore but do not write. This also gives master a cache for PRs to inherit, which it has never had: every entry in the repo is currently scoped to a pull request ref. Trade-off is that a PR changing the dependency tree gets a colder build until master picks the change up.
emmanuelist
requested review from
DanGould,
benalleng and
spacebear21
as code owners
August 18, 2026 23:47
Collaborator
Coverage Report for CI Build 32198642068Coverage remained the same at 86.718%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
benalleng
requested changes
Aug 19, 2026
benalleng
left a comment
Collaborator
There was a problem hiding this comment.
Upon giving this some more thought I think that maybe save-if is not the ideal approach at the moment. I think we need to look a little closer at the reason our caches are bloating so much to begin with first and then if it turns out 1.5Gb is unavoidable then we can take a look at this.
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.
Follow-up to the numbers in #1131.
Swatinem/rust-cachesaves on every run, so each PR writes its own copy of the buildcache. Those entries are large, and they are what actually fills the quota. Upstream
right now:
So rust-cache is sitting at about 94% of the quota on its own, and 4 of those 7
entries are scoped to PR refs. A PR can only restore from its own ref or from the
default branch, never from another PR, so those 4 are doing nothing for anyone else
while pushing everything else out. That is what makes identical cache keys hit or
miss depending on which PR ran last.
This gates saving on master, so PRs restore but do not write.
I tested it on my fork. The branch without this change accumulated 7 rust-cache
entries from its runs. The branch with it, after a full green run of the same
workflows, wrote 0, and CI came back green:
Two things worth knowing.
@benalleng you already said on #1131 that "for any PR that changes the dep tree it is
ok to not get the full benefit of caching", which is the main trade-off here, so I
went ahead on that basis. Shout if you meant something narrower.
There is a small transition cost. master currently holds 3 rust-cache entries, so
most PRs will still restore something straight away, but the jobs master has not run
recently will be cold until it does. rust.yml runs on push to master so that sorts
itself out on the first merge.
Happy to narrow this to rust.yml alone if you would rather keep the blast radius
small. Those 5 jobs are where the 1.4 to 1.5 GiB entries live, so they are most of
the benefit, and the FFI and release sites are much smaller.
Disclosure: co-authored by Claude Code.
Pull Request Checklist
Please confirm the following before requesting review:
AI
in the body of this PR.