From 6df73f033ce6e0adf178f05613fb25754f1f39a1 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 11 Oct 2025 18:39:47 +0200 Subject: [PATCH 1/2] github: compile & run benchmarks in parallel --- .github/workflows/CICD.yml | 55 +++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 9eafa5e8b..7f3f1d0a1 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -1331,6 +1331,28 @@ jobs: name: Run benchmarks (CodSpeed) runs-on: ubuntu-latest needs: min_version + strategy: + matrix: + benchmark-target: + - { package: uu_base64 } + - { package: uu_cp } + - { package: uu_cut } + - { package: uu_du } + - { package: uu_expand } + - { package: uu_fold } + - { package: uu_hashsum } + - { package: uu_ls } + - { package: uu_mv } + - { package: uu_nl } + - { package: uu_numfmt } + - { package: uu_rm } + - { package: uu_seq } + - { package: uu_sort } + - { package: uu_split } + - { package: uu_tsort } + - { package: uu_unexpand } + - { package: uu_uniq } + - { package: uu_wc } steps: - uses: actions/checkout@v5 with: @@ -1353,40 +1375,19 @@ jobs: shell: bash run: cargo install cargo-codspeed --locked - - name: Get benchmark list - id: benchmark_list + - name: Build benchmarks for ${{ matrix.benchmark-target.package }} shell: bash run: | - echo "Finding all utilities with benchmarks..." - benchmark_packages="" - for bench_dir in $(ls -d src/uu/*/benches 2>/dev/null); do - prog_dir=$(dirname "$bench_dir") - prog_name=$(basename "$prog_dir") - echo "Found benchmarks for uu_$prog_name" - benchmark_packages="$benchmark_packages uu_$prog_name" - done - echo "benchmark_packages=${benchmark_packages}" >> $GITHUB_OUTPUT - echo "Found benchmark packages:${benchmark_packages}" + echo "Building benchmarks for ${{ matrix.benchmark-target.package }}" + cargo codspeed build -p ${{ matrix.benchmark-target.package }} - - name: Build benchmarks - shell: bash - run: | - echo "Building benchmarks for packages: ${{ steps.benchmark_list.outputs.benchmark_packages }}" - for package in ${{ steps.benchmark_list.outputs.benchmark_packages }}; do - echo "Building benchmarks for $package" - cargo codspeed build -p $package - done - - - name: Run benchmarks + - name: Run benchmarks for ${{ matrix.benchmark-target.package }} uses: CodSpeedHQ/action@v4 env: CODSPEED_LOG: debug with: mode: instrumentation run: | - echo "Running benchmarks for packages: ${{ steps.benchmark_list.outputs.benchmark_packages }}" - for package in ${{ steps.benchmark_list.outputs.benchmark_packages }}; do - echo "Running benchmarks for $package" - cargo codspeed run -p $package > /dev/null - done + echo "Running benchmarks for ${{ matrix.benchmark-target.package }}" + cargo codspeed run -p ${{ matrix.benchmark-target.package }} > /dev/null token: ${{ secrets.CODSPEED_TOKEN }} From f19d7ec40b0d6f6de202b135631f303ac1b9c1ca Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 11 Oct 2025 19:07:46 +0200 Subject: [PATCH 2/2] github: move benchmark into a single file --- .github/workflows/CICD.yml | 65 ------------------------- .github/workflows/benchmarks.yml | 82 ++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 65 deletions(-) create mode 100644 .github/workflows/benchmarks.yml diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 7f3f1d0a1..c5bbf7f11 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -1326,68 +1326,3 @@ jobs: run: cargo build --release -p uu_rm -p uu_chmod -p uu_chown -p uu_chgrp -p uu_mv -p uu_du - name: Run safe traversal verification run: ./util/check-safe-traversal.sh - - benchmarks: - name: Run benchmarks (CodSpeed) - runs-on: ubuntu-latest - needs: min_version - strategy: - matrix: - benchmark-target: - - { package: uu_base64 } - - { package: uu_cp } - - { package: uu_cut } - - { package: uu_du } - - { package: uu_expand } - - { package: uu_fold } - - { package: uu_hashsum } - - { package: uu_ls } - - { package: uu_mv } - - { package: uu_nl } - - { package: uu_numfmt } - - { package: uu_rm } - - { package: uu_seq } - - { package: uu_sort } - - { package: uu_split } - - { package: uu_tsort } - - { package: uu_unexpand } - - { package: uu_uniq } - - { package: uu_wc } - steps: - - uses: actions/checkout@v5 - with: - persist-credentials: false - - - name: Install system dependencies - shell: bash - run: | - sudo apt-get -y update - sudo apt-get -y install libselinux1-dev - - - uses: dtolnay/rust-toolchain@stable - - - uses: Swatinem/rust-cache@v2 - - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.9 - - - name: Install cargo-codspeed - shell: bash - run: cargo install cargo-codspeed --locked - - - name: Build benchmarks for ${{ matrix.benchmark-target.package }} - shell: bash - run: | - echo "Building benchmarks for ${{ matrix.benchmark-target.package }}" - cargo codspeed build -p ${{ matrix.benchmark-target.package }} - - - name: Run benchmarks for ${{ matrix.benchmark-target.package }} - uses: CodSpeedHQ/action@v4 - env: - CODSPEED_LOG: debug - with: - mode: instrumentation - run: | - echo "Running benchmarks for ${{ matrix.benchmark-target.package }}" - cargo codspeed run -p ${{ matrix.benchmark-target.package }} > /dev/null - token: ${{ secrets.CODSPEED_TOKEN }} diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml new file mode 100644 index 000000000..9051f70ab --- /dev/null +++ b/.github/workflows/benchmarks.yml @@ -0,0 +1,82 @@ +name: Benchmarks + +# spell-checker:ignore codspeed dtolnay Swatinem sccache + +on: + pull_request: + push: + branches: + - '*' + +permissions: + contents: read # to fetch code (actions/checkout) + +# End the current execution if there is a new changeset in the PR. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + benchmarks: + name: Run benchmarks (CodSpeed) + runs-on: ubuntu-latest + strategy: + matrix: + benchmark-target: + - { package: uu_base64 } + - { package: uu_cp } + - { package: uu_cut } + - { package: uu_du } + - { package: uu_expand } + - { package: uu_fold } + - { package: uu_hashsum } + - { package: uu_ls } + - { package: uu_mv } + - { package: uu_nl } + - { package: uu_numfmt } + - { package: uu_rm } + - { package: uu_seq } + - { package: uu_sort } + - { package: uu_split } + - { package: uu_tsort } + - { package: uu_unexpand } + - { package: uu_uniq } + - { package: uu_wc } + steps: + - uses: actions/checkout@v5 + with: + persist-credentials: false + + - name: Install system dependencies + shell: bash + run: | + sudo apt-get -y update + sudo apt-get -y install libselinux1-dev + + - uses: dtolnay/rust-toolchain@stable + + - uses: Swatinem/rust-cache@v2 + + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.9 + + - name: Install cargo-codspeed + shell: bash + run: cargo install cargo-codspeed --locked + + - name: Build benchmarks for ${{ matrix.benchmark-target.package }} + shell: bash + run: | + echo "Building benchmarks for ${{ matrix.benchmark-target.package }}" + cargo codspeed build -p ${{ matrix.benchmark-target.package }} + + - name: Run benchmarks for ${{ matrix.benchmark-target.package }} + uses: CodSpeedHQ/action@v4 + env: + CODSPEED_LOG: debug + with: + mode: instrumentation + run: | + echo "Running benchmarks for ${{ matrix.benchmark-target.package }}" + cargo codspeed run -p ${{ matrix.benchmark-target.package }} > /dev/null + token: ${{ secrets.CODSPEED_TOKEN }}