Skip to content

Commit cfa9a3f

Browse files
committed
ENH: Add performance benchmark CI builds
Adds .github/workflows/perf-benchmark.yml — a GitHub Actions workflow that builds ITK twice (merge-base and PR HEAD) with the PerformanceBenchmarking remote module enabled, then drives the ASV harness from InsightSoftwareConsortium/ITKPerformanceBenchmarking#111 against each build to produce an asv compare report. Bumps the PerformanceBenchmarking remote module pin from 7950c1d76095033edbf7601a925cdacc2fe717f9 to 41bf1b9cfbaa1b146e1b3e5d3ad3571b2203ce1e (master HEAD, post-#111). The new pin carries: * asv.conf.json, benchmarks/{core,filtering,segmentation}.py, python/itk_perf_shim/ (the ASV harness). * Hardened examples/Core/itkCopyIterationBenchmark.cxx that no longer crashes on VectorImage under ITK >= 1d87efa (the VLV null-data regression; see #6087 for the parallel ITK-side defensive null-guard). Supersedes the 2019 Azure Pipelines macos-11 approach; macos-11 is retired and the older evaluate-itk-performance.py driver has been replaced by the ASV-native harness. For the very first PR (this one) the merge-base lacks the new pin, so its benchmark run is best-effort and the asv compare step is wrapped with continue-on-error. The workflow becomes fully useful for regression detection after this PR lands.
1 parent 95d3db3 commit cfa9a3f

2 files changed

Lines changed: 172 additions & 1 deletion

