From 49ab7f83751532dc3ea059f4eb1ef39bfe9086d7 Mon Sep 17 00:00:00 2001 From: Filippo Luca Ferretti Date: Thu, 27 Feb 2025 11:25:38 +0100 Subject: [PATCH] Refactor workflow to improve performance result handling and caching --- .github/workflows/gpu_benchmark.yml | 51 +++++++++++++++-------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/.github/workflows/gpu_benchmark.yml b/.github/workflows/gpu_benchmark.yml index c02b4bab9..06880b304 100644 --- a/.github/workflows/gpu_benchmark.yml +++ b/.github/workflows/gpu_benchmark.yml @@ -12,10 +12,10 @@ permissions: jobs: benchmark: - runs-on: [self-hosted, gpu] + runs-on: self-hosted container: image: ghcr.io/nvidia/jax:jax - options: --gpus all + options: --rm --gpus all steps: - name: Checkout repository @@ -25,29 +25,30 @@ jobs: run: | pip install .[all] - - name: Run JaxSim benchmarks - id: benchmark - run: | - echo "### Benchmark Results" > results.txt - pytest --benchmark-only --gpu-only >> results.txt - # Output the results to GitHub Actions for use in the comment - echo "results=$(cat results.txt)" >> $GITHUB_ENV + - name: Performance regression check + uses: actions/checkout@v4 - - name: Debugging comment for benchmarks start - uses: thollander/actions-comment-pull-request@v3 + - name: Run benchmark and store result + run: pytest bench.py --benchmark-json output.json + + - name: Download previous benchmark data + uses: actions/cache@v4 with: - message: | - Running GPU benchmarks for this PR :rocket: - comment-tag: to_delete_on_completion - mode: delete-on-completion - - - name: Post results in PR comment - if: github.event_name == 'pull_request' - uses: thollander/actions-comment-pull-request@v3 + path: ./cache + key: ${{ runner.os }}-benchmark + + - name: Store benchmark result + uses: benchmark-action/github-action-benchmark@v1 with: - pr-number: ${{ github.event.number }} - message: | - _(execution **${{ github.run_id }}** / attempt **${{ github.run_attempt }}**)_ - ${{ env.results }} - comment-tag: execution - mode: upsert + tool: 'pytest' + output-file-path: output.json + external-data-json-path: ./cache/benchmark-data.json + fail-on-alert: true + summary-always: true + alert-threshold: 150% + auto-push: false + gh-pages-branch: gh-pages + + - name: Push benchmark result + if: github.event_name != 'pull_request' + run: git push 'https://ami-iit:${{ secrets.GITHUB_TOKEN }}@github.com/ami-iit/jaxsim.git' gh-pages:gh-pages