浏览代码

Meta: Trim the CI ccache down to files used in the current build

Tim Schumacher 1 年之前
父节点
当前提交
5f088f3233
共有 5 个文件被更改,包括 29 次插入18 次删除
  1. 9 7
      .github/workflows/cmake.yml
  2. 8 5
      Meta/Azure/Caches.yml
  3. 4 1
      Meta/Azure/Lagom.yml
  4. 7 3
      Meta/Azure/Serenity.yml
  5. 1 2
      Toolchain/BuildClang.sh

+ 9 - 7
.github/workflows/cmake.yml

@@ -156,14 +156,12 @@ jobs:
 
 
       - name: Show ccache stats before build and configure
       - name: Show ccache stats before build and configure
         run: |
         run: |
-          # We only have 5 GiB of cache available *in total*. Beyond that, GitHub deletes caches.
-          # Currently, we use about 130 MB for the toolchains (x86_64), and 2 ccache caches:
-          # One with ALL_DEBUG (x86_64), and one with NORMAL_DEBUG (x86_64).
-          # Therefore, using 1.6 GB or more per cache causes disaster.
-          # Building from scratch fills the ccache cache from 0 to about 0.7 GB, and after compression it comes out to
-          # about 0.25 GB, so 3 GB (1GB after compression) should be plenty, all while comfortably fitting in the cache.
-          ccache -M 3000M
+          # Reset all ccache modification dates to a known epoch. This provides a baseline that we can prune against.
+          find ${{ github.workspace }}/.ccache | tac | xargs touch -a -m -d "2018-10-10T09:53:07Z"
+          ccache -M 0
           ccache -s
           ccache -s
+          ccache -z
+
       - name: Create build directory
       - name: Create build directory
         run: |
         run: |
           mkdir -p ${{ github.workspace }}/Build/${{ matrix.arch }}
           mkdir -p ${{ github.workspace }}/Build/${{ matrix.arch }}
@@ -221,6 +219,10 @@ jobs:
       - name: Build Serenity and Tests
       - name: Build Serenity and Tests
         working-directory: ${{ github.workspace }}/Build/superbuild
         working-directory: ${{ github.workspace }}/Build/superbuild
         run: cmake --build .
         run: cmake --build .
+
+      - name: Prune obsolete ccache files
+        run: ccache --evict-older-than 1d
+
       - name: Show ccache stats after build
       - name: Show ccache stats after build
         run: ccache -s
         run: ccache -s
 
 

+ 8 - 5
Meta/Azure/Caches.yml

@@ -6,9 +6,7 @@ parameters:
   download_cache_path: ''
   download_cache_path: ''
   ccache_version: 1 # Increment this number if CI has trouble with ccache.
   ccache_version: 1 # Increment this number if CI has trouble with ccache.
   serenity_ccache_path: ''
   serenity_ccache_path: ''
-  serenity_ccache_size: '5G'
   toolchain_ccache_path: ''
   toolchain_ccache_path: ''
-  toolchain_ccache_size: $(CCACHE_MAXSIZE)
   with_remote_data_caches: true
   with_remote_data_caches: true
 
 
 steps:
 steps:
@@ -40,8 +38,11 @@ steps:
         displayName: 'Toolchain Compiler Cache'
         displayName: 'Toolchain Compiler Cache'
 
 
       - script: |
       - script: |
-          CCACHE_DIR=${{ parameters.toolchain_ccache_path }} ccache -M ${{ parameters.toolchain_ccache_size }}
+          # Reset all ccache modification dates to a known epoch. This provides a baseline that we can prune against.
+          find ${{ parameters.toolchain_ccache_path }} | tac | xargs touch -a -m -d "2018-10-10T09:53:07Z"
+          CCACHE_DIR=${{ parameters.toolchain_ccache_path }} ccache -M 0
           CCACHE_DIR=${{ parameters.toolchain_ccache_path }} ccache -s
           CCACHE_DIR=${{ parameters.toolchain_ccache_path }} ccache -s
+          CCACHE_DIR=${{ parameters.toolchain_ccache_path }} ccache -z
         displayName: 'Configure Toolchain ccache'
         displayName: 'Configure Toolchain ccache'
 
 
   - ${{ if ne(parameters.serenity_ccache_path, '') }}:
   - ${{ if ne(parameters.serenity_ccache_path, '') }}:
@@ -54,9 +55,11 @@ steps:
       displayName: 'Serenity Compiler Cache'
       displayName: 'Serenity Compiler Cache'
 
 
     - script: |
     - script: |
-        CCACHE_DIR=${{ parameters.serenity_ccache_path }} ccache -M ${{ parameters.serenity_ccache_size }}
-        CCACHE_DIR=${{ parameters.serenity_ccache_path }} ccache -c
+        # Reset all ccache modification dates to a known epoch. This provides a baseline that we can prune against.
+        find ${{ parameters.serenity_ccache_path }} | tac | xargs touch -a -m -d "2018-10-10T09:53:07Z"
+        CCACHE_DIR=${{ parameters.serenity_ccache_path }} ccache -M 0
         CCACHE_DIR=${{ parameters.serenity_ccache_path }} ccache -s
         CCACHE_DIR=${{ parameters.serenity_ccache_path }} ccache -s
