Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find a better solution to caching on CI #58

Closed
clux opened this issue Jul 27, 2019 · 1 comment
Closed

find a better solution to caching on CI #58

clux opened this issue Jul 27, 2019 · 1 comment

Comments

@clux
Copy link
Owner

clux commented Jul 27, 2019

Problem

Currently it's annoying to clean up build caches on CI systems because:

  • cargo build just keeps adding stuff to your cache directory without cleaning up unused artefacts
  • cargo clean just cleans out everything

Thus any cache that follows the approach of:

  1. Load cache
  2. Cargo build
  3. Save cache

Will cause you to maintain a technically unbounded cache, and thus, step 1 and 3 will start taking more time than 2. (Have personally seen this happen after ~100 builds of not resetting a cache on shipcat).

Thus finding out a way to ensure the cache doesn't grow and require manual purging is useful.

There's a relevant cargo meta tracking issue for cargo cache improvements.

CI Suggestions

CircleCI recommends adding dynamic suffixes to your cache keys to force cache expiry. E.g.:

  • target-{{ checksum "Cargo.lock" } (every time you make a version or add new dep)
  • target.release-{{ .Environment.CACHE_VERSION }} (whenever you want to manually bump)

But neither are really that satisfactory. Fast release cadence makes the first basically useless (blank cache constantly), and the second requires manual intervention every now and then (cache too big constantly).

TravisCI has a only a manual option to clear your cache, and normally caches last for 28 days.

Related Tools

One alternative is: cargo-sweep, but this only cleans based on date AFAIKT, which feels like just kicking the can down the road because it'll cause you to rebuild more than you need if you just haven't bumped that dependency in a while..

Another alternative is cargo-cache, but this seems to be more for general gc-ing and probably won't solve the unbounded cache problem.

Tools that would solve this could potentially be bundled inside the build image if it doesn't bloat it too much.

@clux clux changed the title find a satisfactory solution to caching on CI find a better solution to caching on CI Jul 27, 2019
@clux
Copy link
Owner Author

clux commented Oct 2, 2021

The cache strategy on kube-rs with github actions is proving a bit better. No need to manually bump numbers, and the rust-cache action is proving excellent there.

Closing because CI caching issues is not really the purview of this repo, there are decent solutions, and my person TODO about finding a better alternative is now solved with github actions.

@clux clux closed this as completed Oct 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant