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

ci: use ccache to cache compiler output #2942

Merged
merged 3 commits into from
Sep 6, 2024
Merged

ci: use ccache to cache compiler output #2942

merged 3 commits into from
Sep 6, 2024

Conversation

cebtenzzre
Copy link
Member

@cebtenzzre cebtenzzre commented Sep 5, 2024

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:
Screenshot 2024-09-05 at 18 48 42

With hot cache:
Screenshot 2024-09-05 at 18 49 15

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:
Screenshot 2024-09-04 at 14 52 31

But when it misses, as it so often does, there is a +119% slowdown as it compresses and uploads Qt:
Screenshot 2024-09-04 at 14 52 49
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.

Signed-off-by: Jared Van Bortel <[email protected]>
Signed-off-by: Jared Van Bortel <[email protected]>
@cebtenzzre cebtenzzre merged commit 1aae4ff into main Sep 6, 2024
4 of 18 checks passed
@cebtenzzre cebtenzzre deleted the ci-ccache branch September 6, 2024 20:09
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

Successfully merging this pull request may close these issues.

2 participants