bazel-contrib / rules-template

A template for creating a new Bazel ruleset
Apache License 2.0
75 stars 20 forks source link

Don't use --repository_cache with GitHub actions cache #76

Closed aherrmann closed 1 year ago

aherrmann commented 1 year ago

The template defined in this repository and the corresponding GitHub actions configuration configure a --repository_cache to be cached with the GitHub actions cache. However, in my experience, fetching artifacts from the GitHub actions cache is often slower than fetching the artifacts directly from the internet in a GitHub actions run.

I've set up a simple example to illustrate this: In that case we use Bazel to download binaries of varying sizes and either use Bazel's repository cache feature to cache on GitHub actions cache or not. In the case of a download artifact of about 200MiB in size the full build step (including the download of Bazel itself) takes about 9s. However, with the GitHub actions cache enabled the download of the cache alone takes 1m6s. According to the cache action's outputs the download itself is fast at somewhere around 130MB/s, but the overall step duration brings this down to about 3MB/s. (Perhaps the decompression takes so long.)

On smaller sized artifacts the difference vanishes, the GitHub actions run takes about the same time whether the repository cache is used or not. So, in such cases the repository cache doesn't add much value, but only drives up the storage used.

This begs the question, should we recommend a repository cache in the rules template, or is it better to remove it from the example CI configuration?

(Relevant changes https://github.com/bazel-contrib/rules-template/commit/d017a1dcd811bbd25514024776547e5f0b9782c2 and https://github.com/aherrmann/.github/commit/07b63687e79bedab3ff6d184f2003d6aae9421e2)

illicitonion commented 1 year ago

+1 - I don't find repository caches make sense on CI (they often do for end-users, but that's probably a per-user config not a per-repo one).