|
| 1 | +# This file defines a workflow that runs the libc++ benchmarks when a comment is added to the PR. |
| 2 | +# |
| 3 | +# The comment is of the form: |
| 4 | +# |
| 5 | +# /libcxx-bot benchmark <path-to-benchmarks-to-run> |
| 6 | +# |
| 7 | +# That will cause the specified benchmarks to be run on the PR and on the pull-request target, and |
| 8 | +# their results to be compared. |
| 9 | + |
| 10 | +name: Benchmark libc++ |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: read # Default everything to read-only |
| 14 | + |
| 15 | +on: |
| 16 | + issue_comment: |
| 17 | + types: |
| 18 | + - created |
| 19 | + - edited |
| 20 | + |
| 21 | +env: |
| 22 | + CC: clang-22 |
| 23 | + CXX: clang++-22 |
| 24 | + COMMENT_BODY: ${{ github.event.comment.body }} |
| 25 | + |
| 26 | +concurrency: |
| 27 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} |
| 28 | + cancel-in-progress: true |
| 29 | + |
| 30 | +jobs: |
| 31 | + run-benchmarks: |
| 32 | + if: >- |
| 33 | + github.event.issue.pull_request && |
| 34 | + contains(github.event.comment.body, '/libcxx-bot benchmark') |
| 35 | +
|
| 36 | + runs-on: llvm-premerge-libcxx-next-runners # TODO: This should run on a dedicated set of machines |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 39 | + with: |
| 40 | + fetch-depth: 0 |
| 41 | + fetch-tags: true # This job requires access to all the Git branches so it can diff against (usually) main |
| 42 | + |
| 43 | + - uses: actions/setup-python@v6 |
| 44 | + with: |
| 45 | + python-version: '3.10' |
| 46 | + |
| 47 | + - name: Install dependencies |
| 48 | + run: | |
| 49 | + python3 -m venv .venv |
| 50 | + source .venv/bin/activate |
| 51 | + python -m pip install -r libcxx/utils/requirements.txt |
| 52 | +
|
| 53 | + - name: Run baseline |
| 54 | + run: | |
| 55 | + BENCHMARKS=$(echo "${COMMENT_BODY}" | sed -n 's/\/libcxx-bot benchmark (.+)/\1/p') |
| 56 | + baseline_commit=$(git merge-base refs/remotes/origin/${GITHUB_BASE_REF} ${GITHUB_SHA}) |
| 57 | + ./libcxx/utils/test-at-commit --commit ${baseline_commit} -B build/baseline -- -sv -j1 --param optimization=speed ${BENCHMARKS} |
| 58 | +
|
| 59 | + - name: Run candidate |
| 60 | + run: | |
| 61 | + BENCHMARKS=$(echo "${COMMENT_BODY}" | sed -n 's/\/libcxx-bot benchmark (.+)/\1/p') |
| 62 | + ./libcxx/utils/test-at-commit --commit ${GITHUB_SHA} -B build/candidate -- -sv -j1 --param optimization=speed ${BENCHMARKS} |
| 63 | +
|
| 64 | + - name: Compare baseline and candidate runs |
| 65 | + run: ./libcxx/utils/compare-benchmarks <(./libcxx/utils/consolidate-benchmarks build/baseline) \ |
| 66 | + <(./libcxx/utils/consolidate-benchmarks build/candidate) |
0 commit comments