Skip to content

ccache GitHub action generates excessive caches #113858

Closed

Description

@encukou

The ccache action speeds up *nix builds considerably (though not enough that we could do without it).
The issue with it is that every build uploads a new cache, filling up our quota very quickly. GitHub removes caches that weren't used recently, but ccache is aggressive enough that it's crowding out smaller, useful entries. Specifically, the action to mark stale-PRs (which only runs every once in a while), has its state removed before the next run.

  • Solve this in main. (It's hard to test locally, iterating on main seems to be the best way to do it. Sorry for the noise!)
  • Backport to bugfix branches

Linked PRs

Activity

  1. self-assigned this
    on Jan 9, 2024
  2. encukou commented on Jan 9, 2024

    @encukou
    MemberAuthor

    It's not possible to change the contents of an existing cache, so for this to be useful we need to save a new one occasionally.
    With #113859 it should save only on merged commits, not in-progress PRs. Hopefully that'll be enough.

  3. hugovk commented on Jan 9, 2024

    @hugovk
    Member

    Another idea is to set a max-size, but the above PR looks like a good thing to try first 👍

    https://github.com/hendrikmuhs/ccache-action/blob/4cb35b2ff44ce57e1f5f5221e26bd8fefcfe41d0/action.yml#L15-L17

  4. encukou commented on Jan 9, 2024

    @encukou
    MemberAuthor

    Some napkin math suggests that this should be enough, at least outside sprints. Which is good enough :)
    I don't think we want to delete the caches manually, so we'll be at GitHub's 10GiB limit regardless of max-size.

    I plan to merge tomorrow morning (EU time) so I have the whole day to watch the effect (and revert if needed).

  5. added a commit that references this issue on Jan 10, 2024
  6. erlend-aasland commented on Jan 11, 2024

    @erlend-aasland
    Contributor

    Is there more to do here? (I accidentally clicked "Close with comment" iso. "Comment"; so, please reopen if there is more to do here 😄)

  7. encukou commented on Jan 11, 2024

    @encukou
    MemberAuthor

    Yup, there is :)

  8. 20 remaining items

  9. encukou commented on Jan 24, 2024

    @encukou
    MemberAuthor

    Yeah, the current approach could barely get us to where we want to be. IMO it's time to cut the losses and try the other approach.
    IMO, the best direction is to put branch names in the cache names, and write logic to clear all ccaches but the freshest one for each branch.

  10. hugovk commented on Jan 24, 2024

    @hugovk
    Member

    Sure, sounds good.

    From the other side of the fence, we could adjust the stale.yml cron to run more often than daily: https://github.com/python/cpython/blob/main/.github/workflows/stale.yml

  11. added 3 commits that reference this issue on Feb 11, 2024
  12. hugovk commented on Mar 12, 2024

    @hugovk
    Member

    Please see #116636 to process the stale issues twice per day, which hopefully will keep its cache file fresh and prevent deletion.

  13. hugovk commented on Mar 15, 2024

    @hugovk
    Member

    Twice per day isn't enough, let's try 4x: #116857.

  14. hugovk commented on Mar 17, 2024

    @hugovk
    Member

    4x doesn't help either. The problem now isn't that the stale cache has been deleted (for example, there's ~30 hours of caches available right now), but https://github.com/actions/stale only checks the first page of results from the cache API!

    For example, https://api.github.com/repos/python/cpython/actions/caches only has ~3 hours of caches at the moment.

    Upstream bug report is at actions/stale#1136

  15. added 3 commits that reference this issue on Sep 2, 2024
  16. changed the title [-]ccache GitHub action generates excessive caches[/-] [+]`ccache` GitHub action generates excessive caches[/+] on Sep 26, 2024
  17. added
    infraCI, GitHub Actions, buildbots, Dependabot, etc.
    on Sep 27, 2024
  18. hugovk commented on Jun 19, 2026

    @hugovk
    Member

    Fixed by removing ccache via #139596.

    Now about half the cache is made up of CodeQL caches, and I think we only need 1-2 (per language), but that's another issue.

    https://github.com/python/cpython/actions/caches?query=key%3Acodeql+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

infraCI, GitHub Actions, buildbots, Dependabot, etc.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions