Skip to content

Commit 105874a

Browse files
Add benchmarks framework
Add performance benchmarking infrastructure for fromager including GitHub Actions workflows for nightly and on-demand runs. Signed-off-by: Michael Yochpaz <myochpaz@redhat.com>
1 parent f6e78fb commit 105874a

14 files changed

Lines changed: 3862 additions & 0 deletions

File tree

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Nightly Integration Benchmarks
2+
3+
on:
4+
schedule:
5+
- cron: "0 2 * * *" # 2 AM UTC daily
6+
workflow_dispatch: # Allow manual trigger
7+
8+
jobs:
9+
integration-benchmark:
10+
runs-on: ubuntu-latest
11+
12+
services:
13+
local-pypi:
14+
image: pypiserver/pypiserver:latest
15+
ports:
16+
- 8080:8080
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.11"
25+
26+
- name: Install hatch
27+
run: pip install hatch
28+
29+
- name: Download packages for local PyPI
30+
run: |
31+
mkdir -p packages
32+
pip download -r benchmarks/requirements/packages.txt -d packages
33+
# Note: In production, these would be copied to the pypiserver volume
34+
35+
- name: Run integration benchmarks with CodSpeed
36+
uses: CodSpeedHQ/action@v3
37+
env:
38+
CODSPEED_VALGRIND_ARGS: "--trace-children=yes --trace-children-skip=/bin/sh,/usr/bin/git"
39+
UV_INDEX_URL: "http://localhost:8080/simple"
40+
UV_NO_PROGRESS: "1"
41+
with:
42+
token: ${{ secrets.CODSPEED_TOKEN }}
43+
run: hatch run benchmark:run --codspeed -m "integration"
44+
45+
- name: Generate benchmark JSON (fallback)
46+
if: always()
47+
env:
48+
UV_INDEX_URL: "http://localhost:8080/simple"
49+
UV_NO_PROGRESS: "1"
50+
run: |
51+
hatch run benchmark:run \
52+
--benchmark-only \
53+
--benchmark-json=integration-benchmark-results.json \
54+
-m "integration" || true
55+
56+
- name: Upload benchmark results
57+
uses: actions/upload-artifact@v4
58+
if: always()
59+
with:
60+
name: integration-benchmark-results
61+
path: integration-benchmark-results.json
62+
retention-days: 90
63+
64+
- name: Run memory profiling on integration tests
65+
if: always()
66+
env:
67+
UV_INDEX_URL: "http://localhost:8080/simple"
68+
UV_NO_PROGRESS: "1"
69+
run: |
70+
hatch run benchmark:memory \
71+
--memray-bin-path=integration-memray-results \
72+
-m "integration" || true
73+
74+
- name: Upload memory results
75+
uses: actions/upload-artifact@v4
76+
if: always()
77+
with:
78+
name: integration-memory-results
79+
path: integration-memray-results/
80+
retention-days: 90

.github/workflows/benchmarks.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Benchmarks
2+
3+
on:
4+
pull_request:
5+
types: [labeled, synchronize]
6+
push:
7+
branches: [main]
8+
9+
jobs:
10+
benchmark-cpu:
11+
# Only run on PRs with 'run-benchmarks' label OR on main branch
12+
if: |
13+
github.event_name == 'push' ||
14+
contains(github.event.pull_request.labels.*.name, 'run-benchmarks')
15+
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.11"
25+
26+
- name: Install hatch
27+
run: pip install hatch
28+
29+
- name: Run benchmarks with CodSpeed
30+
uses: CodSpeedHQ/action@v3
31+
with:
32+
token: ${{ secrets.CODSPEED_TOKEN }}
33+
run: hatch run benchmark:run --codspeed -m "not slow and not integration"
34+
35+
- name: Generate benchmark JSON (fallback)
36+
if: always()
37+
run: |
38+
hatch run benchmark:run \
39+
--benchmark-only \
40+
--benchmark-json=benchmark-results.json \
41+
-m "not slow and not integration" || true
42+
43+
- name: Upload benchmark results
44+
uses: actions/upload-artifact@v4
45+
if: always()
46+
with:
47+
name: benchmark-results
48+
path: benchmark-results.json
49+
retention-days: 30
50+
51+
benchmark-memory:
52+
# Only run on PRs with 'run-benchmarks' label
53+
if: contains(github.event.pull_request.labels.*.name, 'run-benchmarks')
54+
55+
runs-on: ubuntu-latest
56+
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- name: Set up Python
61+
uses: actions/setup-python@v5
62+
with:
63+
python-version: "3.11"
64+
65+
- name: Install hatch
66+
run: pip install hatch
67+
68+
- name: Run memory benchmarks
69+
run: |
70+
hatch run benchmark:memory \
71+
--memray-bin-path=memray-results \
72+
-m "not slow and not integration"
73+
74+
- name: Upload memory results
75+
uses: actions/upload-artifact@v4
76+
if: always()
77+
with:
78+
name: memory-results
79+
path: memray-results/
80+
retention-days: 30

0 commit comments

Comments
 (0)