From 19a1f3be022922b25d6439a2912ea5ac6e98db10 Mon Sep 17 00:00:00 2001 From: Wang Xiaofeng Date: Mon, 24 Aug 2026 23:17:31 +0800 Subject: [PATCH 1/3] Cache CI build outputs --- .github/actions/setup-build-cache/action.yml | 75 ++++++++++++++++++++ .github/workflows/ci-linux.yml | 33 +++++++++ .github/workflows/ci-macos.yml | 9 +++ 3 files changed, 117 insertions(+) create mode 100644 .github/actions/setup-build-cache/action.yml diff --git a/.github/actions/setup-build-cache/action.yml b/.github/actions/setup-build-cache/action.yml new file mode 100644 index 0000000000..7831e7fabe --- /dev/null +++ b/.github/actions/setup-build-cache/action.yml @@ -0,0 +1,75 @@ +name: Setup build cache +description: Restore and configure the compiler cache used by CI builds + +inputs: + kind: + description: Cache backend to configure (ccache or bazel) + required: true + +runs: + using: composite + steps: + - name: Restore ccache + if: inputs.kind == 'ccache' + uses: actions/cache@v6 + with: + path: ~/.cache/ccache + key: ${{ runner.os }}-ccache-${{ github.job }}-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-ccache-${{ github.job }}- + ${{ runner.os }}-ccache- + + - name: Configure ccache + if: inputs.kind == 'ccache' + shell: bash + run: | + if [[ "${{ runner.os }}" == "macOS" ]]; then + brew install ccache + else + sudo apt-get update + sudo apt-get install -y ccache + fi + + mkdir -p "${HOME}/.cache/ccache" "${HOME}/.cache/ccache-bin" + for compiler in cc c++ gcc g++ clang clang++ clang-12 clang++-12; do + ln -sf "$(command -v ccache)" "${HOME}/.cache/ccache-bin/${compiler}" + done + CCACHE_DIR="${HOME}/.cache/ccache" ccache --max-size=2G + CCACHE_DIR="${HOME}/.cache/ccache" ccache --zero-stats + + echo "${HOME}/.cache/ccache-bin" >> "${GITHUB_PATH}" + echo "CCACHE_DIR=${HOME}/.cache/ccache" >> "${GITHUB_ENV}" + echo "CCACHE_BASEDIR=${GITHUB_WORKSPACE}" >> "${GITHUB_ENV}" + echo "CCACHE_COMPILERCHECK=content" >> "${GITHUB_ENV}" + echo "CCACHE_NOHASHDIR=true" >> "${GITHUB_ENV}" + + - name: Restore Bazel repository cache + if: inputs.kind == 'bazel' + uses: actions/cache@v6 + with: + path: | + ~/.cache/bazel-repository + ~/.cache/bazelisk + key: ${{ runner.os }}-bazel-repository-${{ hashFiles('.bazelversion', 'MODULE.bazel', 'MODULE.bazel.lock', 'WORKSPACE') }} + restore-keys: | + ${{ runner.os }}-bazel-repository- + + - name: Restore Bazel disk cache + if: inputs.kind == 'bazel' + uses: actions/cache@v6 + with: + path: ~/.cache/bazel-disk + key: ${{ runner.os }}-bazel-disk-${{ github.job }}-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-bazel-disk-${{ github.job }}- + ${{ runner.os }}-bazel-disk- + + - name: Configure Bazel caches + if: inputs.kind == 'bazel' + shell: bash + run: | + mkdir -p "${HOME}/.cache/bazel-repository" "${HOME}/.cache/bazel-disk" + cat >> "${HOME}/.bazelrc" < Date: Tue, 25 Aug 2026 00:03:17 +0800 Subject: [PATCH 2/3] Report ccache statistics in CI --- .github/workflows/ci-linux.yml | 22 ++++++++++++++++++++++ .github/workflows/ci-macos.yml | 8 ++++++++ 2 files changed, 30 insertions(+) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index fe33be2edb..3619add1c5 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -52,6 +52,10 @@ jobs: --with-thrift --with-glog --with-rdma --with-debug-bthread-sche-safety \ --with-debug-lock --with-bthread-tracer --with-asan + - name: Show ccache statistics + if: always() + run: ccache --show-stats + compile-with-cmake: runs-on: ubuntu-22.04 steps: @@ -91,6 +95,10 @@ jobs: -DWITH_ASAN=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5 .. make -j ${{env.proc_num}} && make clean + - name: Show ccache statistics + if: always() + run: ccache --show-stats + gcc-compile-with-make-protobuf: runs-on: ubuntu-22.04 steps: @@ -124,6 +132,10 @@ jobs: protobuf-install-dir: /protobuf-3.21.12 config-brpc-options: --cc=gcc --cxx=g++ --werror + - name: Show ccache statistics + if: always() + run: ccache --show-stats + gcc-unittest-with-bazel: runs-on: ubuntu-22.04 steps: @@ -210,6 +222,10 @@ jobs: protobuf-install-dir: /protobuf-3.21.12 config-brpc-options: --cc=clang --cxx=clang++ --werror + - name: Show ccache statistics + if: always() + run: ccache --show-stats + clang-unittest-with-bazel: runs-on: ubuntu-22.04 steps: @@ -289,6 +305,9 @@ jobs: run: | cd test sh ./run_tests.sh + - name: Show ccache statistics + if: always() + run: ccache --show-stats clang-unittest-asan: runs-on: ubuntu-22.04 @@ -314,6 +333,9 @@ jobs: # too slowly, so they flake here (connection refused). Skip just those under ASan; the # redis codec/server tests still run, and the full suite runs in clang-unittest. GTEST_FILTER='-RedisTest.sanity:RedisTest.keys_with_spaces:RedisTest.incr_and_decr:RedisTest.by_components:RedisTest.auth' sh ./run_tests.sh + - name: Show ccache statistics + if: always() + run: ccache --show-stats clang-unittest-bazel-with-babylon-and-new-pb: runs-on: ubuntu-22.04 diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 8c24330a4c..9cc89fabc6 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -44,6 +44,10 @@ jobs: mkdir build && cd build && cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DWITH_UBRING=ON -DCMAKE_PREFIX_PATH=$(brew --prefix protobuf@21) .. make -j ${{env.proc_num}} && make clean + - name: Show ccache statistics + if: always() + run: ccache --show-stats + compile-with-make-cmake-protobuf29: runs-on: macos-latest # https://github.com/actions/runner-images @@ -69,6 +73,10 @@ jobs: mkdir build && cd build && cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DWITH_UBRING=ON -DCMAKE_PREFIX_PATH=$(brew --prefix protobuf@29) .. make -j ${{env.proc_num}} && make clean + - name: Show ccache statistics + if: always() + run: ccache --show-stats + compile-with-bazel: runs-on: macos-latest # https://github.com/actions/runner-images steps: From 6194eef74a265cf408ec3a30dcfbd21907c85466 Mon Sep 17 00:00:00 2001 From: Wang Xiaofeng Date: Tue, 25 Aug 2026 00:52:06 +0800 Subject: [PATCH 3/3] Run CMake configurations in parallel --- .github/actions/setup-build-cache/action.yml | 8 ++- .github/workflows/ci-linux.yml | 67 ++++++++++++-------- 2 files changed, 44 insertions(+), 31 deletions(-) diff --git a/.github/actions/setup-build-cache/action.yml b/.github/actions/setup-build-cache/action.yml index 7831e7fabe..6fbd7a4551 100644 --- a/.github/actions/setup-build-cache/action.yml +++ b/.github/actions/setup-build-cache/action.yml @@ -5,6 +5,9 @@ inputs: kind: description: Cache backend to configure (ccache or bazel) required: true + cache-key: + description: Cache namespace override for matrix jobs + required: false runs: using: composite @@ -14,10 +17,9 @@ runs: uses: actions/cache@v6 with: path: ~/.cache/ccache - key: ${{ runner.os }}-ccache-${{ github.job }}-${{ github.sha }} + key: ${{ runner.os }}-ccache-${{ inputs.cache-key || github.job }}--${{ github.sha }} restore-keys: | - ${{ runner.os }}-ccache-${{ github.job }}- - ${{ runner.os }}-ccache- + ${{ runner.os }}-ccache-${{ inputs.cache-key || github.job }}-- - name: Configure ccache if: inputs.kind == 'ccache' diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 3619add1c5..643e7c0f7f 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -57,43 +57,54 @@ jobs: run: ccache --show-stats compile-with-cmake: + name: compile-with-cmake (${{ matrix.name }}) runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + include: + - name: gcc-default + cc: gcc + cxx: g++ + cmake-options: '' + - name: gcc-all-options + cc: gcc + cxx: g++ + cmake-options: >- + -DWITH_MESALINK=OFF -DWITH_GLOG=ON -DWITH_THRIFT=ON + -DWITH_RDMA=ON -DWITH_UBRING=ON + -DWITH_DEBUG_BTHREAD_SCHE_SAFETY=ON -DWITH_DEBUG_LOCK=ON + -DWITH_BTHREAD_TRACER=ON -DWITH_ASAN=ON + - name: clang-default + cc: clang + cxx: clang++ + cmake-options: '' + - name: clang-all-options + cc: clang + cxx: clang++ + cmake-options: >- + -DWITH_MESALINK=OFF -DWITH_GLOG=ON -DWITH_THRIFT=ON + -DWITH_RDMA=ON -DWITH_UBRING=ON + -DWITH_DEBUG_BTHREAD_SCHE_SAFETY=ON -DWITH_DEBUG_LOCK=ON + -DWITH_BTHREAD_TRACER=ON -DWITH_ASAN=ON steps: - uses: actions/checkout@v2 - uses: ./.github/actions/setup-build-cache with: kind: ccache + cache-key: cmake-${{ matrix.name }} - uses: ./.github/actions/install-all-dependencies - - name: gcc with default options - run: | - export CC=gcc && export CXX=g++ - mkdir gcc_build && cd gcc_build && cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 .. - make -j ${{env.proc_num}} && make clean - - - name: gcc with all options - run: | - export CC=gcc && export CXX=g++ - mkdir gcc_build_all && cd gcc_build_all - cmake -DWITH_MESALINK=OFF -DWITH_GLOG=ON -DWITH_THRIFT=ON -DWITH_RDMA=ON -DWITH_UBRING=ON \ - -DWITH_DEBUG_BTHREAD_SCHE_SAFETY=ON -DWITH_DEBUG_LOCK=ON -DWITH_BTHREAD_TRACER=ON \ - -DWITH_ASAN=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5 .. - make -j ${{env.proc_num}} && make clean - - - name: clang with default options - run: | - export CC=clang && export CXX=clang++ - mkdir clang_build && cd clang_build && cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 .. - make -j ${{env.proc_num}} && make clean - - - name: clang with all options + - name: Build + env: + CC: ${{ matrix.cc }} + CXX: ${{ matrix.cxx }} + CMAKE_OPTIONS: ${{ matrix.cmake-options }} run: | - export CC=clang && export CXX=clang++ - mkdir clang_build_all && cd clang_build_all - cmake -DWITH_MESALINK=OFF -DWITH_GLOG=ON -DWITH_THRIFT=ON -DWITH_RDMA=ON -DWITH_UBRING=ON \ - -DWITH_DEBUG_BTHREAD_SCHE_SAFETY=ON -DWITH_DEBUG_LOCK=ON -DWITH_BTHREAD_TRACER=ON \ - -DWITH_ASAN=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5 .. - make -j ${{env.proc_num}} && make clean + read -r -a cmake_options <<< "${CMAKE_OPTIONS}" + cmake -S . -B build -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ + "${cmake_options[@]}" + cmake --build build -j ${{env.proc_num}} - name: Show ccache statistics if: always()