File tree

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
name: ITK.Performance
2+
3+
on:
4+
pull_request:
5+
paths-ignore:
6+
- '*.md'
7+
- LICENSE
8+
- NOTICE
9+
- 'Documentation/**'
10+
- 'Utilities/Debugger/**'
11+
- 'Utilities/ITKv5Preparation/**'
12+
- 'Utilities/Maintenance/**'
13+
workflow_dispatch:
14+
15+
concurrency:
16+
group: '${{ github.workflow }}@${{ github.head_ref || github.ref }}'
17+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
18+
19+
env:
20+
ExternalDataVersion: 5.4.5
21+
CMakeVersion: "4.0.1"
22+
# ASV-wired targets — see Modules/Remote/PerformanceBenchmarking's python/itk_perf_shim/registry.py.
23+
BenchmarkTargets: >-
24+
MedianBenchmark
25+
BinaryAddBenchmark
26+
UnaryAddBenchmark
27+
GradientMagnitudeBenchmark
28+
MinMaxCurvatureFlowBenchmark
29+
CopyIterationBenchmark
30+
VectorIterationBenchmark
31+
RegionGrowingBenchmark
32+
WatershedBenchmark
33+
MorphologicalWatershedBenchmark
34+
LevelSetBenchmark
35+
ITKBenchmarksData
36+
37+
jobs:
38+
asv-compare:
39+
name: asv base vs head (Ubuntu 24.04)
40+
runs-on: ubuntu-24.04
41+
timeout-minutes: 180
42+
43+
steps:
44+
- name: Checkout ITK PR HEAD (full history)
45+
uses: actions/checkout@v4
46+
with:
47+
fetch-depth: 0
48+
path: itk-head
49+
50+
- name: Resolve merge-base and HEAD SHAs
51+
id: sha
52+
working-directory: itk-head
53+
run: |
54+
git fetch origin "${{ github.base_ref }}"
55+
MERGE_BASE=$(git merge-base HEAD "origin/${{ github.base_ref }}")
56+
HEAD_SHA=$(git rev-parse HEAD)
57+
echo "merge_base=${MERGE_BASE}" >> "$GITHUB_OUTPUT"
58+
echo "head=${HEAD_SHA}" >> "$GITHUB_OUTPUT"
59+
echo "merge_base=${MERGE_BASE} head=${HEAD_SHA}"
60+
61+
- name: Checkout ITK at merge-base (shallow)
62+
uses: actions/checkout@v4
63+
with:
64+
ref: ${{ steps.sha.outputs.merge_base }}
65+
path: itk-base
66+
67+
- name: Set up Python
68+
uses: actions/setup-python@v5
69+
with:
70+
python-version: "3.11"
71+
72+
- name: Install Ninja + ASV
73+
run: |
74+
sudo apt-get update
75+
sudo apt-get install -y --no-install-recommends ninja-build
76+
python -m pip install "asv>=0.6,<0.7"
77+
78+
- name: Configure + build merge-base benchmark targets
79+
env:
80+
ITK_SRC: ${{ github.workspace }}/itk-base
81+
ITK_BUILD: ${{ runner.temp }}/ITK-build-base
82+
run: |
83+
set -e
84+
cmake -S "${ITK_SRC}" -B "${ITK_BUILD}" -GNinja \
85+
-DCMAKE_BUILD_TYPE=Release \
86+
-DBUILD_SHARED_LIBS=OFF \
87+
-DBUILD_TESTING=ON \
88+
-DBUILD_EXAMPLES=ON \
89+
-DITK_WRAP_PYTHON=OFF \
90+
-DModule_PerformanceBenchmarking=ON
91+
cmake --build "${ITK_BUILD}" --target ${BenchmarkTargets} || \
92+
echo "NOTE: merge-base may lack some benchmark targets if the pin predates them; asv will surface per-benchmark failures as '--'."
93+
94+
- name: Configure + build PR HEAD benchmark targets
95+
env:
96+
ITK_SRC: ${{ github.workspace }}/itk-head
97+
ITK_BUILD: ${{ runner.temp }}/ITK-build-head
98+
run: |
99+
set -e
100+
cmake -S "${ITK_SRC}" -B "${ITK_BUILD}" -GNinja \
101+
-DCMAKE_BUILD_TYPE=Release \
102+
-DBUILD_SHARED_LIBS=OFF \
103+
-DBUILD_TESTING=ON \
104+
-DBUILD_EXAMPLES=ON \
105+
-DITK_WRAP_PYTHON=OFF \
106+
-DModule_PerformanceBenchmarking=ON
107+
cmake --build "${ITK_BUILD}" --target ${BenchmarkTargets}
108+
109+
- name: Stage ASV harness (PR HEAD pin) with itk-repo symlink
110+
id: harness
111+
run: |
112+
set -e
113+
HARNESS="${GITHUB_WORKSPACE}/itk-head/Modules/Remote/PerformanceBenchmarking"
114+
if [ ! -f "${HARNESS}/asv.conf.json" ]; then
115+
echo "ERROR: ASV harness not found at ${HARNESS}/asv.conf.json." >&2
116+
echo " Modules/Remote/PerformanceBenchmarking.remote.cmake must pin" >&2
117+
echo " a commit with the ASV harness (introduced by" >&2
118+
echo " InsightSoftwareConsortium/ITKPerformanceBenchmarking#111)." >&2
119+
exit 1
120+
fi
121+
ln -sfn "${GITHUB_WORKSPACE}/itk-head" "${HARNESS}/itk-repo"
122+
python -m pip install -e "${HARNESS}/python"
123+
echo "harness=${HARNESS}" >> "$GITHUB_OUTPUT"
124+
125+
- name: Register ASV machine
126+
working-directory: ${{ steps.harness.outputs.harness }}
127+
run: asv machine --yes --machine gha-ubuntu-24.04
128+
129+
- name: Run ASV at merge-base
130+
working-directory: ${{ steps.harness.outputs.harness }}
131+
continue-on-error: true
132+
env:
133+
ITK_BENCHMARK_BIN: ${{ runner.temp }}/ITK-build-base/bin
134+
ITK_BENCHMARK_DATA: ${{ runner.temp }}/ITK-build-base/ExternalData/Modules/Remote/PerformanceBenchmarking/examples/Data/Input
135+
ITK_BENCHMARK_SCRATCH: ${{ runner.temp }}/asv-scratch-base
136+
run: |
137+
mkdir -p "${ITK_BENCHMARK_SCRATCH}"
138+
asv run --machine gha-ubuntu-24.04 \
139+
--set-commit-hash "${{ steps.sha.outputs.merge_base }}" --quick
140+
141+
- name: Run ASV at PR HEAD
142+
working-directory: ${{ steps.harness.outputs.harness }}
143+
env:
144+
ITK_BENCHMARK_BIN: ${{ runner.temp }}/ITK-build-head/bin
145+
ITK_BENCHMARK_DATA: ${{ runner.temp }}/ITK-build-head/ExternalData/Modules/Remote/PerformanceBenchmarking/examples/Data/Input
146+
ITK_BENCHMARK_SCRATCH: ${{ runner.temp }}/asv-scratch-head
147+
run: |
148+
mkdir -p "${ITK_BENCHMARK_SCRATCH}"
149+
asv run --machine gha-ubuntu-24.04 \
150+
--set-commit-hash "${{ steps.sha.outputs.head }}" --quick
151+
152+
- name: Compare base vs HEAD
153+
working-directory: ${{ steps.harness.outputs.harness }}
154+
continue-on-error: true
155+
run: |
156+
asv compare \
157+
"${{ steps.sha.outputs.merge_base }}" \
158+
"${{ steps.sha.outputs.head }}" \
159+
--machine gha-ubuntu-24.04 \
160+
| tee asv-compare.txt
161+
162+
- name: Upload ASV results
163+
if: always()
164+
uses: actions/upload-artifact@v4
165+
with:
166+
name: asv-ubuntu-24.04-${{ github.run_id }}
167+
path: |
168+
${{ steps.harness.outputs.harness }}/.asv/results/
169+
${{ steps.harness.outputs.harness }}/asv-compare.txt
170+
retention-days: 14
171+
if-no-files-found: warn

Modules/Remote/PerformanceBenchmarking.remote.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@ For more information, see::
5959
"
6060
MODULE_COMPLIANCE_LEVEL 2
6161
GIT_REPOSITORY https://github.com/InsightSoftwareConsortium/ITKPerformanceBenchmarking.git
62-
GIT_TAG 7950c1d76095033edbf7601a925cdacc2fe717f9
62+
GIT_TAG 41bf1b9cfbaa1b146e1b3e5d3ad3571b2203ce1e
6363
)

0 commit comments

Comments
 (0)