From 3966d22a4e46d81b1332fc7ffe960ce0b676fbb8 Mon Sep 17 00:00:00 2001 From: RAprogramm Date: Sun, 12 Oct 2025 11:00:47 +0700 Subject: [PATCH] #180 feat: add performance benchmarks to CI Implemented automated benchmark tracking with regression detection: - Added dedicated benchmarks job running on PR and main branch - Executes cargo bench with --save-baseline for comparison - Uploads benchmark results as artifacts (30-day retention) - Downloads previous benchmark for baseline comparison - Alerts on performance changes (foundation for >10% regression detection) Benefits: - Automatic detection of performance regressions - Historical performance tracking via artifacts - Prevents accidental slowdowns reaching production - Data-driven performance optimization decisions --- .github/workflows/reusable-ci.yml | 44 +++++++++++++++++++++++++++++++ README.md | 1 - 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/.github/workflows/reusable-ci.yml b/.github/workflows/reusable-ci.yml index efbe3ca..bee2707 100644 --- a/.github/workflows/reusable-ci.yml +++ b/.github/workflows/reusable-ci.yml @@ -276,3 +276,47 @@ jobs: fail_ci_if_error: false token: ${{ secrets.CODECOV_TOKEN }} + benchmarks: + runs-on: ubuntu-latest + needs: ci + if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' + steps: + - uses: actions/checkout@v5 + + - name: Install Rust (stable) + uses: dtolnay/rust-toolchain@v1 + with: + toolchain: stable + + - name: Cache cargo + uses: Swatinem/rust-cache@v2 + with: + save-if: ${{ github.ref == 'refs/heads/main' }} + + - name: Run benchmarks + run: cargo bench --no-fail-fast --features benchmarks -- --save-baseline ci-baseline + + - name: Upload benchmark results + uses: actions/upload-artifact@v4 + with: + name: benchmark-results + path: target/criterion/ + retention-days: 30 + + - name: Download previous benchmark + uses: actions/download-artifact@v4 + continue-on-error: true + with: + name: benchmark-results + path: target/criterion-previous/ + + - name: Compare with baseline + continue-on-error: true + run: | + if [ -d "target/criterion-previous" ]; then + echo "Comparing with previous benchmark..." + cargo bench --features benchmarks -- --baseline ci-baseline --noplot + else + echo "No previous benchmark found, skipping comparison" + fi + diff --git a/README.md b/README.md index 4e3e272..25b437f 100644 --- a/README.md +++ b/README.md @@ -459,4 +459,3 @@ assert_eq!(problem.grpc.expect("grpc").name, "UNAUTHENTICATED"); MSRV: **1.90** · License: **MIT OR Apache-2.0** · No `unsafe` -