ci: CCache churns through available space too quickly

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-hackers(at)postgresql(dot)org, Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>, Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Subject: ci: CCache churns through available space too quickly
Date: 2026-06-05 20:09:29
Message-ID: 7eugqon2ilnaq6yimtq7prtl5wlia43mhpmwlydzlw4u4wonaz@hh2fagz5bjuu
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I noticed that a handfull of CI runs already lead to exceeding the available
cache space. One can pay for more cache space, but I think the problem is
more that what we currently do doesn't work well.

With cirrus-ci all branches shared one cache, but that's not the case with
github actions. Except for being able to read caches from the default branch
(master in our case), other branches have completely separate cache
namespaces. That's probably the right call, safety wise, but makes our ccache
approach .. not great.

We should only upload a new cache when the ccache cache hit ratio of the
existing cache entry has gotten low.

We also chose the cache key unfortunately, so that if a branch name started
with the name of the default branch, followed by a -, we'd always end up using
the main branches cache.

The attached patch fixes these, and a few other problems. See commit message
for details. With it I see a lot less cache churn and therefore also a higher
hit rate once one has more than 2-3 branches.

I'm not entirely happy with the amount of per job repetition this has. While
staying within the confines of a single .yml file, I couldn't find a better
way to deal with that. We could move a fair bit of that complexity into a
separate file, using so called "composite actions". But that's a bit of
additional github actions specific stuff that one would be exposed to, so I'm
not sure we should go that way?

It would result in having only two references to ccache in each job (one
before the build, one after). Each of those could encapsulate a bunch of steps
defined in another file.

Thoughts?

Greetings,

Andres Freund

Attachment Content-Type Size
v3-0001-ci-Improve-ccache-handling.patch text/x-diff 12.7 KB
v3-0002-ci-fewer-tests.patch text/x-diff 1.1 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2026-06-05 20:12:05 Re: [PATCH] CI: Add a CPAN cache on Windows
Previous Message Jacob Champion 2026-06-05 19:38:41 Re: ci: Add MTEST_SUITES for optional test tailoring