|
| 1 | +name: Benchmarks |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: write # contents permission to update benchmark contents in gh-pages branch |
| 5 | + statuses: read |
| 6 | + deployments: write # deployments permission to deploy GitHub pages website |
| 7 | + pull-requests: write |
| 8 | + |
| 9 | +on: |
| 10 | + schedule: |
| 11 | + - cron: '0 3 * * *' # Nightly at 3am UTC |
| 12 | + workflow_dispatch: |
| 13 | + # Manual trigger |
| 14 | + pull_request: |
| 15 | + types: [labeled, unlabeled, synchronize, opened, reopened] |
| 16 | + paths: |
| 17 | + - ".github/workflows/benchmark.yml" |
| 18 | + - "ext/**" |
| 19 | + - "lib/**" |
| 20 | + - "src/**" |
| 21 | + - "Project.toml" |
| 22 | + |
| 23 | +concurrency: |
| 24 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 25 | + cancel-in-progress: true |
| 26 | + |
| 27 | +jobs: |
| 28 | + benchmark: |
| 29 | + timeout-minutes: 90 |
| 30 | + if: ${{ (github.ref == 'refs/heads/main' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')) || (github.event_name == 'pull_request' && contains(join(github.event.pull_request.labels.*.name, ','), 'run benchmarks')) }} |
| 31 | + runs-on: ${{ matrix.os }} |
| 32 | + container: |
| 33 | + image: ${{ contains(matrix.os, 'linux') && 'ghcr.io/enzymead/reactant-docker-images@sha256:7004a6ebbdd77bd047900b2bffc542e8576864056dc27a9c94d30666d6f7ea01' || '' }} |
| 34 | + strategy: |
| 35 | + fail-fast: false |
| 36 | + matrix: |
| 37 | + os: |
| 38 | + - linux-x86-n2-32 |
| 39 | + - linux-x86-ct6e-180-4tpu |
| 40 | + - linux-x86-a2-48-a100-4gpu |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v4 |
| 43 | + - uses: julia-actions/setup-julia@v2 |
| 44 | + with: |
| 45 | + version: "1" |
| 46 | + - uses: julia-actions/cache@v2 |
| 47 | + - name: "Instantiate benchmarks environment" |
| 48 | + shell: julia --color=yes --project=benchmark {0} |
| 49 | + run: | |
| 50 | + using Pkg |
| 51 | + Pkg.instantiate() |
| 52 | + - name: "Run Benchmarks" |
| 53 | + run: | |
| 54 | + julia --color=yes --project=benchmark benchmark/runbenchmarks.jl |
| 55 | + - name: Upload PProf Results |
| 56 | + uses: actions/upload-artifact@v4 |
| 57 | + timeout-minutes: 10 |
| 58 | + with: |
| 59 | + name: pprof-results-${{ matrix.os }} |
| 60 | + path: "**/*pb.gz" |
| 61 | + retention-days: 90 |
| 62 | + overwrite: false |
| 63 | + - name: Upload Benchmark Results |
| 64 | + uses: actions/upload-artifact@v4 |
| 65 | + timeout-minutes: 10 |
| 66 | + with: |
| 67 | + name: benchmark-results-${{ matrix.os }} |
| 68 | + path: "benchmark/results/*" |
| 69 | + retention-days: 90 |
| 70 | + overwrite: false |
| 71 | + |
| 72 | + benchmark-aggregate: |
| 73 | + if: ${{ (github.ref == 'refs/heads/main' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')) || (github.event_name == 'pull_request' && contains(join(github.event.pull_request.labels.*.name, ','), 'run benchmarks')) }} |
| 74 | + needs: benchmark |
| 75 | + runs-on: ubuntu-latest |
| 76 | + steps: |
| 77 | + - uses: actions/checkout@v5 |
| 78 | + - uses: julia-actions/setup-julia@v2 |
| 79 | + with: |
| 80 | + version: "1" |
| 81 | + - uses: julia-actions/cache@v2 |
| 82 | + - uses: actions/download-artifact@v5 |
| 83 | + with: |
| 84 | + pattern: benchmark-results-* |
| 85 | + path: benchmark/results |
| 86 | + merge-multiple: true |
| 87 | + - name: Combine benchmarks |
| 88 | + id: locate |
| 89 | + run: | |
| 90 | + julia --color=yes -e '@info "Instantiating project" |
| 91 | + using Pkg; |
| 92 | + Pkg.add("JSON3"); |
| 93 | + @info "Combining Benchmarks" |
| 94 | + include("benchmark/aggregate.jl")' |
| 95 | +
|
| 96 | + echo "path=$(find benchmark -type f -name combinedbenchmarks.json 2>/dev/null)" >> $GITHUB_OUTPUT |
| 97 | + - name: Upload benchmark results as artifact |
| 98 | + uses: actions/upload-artifact@v4 |
| 99 | + with: |
| 100 | + name: benchmark-results |
| 101 | + path: ${{ steps.locate.outputs.path }} |
| 102 | + retention-days: 90 |
| 103 | + overwrite: false |
| 104 | + - name: Upload Benchmark Results |
| 105 | + uses: benchmark-action/github-action-benchmark@v1 |
| 106 | + with: |
| 107 | + name: Reactant.jl Benchmarks |
| 108 | + tool: "customSmallerIsBetter" |
| 109 | + output-file-path: ${{ steps.locate.outputs.path }} |
| 110 | + benchmark-data-dir-path: "benchmarks" |
| 111 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 112 | + comment-always: true |
| 113 | + summary-always: true |
| 114 | + alert-threshold: "150%" |
| 115 | + fail-on-alert: false |
| 116 | + auto-push: ${{ github.event_name != 'pull_request' }} |
| 117 | + max-items-in-chart: 50 |
0 commit comments