[llvm] [libc++] Run the PR benchmarking tooling from main (PR #226278)
Louis Dionne via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 24 18:49:28 PDT 2026
https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/226278
>From 6bc5149395e7adbfb0144555189fb242364df560 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Thu, 24 Sep 2026 12:44:45 -0400
Subject: [PATCH] [libc++] Run the PR benchmarking tooling from main
Previously, we'd use the workflow file and machines.json from the main
branch, but the rest of the tools (e.g. build-at-commit) would be taken
from the PR head. This patch switches to using the tools from main and
only using the PR head's content for the actual code and benchmarks.
This should make it easier to evolve the tools and the workflow files
without breaking PR benchmarking for people who submit PRs from slightly
outdated bases.
---
.github/workflows/libcxx-benchmark-commit.yml | 1 +
.github/workflows/libcxx-pr-benchmark.yml | 35 ++++++++++++++-----
.../libcxx/build-at-commit/action.yml | 18 +++++++---
3 files changed, 41 insertions(+), 13 deletions(-)
diff --git a/.github/workflows/libcxx-benchmark-commit.yml b/.github/workflows/libcxx-benchmark-commit.yml
index efd299bcce8dc..0aafda5456130 100644
--- a/.github/workflows/libcxx-benchmark-commit.yml
+++ b/.github/workflows/libcxx-benchmark-commit.yml
@@ -157,6 +157,7 @@ jobs:
continue-on-error: true
uses: ./.github/workflows/libcxx/build-at-commit
with:
+ git-repo: ${{ github.workspace }}
commit: ${{ inputs.commit }}
install-dir: ${{ env.INSTALL_DIR }}
compiler: ${{ matrix.cxx }}
diff --git a/.github/workflows/libcxx-pr-benchmark.yml b/.github/workflows/libcxx-pr-benchmark.yml
index 913eca1fd62c0..39cab7b72c5cc 100644
--- a/.github/workflows/libcxx-pr-benchmark.yml
+++ b/.github/workflows/libcxx-pr-benchmark.yml
@@ -115,14 +115,29 @@ jobs:
LNT_MACHINE: ${{ matrix.lnt-machine }}
PR_HEAD: ${{ needs.extract-info.outputs.pr_head }}
PR_BASE: ${{ needs.extract-info.outputs.pr_base }}
+ TOOLING: ${{ github.workspace }}/tooling
steps:
- - uses: actions/checkout at df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
+ - name: Checkout the PR
+ uses: actions/checkout at df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
ref: ${{ needs.extract-info.outputs.pr_head }}
fetch-depth: 0
fetch-tags: true # This job requires access to all the Git branches so it can diff against (usually) main
+ # This workflow is always taken from the default branch. Check out the tooling from the corresponding
+ # commit so that we're always running tooling that's in sync with the workflow's definition. Only the
+ # code and the test suite (including its testing configuration) are taken from the PR head.
+ - name: Checkout the tooling from ${{ github.sha }}
+ uses: actions/checkout at df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
+ with:
+ persist-credentials: false
+ ref: ${{ github.sha }}
+ path: tooling
+ sparse-checkout: |
+ .github/workflows/libcxx
+ libcxx/utils
+
- name: Install Python
if: runner.os == 'Linux' # installed via Homebrew on macOS
uses: actions/setup-python at ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
@@ -151,23 +166,25 @@ jobs:
run: |
python3 -m venv .venv
source .venv/bin/activate
- pip install -r libcxx/utils/requirements.txt
+ pip install -r "${TOOLING}/libcxx/utils/requirements.txt"
- name: Determine the baseline commit
id: baseline
run: echo "commit=$(git merge-base "${PR_BASE}" "${PR_HEAD}")" >> "${GITHUB_OUTPUT}"
- name: Build the baseline
- uses: ./.github/workflows/libcxx/build-at-commit
+ uses: ./tooling/.github/workflows/libcxx/build-at-commit
with:
+ git-repo: ${{ github.workspace }}
commit: ${{ steps.baseline.outputs.commit }}
install-dir: ${{ github.workspace }}/install/baseline
compiler: ${{ matrix.cxx }}
cmake-cache: ${{ matrix.cmake-cache }}
- name: Build the candidate
- uses: ./.github/workflows/libcxx/build-at-commit
+ uses: ./tooling/.github/workflows/libcxx/build-at-commit
with:
+ git-repo: ${{ github.workspace }}
commit: ${{ needs.extract-info.outputs.pr_head }}
install-dir: ${{ github.workspace }}/install/candidate
compiler: ${{ matrix.cxx }}
@@ -186,16 +203,16 @@ jobs:
# Run 5 times so we can pick the median, and interleave baseline and candidate to mitigate the impact of
# environmental noise
for _ in $(seq 1 5); do
- ./libcxx/utils/test-at-commit --test-config installed-libc++.cfg.in -B benchmarks/baseline --compiler "${COMPILER}" -- -sv -j1 "${lit_params[@]}" --param libcxx_installation="${PWD}/install/baseline" "$BENCHMARKS"
- ./libcxx/utils/consolidate-benchmarks benchmarks/baseline | tee -a baseline.lnt
- ./libcxx/utils/test-at-commit --test-config installed-libc++.cfg.in -B benchmarks/candidate --compiler "${COMPILER}" -- -sv -j1 "${lit_params[@]}" --param libcxx_installation="${PWD}/install/candidate" "$BENCHMARKS"
- ./libcxx/utils/consolidate-benchmarks benchmarks/candidate | tee -a candidate.lnt
+ "${TOOLING}/libcxx/utils/test-at-commit" --test-config installed-libc++.cfg.in -B benchmarks/baseline --compiler "${COMPILER}" -- -sv -j1 "${lit_params[@]}" --param libcxx_installation="${PWD}/install/baseline" "$BENCHMARKS"
+ "${TOOLING}/libcxx/utils/consolidate-benchmarks" benchmarks/baseline | tee -a baseline.lnt
+ "${TOOLING}/libcxx/utils/test-at-commit" --test-config installed-libc++.cfg.in -B benchmarks/candidate --compiler "${COMPILER}" -- -sv -j1 "${lit_params[@]}" --param libcxx_installation="${PWD}/install/candidate" "$BENCHMARKS"
+ "${TOOLING}/libcxx/utils/consolidate-benchmarks" benchmarks/candidate | tee -a candidate.lnt
done
- name: Compare baseline and candidate runs
run: |
source .venv/bin/activate
- ./libcxx/utils/compare-benchmarks baseline.lnt candidate.lnt | tee results.txt
+ "${TOOLING}/libcxx/utils/compare-benchmarks" baseline.lnt candidate.lnt | tee results.txt
- name: Update comment with results
uses: actions/github-script at 3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
diff --git a/.github/workflows/libcxx/build-at-commit/action.yml b/.github/workflows/libcxx/build-at-commit/action.yml
index 0528a8e37c5fe..3c6a75f56b5f6 100644
--- a/.github/workflows/libcxx/build-at-commit/action.yml
+++ b/.github/workflows/libcxx/build-at-commit/action.yml
@@ -1,9 +1,10 @@
# This composite action builds libc++ as of an arbitrary commit and installs it into the
-# specified directory.
+# specified directory. This allows other workflows to reuse this job for various purposes.
#
-# This allows other workflows to reuse this job for various purposes.
+# The tools used to perform the build are taken from the monorepo checkout this action lives
+# in, while the commit being built is taken from `git-repo`.
#
-# This action assumes that the monorepo has been checked out with its full history (arbitrary
+# This action assumes that `git-repo` has been checked out with its full history (arbitrary
# historical commits must be reachable) and that CMake, Ninja and the compiler are available.
name: 'Build libc++ at a commit'
@@ -24,6 +25,9 @@ inputs:
CMake cache describing how to build the library, as a path relative to the root of the
monorepo (e.g. libcxx/utils/ci/lnt/cmake/generic.cmake).
required: true
+ git-repo:
+ description: 'The Git repository containing the commit to build.'
+ required: true
runs:
using: composite
@@ -34,16 +38,22 @@ runs:
CMAKE_CACHE: ${{ inputs.cmake-cache }}
COMMIT: ${{ inputs.commit }}
COMPILER: ${{ inputs.compiler }}
+ GIT_REPO: ${{ inputs.git-repo }}
INSTALL_DIR: ${{ inputs.install-dir }}
run: |
+ # Execute from the root of the monorepo that contains this action. This can be different from the
+ # default working directory if this action is invoked in a subdirectory of the calling workflow.
+ cd "${GITHUB_ACTION_PATH}/../../../.."
+
# Clean up any stale install directory
rm -rf "${INSTALL_DIR}"
# Let build-at-commit use (and clean up) its own temporary source and build directories:
# only the installation is of interest to the caller.
libcxx/utils/build-at-commit \
+ --git-repo "${GIT_REPO}" \
--commit "${COMMIT}" \
--install-dir "${INSTALL_DIR}" \
-- \
-DCMAKE_CXX_COMPILER="${COMPILER}" \
- -C "${GITHUB_WORKSPACE}/${CMAKE_CACHE}"
+ -C "${CMAKE_CACHE}"
More information about the llvm-commits
mailing list