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

Update CI ccache on every push to develop #2865

Merged
merged 2 commits into from
Jul 17, 2024

Conversation

mikee47
Copy link
Contributor

@mikee47 mikee47 commented Jul 17, 2024

Build times are increasing faster than I expected, so it's clear that to be effective the ccache needs to be kept up to date.
This needs to happen automatically so we can forget about it.

Github caching behaviour is to fail the save operation if a hit occurred on primary key.
In other words, a cache entry will never be overwritten (updated).
There is no provision for a cache update as such: actions/cache#342

The workaround is fairly easy though: break into discrete restore/delete/save steps.

Only the cache for the current branch is deleted, using the --branch option to gh action-cache delete.
This prevents pull requests from contributors with repo write access from deleting the main develop cache.

This table shows the intended progression of cache updates, starting from an empty cache:

Event Branch Restore Delete Save
PR feature/new - - feature/new
PR feature/new feature/new - -
Merge develop - - develop
PR fix/lwip develop - -
Merge develop develop develop develop

So always save if (event.branch == develop) or no cache hit

If cache hit occurred on primary key then cache save will fail.
This can lead to a stale cache pretty quickly.

Workaround is to break into discrete restore / delete / steps.
Only attempt to delete cache for develop
@slaff slaff merged commit c3d496b into SmingHub:develop Jul 17, 2024
46 checks passed
@mikee47 mikee47 deleted the feature/ci-cache-update branch July 17, 2024 12:32
@mikee47
Copy link
Contributor Author

mikee47 commented Jul 17, 2024

@slaff Still issues with caching:

  1. Library caching broken because I moved initialisation commands out of installers in Update windows installer #2859
  2. With 42 jobs, ccache file size limit of 500MB means they'd eventually grow to 21GB.

I'm working on fixes but not worth delaying release 5.2 for them.

@slaff
Copy link
Contributor

slaff commented Jul 17, 2024

I'm working on fixes but not worth delaying release 5.2 for them.

Don't worry, I'll wait.

slaff pushed a commit that referenced this pull request Jul 18, 2024
**Fix CI library caching**

#2865 broken library CI because:

- ccache initialisation commands never get executed to set ccache directory
- library ccache key must have toolchain in it

Fixed by removing the ccache commands from script and updating workflow `env` instead.
Just requires call to clear stats before building.

NB. This leads to a fair bit of duplication in all 3 workflow files. This is the simplest I can come up with for now.

**Simplify workflows**

Don't need the `Configure environment` step, just add values to `env`.

**Use explicit ccache path**

In testing was getting failures saving cache due to ccache not found.
Use explicit absolute path to ccache directory.

**Restrict ccache size**

The cache for each job will increase over time to hit 500MB.
Over 40 jobs that's 20GB and will cause cache thrashing.

Easy fix: ask ccache to evict anything older than 4 hours from ccache.
Do this before printing stats so we can see the resulting size.
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