Bound nix cache size in FFI CI workflows - #1814
Conversation
|
Feel free to add this to other workflows in new commits. I would like to merge them all together in this PR. |
Coverage Report for CI Build 32272924268Coverage remained the same at 86.718%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
|
Added the rest of the workflows in three commits, so magic-nix-cache-action is out of Couple of things you should know before merging though. I got the attribution wrong in #1131. I had measured entry counts and then wrote as On One gap worth flagging: crates-release.yml doesn't actually get exercised by this PR. Disclosure: co-authored by Claude Code. |
|
We actually are modifying the nix cache workflow jobs unrelated to caching in #1819. Since that will greatly dedupe the caching steps you might want to rebase onto that once I merge it in.
Yeah once I read the config again I realized that it isn't what I thought
That's fine. We can always YOLO test at a later date. Likely worst case the cache fails for those. |
9971458 to
7e4b495
Compare
|
Rebased onto #1819. That collapsed most of this, since the nix setup now lives in Keys are scoped by Thanks for the steer on #1819, it's a much smaller change this way. |
benalleng
left a comment
There was a problem hiding this comment.
Unless there is a valid reason I am missing the rust jobs should also use this new setup-nix/action
There was a problem hiding this comment.
Any reason to not simply use the setup-nix/action job for these workflows as well instead of copying them?
There was a problem hiding this comment.
Agreed I guess I missed those in my refactor, they should use the shared nix setup action too.
magic-nix-cache-action writes one GitHub cache entry per nix store path, which churns through the Actions cache API and leaves over a thousand entries behind. Swap it for nix-community/cache-nix-action, which keeps the store as a single bounded entry per job, purging all but the newest. Point the rust jobs at the shared setup-nix action too, rather than repeating the install and cache steps inline, so there is one place to change this. Keys are scoped by `github.job` because jobs realise different store closures, and job ids are unique across the workflows that set nix up. Note this reduces entry count and churn but does not by itself free the cache quota: Swatinem/rust-cache accounts for 9.32 GiB of the 10 GB against cache-nix-action's 0.59 GiB. See payjoin#1131 for the numbers.
7e4b495 to
29b8e88
Compare

Follow-up to #1131, with the measurements in
#1131 (comment).
magic-nix-cache-actionwrites one GitHub cache entry per nix store path. Upstreamcurrently holds 1031 entries totalling 10.46 GiB against a 10 GB quota, of which only 15
are the
Swatinem/rust-cacheentries the jobs actually reuse. GitHub then evictsleast-recently-used entries, so identical keys hit or miss depending on which PR ran last.
This swaps the four FFI workflows to
nix-community/cache-nix-action,which stores the nix store as one bounded entry per workflow per runner OS, with
purgeon so only the newest survives per key.I tested it on my fork before opening this. All three testable FFI workflows passed
(csharp is excluded from the fork test only because its unrelated
build-nuget-nativecross-compile matrix would have run too):
The 6 entries this action created, one per workflow per OS:
With csharp included that is 8 entries rather than the thousands magic-nix-cache
produces, and CI runs were green so
gc-max-store-size: 1Gis not too tight for thesedevshells. The number is easy to tune if you'd rather trade quota for fewer GC passes.
Fork runs: https://github.com/emmanuelist/rust-payjoin/actions?query=branch%3Aci-bounded-nix-cache
I left
rust.yml,format.ymlandcrates-release.ymlonmagic-nix-cache-actionsothis can be judged on the FFI workflows first. Happy to convert those too, or to close
this if you'd rather go a different way (dropping nix caching from the FFI jobs entirely,
or moving it off the GitHub quota to FlakeHub or Cachix were the other options I listed
in #1131).
Disclosure: co-authored by Claude Code.