33# it requires several inputs that allow customizing its behavior.
44
55name : " [libc++] Run benchmark suite against commit"
6+
7+ # Keep in sync with libcxx/utils/ci/lnt/dispatch-benchmarks
68run-name : " [libc++] Run benchmark suite against ${{ inputs.commit }} on ${{ inputs.lnt-machine }}"
79
810permissions :
1820 lnt-machine :
1921 description : ' The LNT machine to run the benchmarks on'
2022 required : true
21- type : choice
22- options :
23- - macos-26.5-arm64
24- - linux-x86_64
25- benchmark-suite-version :
26- description : ' The version of the benchmark suite to use (a LLVM monorepo SHA)'
23+ type : string
24+ benchmark-suite-override :
25+ description : |
26+ Override the version of the benchmark suite to use (a LLVM monorepo SHA). By default, the version pinned
27+ for this machine in machines.json is used. This override can be used to dry-run benchmarks with arbitrary
28+ commits of the benchmark suite, but only the version pinned in machines.json can be used when actually
29+ submitting to LNT.
2730 required : false
2831 type : string
29- default : 0eefb2682bf8c04954c46e91916b5164d8424702
3032 filter :
3133 description : ' An optional filter to determine which benchmarks to run'
3234 required : false
@@ -49,37 +51,50 @@ jobs:
4951 outputs :
5052 matrix : ${{ steps.select.outputs.matrix }}
5153 steps :
54+ - name : Checkout the machine definitions
55+ uses : actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
56+ with :
57+ persist-credentials : false
58+ # Disabling cone mode allows checking out exactly the single file we need.
59+ sparse-checkout : libcxx/utils/ci/lnt/machines.json
60+ sparse-checkout-cone-mode : false
61+
5262 - name : Select the configuration to benchmark on
5363 id : select
5464 uses : actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
5565 env :
5666 LNT_MACHINE : ${{ inputs.lnt-machine }}
67+ BENCHMARK_SUITE_OVERRIDE : ${{ inputs.benchmark-suite-override }}
68+ SUBMIT_LNT : ${{ inputs.submit-lnt }}
5769 with :
5870 script : |
59- const MACHINES = [
60- {
61- 'lnt-machine': 'macos-26.5-arm64',
62- runner: ['self-hosted', 'macOS', 'ARM64', '26', '26.5'],
63- cxx: 'clang++',
64- 'running-on': 'macos',
65- 'xcode-version': '26.5',
66- },
67- {
68- 'lnt-machine': 'linux-x86_64',
69- runner: 'llvm-premerge-libcxx-runners',
70- cxx: 'clang++-22',
71- 'running-on': 'linux',
72- },
73- ];
71+ const config = JSON.parse(require('fs').readFileSync('libcxx/utils/ci/lnt/machines.json', 'utf8'));
7472
7573 const requested = process.env.LNT_MACHINE;
76- const selected = MACHINES .filter(m => m ['lnt-machine'] === requested);
74+ const selected = config .filter(cfg => cfg ['lnt-machine'] === requested);
7775 if (selected.length === 0) {
78- const known = MACHINES .map(m => m ['lnt-machine']).join(', ');
76+ const known = config .map(cfg => cfg ['lnt-machine']).join(', ');
7977 core.setFailed(`Unknown LNT machine '${requested}' (known machines: ${known})`);
8078 return;
8179 }
8280
81+ // Honor benchmark suite version override and make sure we don't submit if an incorrect
82+ // override is provided.
83+ const version_override = (process.env.BENCHMARK_SUITE_OVERRIDE || '').trim().toLowerCase();
84+ for (const cfg of selected) {
85+ const pinned = cfg['benchmark-suite-version'];
86+ if (process.env.SUBMIT_LNT === 'true' && version_override && version_override !== pinned) {
87+ core.setFailed(`Refusing to submit results for ${cfg['lnt-machine']}, since the benchmark suite was `
88+ + `overridden to version ${version_override}, which is different from the version `
89+ + `pinned in machines.json (${pinned}).`);
90+ return;
91+ }
92+
93+ if (version_override) {
94+ cfg['benchmark-suite-version'] = version_override;
95+ }
96+ }
97+
8398 core.setOutput('matrix', JSON.stringify(selected));
8499
85100 run-benchmarks :
@@ -125,13 +140,20 @@ jobs:
125140 "${COMPILER}" --version
126141 python3 --version
127142
143+ - name : Setup virtual environment
144+ run : |
145+ python3 -m venv .venv
146+ source .venv/bin/activate
147+ pip install -r libcxx/utils/requirements.txt
148+
128149 - name : Run the benchmarks
129150 env :
130151 COMMIT : ${{ inputs.commit }}
131- BENCHMARK_SUITE_VERSION : ${{ inputs .benchmark-suite-version }}
152+ BENCHMARK_SUITE_VERSION : ${{ matrix .benchmark-suite-version }}
132153 FILTER : ${{ inputs.filter }}
133154 LNT_MACHINE : ${{ matrix.lnt-machine }}
134155 run : |
156+ source .venv/bin/activate
135157 filter_arg=()
136158 if [ -n "${FILTER}" ]; then
137159 filter_arg=(--filter "${FILTER}")
@@ -152,6 +174,7 @@ jobs:
152174 COMMIT : ${{ inputs.commit }}
153175 LNT_URL : ${{ inputs.lnt-url }}
154176 run : |
177+ source .venv/bin/activate
155178 libcxx/utils/ci/lnt/submit-benchmarks \
156179 --lnt-url "${LNT_URL}" \
157180 --test-suite libcxx \
0 commit comments