From d3b858d36362cf5747ab7de0086289d233092e6c Mon Sep 17 00:00:00 2001
From: Justin Pryzby <pryzbyj@telsasoft.com>
Date: Sun, 3 Apr 2022 00:10:20 -0500
Subject: [PATCH 13/21] cirrus/ccache: disable compression and show stats

ci-os-only: linux, windows

ccache since 4.0 enables zstd compression by default.

With default compression enabled (https://cirrus-ci.com/task/6692342840164352):
linux/debian/bullseye has 4.2; 99MB cirrus cache; cache_size_kibibyte	109616
macos has 4.5.1: 47MB cirrus cache; cache_size_kibibyte	52500
freebsd has 3.7.12: 42MB cirrus cache; cache_size_kibibyte	134064
windows has 4.6.1; 180MB cirrus cache; cache_size_kibibyte	51179
todo: compiler warnings

With compression disabled (https://cirrus-ci.com/task/4614182514458624):
linux: 91MB cirrus cache; cache_size_kibibyte	316136
macos: 41MB cirrus cache; cache_size_kibibyte	118068
windows: 42MB cirrus cache; cache_size_kibibyte	134064
freebsd is the same

The stats should either be shown or logged (or maybe run with CCACHE_NOSTATS,
to avoid re-uploading cache tarball in a 100% cached build, due only to
updating ./**/stats).

Note that ccache 4.4 supports CCACHE_STATSLOG, which seems ideal.
---
 .cirrus.yml | 34 ++++++++++++++++++++++++++++++----
 1 file changed, 30 insertions(+), 4 deletions(-)

diff --git a/.cirrus.yml b/.cirrus.yml
index 50a34373647..1d16594803f 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -16,7 +16,9 @@ env:
   # Useful to be able to analyse what in a script takes long
   CIRRUS_LOG_TIMESTAMP: true
 
-  CCACHE_MAXSIZE: "250M"
+  CCACHE_MAXSIZE: "500M"
+  CCACHE_NOCOMPRESS: 1
+  #CCACHE_STATSLOG: ccache.log
 
   # target to test, for all but windows
   CHECK: check-world PROVE_FLAGS=$PROVE_FLAGS
@@ -110,7 +112,11 @@ task:
         CXX="ccache c++" \
         CFLAGS="-Og -ggdb"
     EOF
-  build_script: su postgres -c "gmake -s -j${BUILD_JOBS} world-bin"
+
+  build_script: |
+    ccache --zero-stats
+    su postgres -c "gmake -s -j${BUILD_JOBS} world-bin"
+    ccache --show-stats
   upload_caches: ccache
 
   # The use of script avoids make -Otarget complaints about fcntl() on
@@ -206,7 +212,11 @@ task:
         CFLAGS="-Og -ggdb -fsanitize=undefined,alignment -fno-sanitize-recover=all" \
         CXXFLAGS="-Og -ggdb -fsanitize=undefined,alignment -fno-sanitize-recover=all"
     EOF
-  build_script: su postgres -c "make -s -j${BUILD_JOBS} world-bin"
+
+  build_script: |
+    ccache --zero-stats
+    su postgres -c "make -s -j${BUILD_JOBS} world-bin"
+    ccache --show-stats
   upload_caches: ccache
 
   test_world_script: |
@@ -325,7 +335,11 @@ task:
       \
       LLVM_CONFIG=${brewpath}/llvm/bin/llvm-config \
       PYTHON=python3
-  build_script: gmake -s -j${BUILD_JOBS} world-bin
+
+  build_script: |
+    ccache --zero-stats
+    gmake -s -j${BUILD_JOBS} world-bin
+    ccache --show-stats
   upload_caches: ccache
 
   test_world_script: |
@@ -422,7 +436,9 @@ task:
   build_script:
     #- ccache --clear
     - vcvarsall x64
+    - ccache --zero-stats
     - msbuild %MSBFLAGS% pgsql.sln
+    - ccache --show-stats
 
   always:
     upload_caches: ccache
@@ -537,7 +553,9 @@ task:
         ${LINUX_CONFIGURE_FEATURES} \
         CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang"
       make -s -j${BUILD_JOBS} clean
+      ccache --zero-stats
       time make -s -j${BUILD_JOBS} world-bin
+      ccache --show-stats
 
   # gcc, cassert on, dtrace off
   always:
@@ -548,7 +566,9 @@ task:
         ${LINUX_CONFIGURE_FEATURES} \
         CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang"
       make -s -j${BUILD_JOBS} clean
+      ccache --zero-stats
       time make -s -j${BUILD_JOBS} world-bin
+      ccache --show-stats
 
   # clang, cassert off, dtrace off
   always:
@@ -558,7 +578,9 @@ task:
         ${LINUX_CONFIGURE_FEATURES} \
         CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang"
       make -s -j${BUILD_JOBS} clean
+      ccache --zero-stats
       time make -s -j${BUILD_JOBS} world-bin
+      ccache --show-stats
 
   # clang, cassert on, dtrace on
   always:
@@ -570,7 +592,9 @@ task:
         ${LINUX_CONFIGURE_FEATURES} \
         CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang"
       make -s -j${BUILD_JOBS} clean
+      ccache --zero-stats
       time make -s -j${BUILD_JOBS} world-bin
+      ccache --show-stats
 
   # cross-compile to windows
   always:
@@ -581,7 +605,9 @@ task:
         CC="ccache x86_64-w64-mingw32-gcc" \
         CXX="ccache x86_64-w64-mingw32-g++"
       make -s -j${BUILD_JOBS} clean
+      ccache --zero-stats
       time make -s -j${BUILD_JOBS} world-bin
+      ccache --show-stats
 
   ###
   # Verify docs can be built
-- 
2.17.1

