ci: use ccache to cache compiler output #2942
Merged
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.
This PR adds ccache to the CI scripts, leveraging CircleCI's save_cache/restore_cache to persist the cache between runs.
Leaving as draft until #2941 is merged.Effectiveness
Without cache:
With hot cache:
The Windows build takes about 50% less time, and all builds complete in around 30 minutes instead of over an hour.
Qt Cache
We are currently using a few gigabytes of cache for Qt, which is OK when the cache hits:
But when it misses, as it so often does, there is a +119% slowdown as it compresses and uploads Qt:
Since ccache is capped to 500MiB and is much more important, I've chosen to remove the Qt cache so it doesn't cause the ccache cache to be evicted.
We may be able to re-enable the Qt cache in the future if we think it's useful and we are able to store
~/.ccache
somewhere else, e.g. using sccache and an S3/R2 backing store.Limitations
Cross-job ccache is suboptimal right now because some jobs use different working directories, and the relative paths to header files matter.edit: I did some local testing, and it seems like most files get a preprocessor-mode cache hit regardless of build directory. It's not as efficient as a direct hit, but direct hits are difficult to achieve for a project when it is top-level in one case and not in another.