+        CCACHE_DIR=${{ parameters.serenity_ccache_path }} ccache -z
       displayName: 'Configure Serenity ccache'
       displayName: 'Configure Serenity ccache'
 
 
   - ${{ if eq(parameters.with_remote_data_caches, true) }}:
   - ${{ if eq(parameters.with_remote_data_caches, true) }}:

+ 4 - 1
Meta/Azure/Lagom.yml

@@ -56,7 +56,6 @@ jobs:
         with_remote_data_caches: true
         with_remote_data_caches: true
         ${{ if eq(parameters.os, 'macOS') }}:
         ${{ if eq(parameters.os, 'macOS') }}:
           ccache_version: 2
           ccache_version: 2
-        serenity_ccache_size: '2G'
 
 
     - ${{ if eq(parameters.os, 'Android') }}:
     - ${{ if eq(parameters.os, 'Android') }}:
       - script: |
       - script: |
@@ -212,6 +211,10 @@ jobs:
           ASAN_OPTIONS: 'strict_string_checks=1:check_initialization_order=1:strict_init_order=1:detect_stack_use_after_return=0:allocator_may_return_null=1'
           ASAN_OPTIONS: 'strict_string_checks=1:check_initialization_order=1:strict_init_order=1:detect_stack_use_after_return=0:allocator_may_return_null=1'
           UBSAN_OPTIONS: 'print_stacktrace=1:print_summary=1:halt_on_error=1'
           UBSAN_OPTIONS: 'print_stacktrace=1:print_summary=1:halt_on_error=1'
 
 
+    - script: |
+        CCACHE_DIR='$(SERENITY_CCACHE_DIR)' ccache --evict-older-than 1d
+      displayName: 'Prune obsolete ccache files'
+
     - script: |
     - script: |
         CCACHE_DIR='$(SERENITY_CCACHE_DIR)' ccache -s
         CCACHE_DIR='$(SERENITY_CCACHE_DIR)' ccache -s
       displayName: 'Cache Stats'
       displayName: 'Cache Stats'

+ 7 - 3
Meta/Azure/Serenity.yml

@@ -9,8 +9,6 @@ jobs:
     variables:
     variables:
     - name: LLVM_CCACHE_DIR
     - name: LLVM_CCACHE_DIR
       value: $(Build.SourcesDirectory)/Toolchain/.ccache
       value: $(Build.SourcesDirectory)/Toolchain/.ccache
-    - name: LLVM_CCACHE_MAXSIZE
-      value: 20GB
     - name: SERENITY_CCACHE_DIR
     - name: SERENITY_CCACHE_DIR
       value: $(Build.SourcesDirectory)/.ccache
       value: $(Build.SourcesDirectory)/.ccache
 
 
@@ -29,7 +27,6 @@ jobs:
         toolchain: 'clang'
         toolchain: 'clang'
         download_cache_path: 'Build/caches'
         download_cache_path: 'Build/caches'
         toolchain_ccache_path: '$(LLVM_CCACHE_DIR)'
         toolchain_ccache_path: '$(LLVM_CCACHE_DIR)'
-        toolchain_ccache_size: '$(LLVM_CCACHE_MAXSIZE)'
         serenity_ccache_path: '$(SERENITY_CCACHE_DIR)'
         serenity_ccache_path: '$(SERENITY_CCACHE_DIR)'
 
 
     - script: ./Toolchain/BuildClang.sh --ci
     - script: ./Toolchain/BuildClang.sh --ci
@@ -126,6 +123,13 @@ jobs:
           artifactType: 'pipeline'
           artifactType: 'pipeline'
           artifactName: 'Coverage'
           artifactName: 'Coverage'
 
 
+    - script: |
+        echo "##[section]Toolchain Cache"
+        CCACHE_DIR='$(LLVM_CCACHE_DIR)' ccache --evict-older-than 1d
+
+        echo "##[section]Serenity Cache"
+        CCACHE_DIR='$(SERENITY_CCACHE_DIR)' ccache --evict-older-than 1d
+      displayName: 'Prune obsolete ccache files'
 
 
     - script: |
     - script: |
         echo "##[section]Toolchain Cache"
         echo "##[section]Toolchain Cache"

+ 1 - 2
Toolchain/BuildClang.sh

@@ -293,8 +293,7 @@ pushd "$DIR/Build/clang"
             ${link_lld:+"-DLLVM_ENABLE_LLD=ON"} \
             ${link_lld:+"-DLLVM_ENABLE_LLD=ON"} \
             ${dev:+"-DLLVM_CCACHE_BUILD=ON"} \
             ${dev:+"-DLLVM_CCACHE_BUILD=ON"} \
             ${ci:+"-DLLVM_CCACHE_BUILD=ON"} \
             ${ci:+"-DLLVM_CCACHE_BUILD=ON"} \
-            ${ci:+"-DLLVM_CCACHE_DIR=$LLVM_CCACHE_DIR"} \
-            ${ci:+"-DLLVM_CCACHE_MAXSIZE=$LLVM_CCACHE_MAXSIZE"}
+            ${ci:+"-DLLVM_CCACHE_DIR=$LLVM_CCACHE_DIR"}
 
 
         buildstep_ninja "llvm/build" ninja -j "$MAKEJOBS"
         buildstep_ninja "llvm/build" ninja -j "$MAKEJOBS"
         buildstep_ninja "llvm/install" ninja install/strip
         buildstep_ninja "llvm/install" ninja install/strip