From b3cd1c5215c70b37bf0e6856035a44a462a03303 Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Tue, 7 Mar 2023 12:02:57 +0100 Subject: [PATCH] Manually prune CI ccache. Since ccache in Cirrus currently does not preserve timestamps the timestamp-based cache pruning implemented by ccache likely would just remove random files. To work around this, this patch implements a manual pruning step. This step runs after the build so that at least the files used in the build should have their timestamps updated. We can then force eviction of some of the unused files from the cache by cleaning the cache with a size less than the maximum cache size. --- .cirrus.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.cirrus.yml b/.cirrus.yml index 43b2284710..7c66c3ac1b 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -113,6 +113,9 @@ ci_template: &CI_TEMPLATE type: text/html cache_statistics_script: ccache --show-stats + ccache_prune_script: + # Evit some of the cached build artifacts not used in this build. + CCACHE_MAXSIZE=${ZEEK_CCACHE_PRUNE_SIZE} ccache -c env: CIRRUS_WORKING_DIR: /zeek @@ -148,6 +151,11 @@ env: CCACHE_MAXSIZE: 1000M CCACHE_MAXFILES: 20000 + # Size to use when manually pruning the cache below. This size should be + # roughly `CCACHE_MAXSIZE - `. This works around + # https://github.com/cirruslabs/cirrus-ci-agent/issues/277. + ZEEK_CCACHE_PRUNE_SIZE: 700M + # Increase this to flush the ccache cache. Mainly useful until there's # a solution for the mtime pruning above. ZEEK_CCACHE_EPOCH: 2