Skip to content

Commit b0c0cfc

Browse files
authored
ci: Benchmark with CodSpeed.io (#187)
Experimentally replace the [bencher.dev](https://bencher.dev/perf/portgraph) CI with [codspeed's](https://codspeed.io/CQCL/portgraph). On first review I had overlooked codspeed's criterion wrapper that replaces the multi-run benchmarks with a single-run equivalent, similar to iai's.
1 parent aebb42e commit b0c0cfc

File tree

4 files changed

+21
-75
lines changed

4 files changed

+21
-75
lines changed

.github/workflows/archive-bencher.yml

-20
This file was deleted.

.github/workflows/ci.yml

+12-50
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
run: cargo miri test
5555

5656
benches:
57-
name: continuous Benchmarking
57+
name: continuous benchmarking
5858
# Not required, we can ignore it for the merge queue check.
5959
if: github.event_name != 'merge_group'
6060
runs-on: ubuntu-latest
@@ -67,56 +67,18 @@ jobs:
6767
- uses: Swatinem/rust-cache@v2
6868
with:
6969
prefix-key: v0
70-
71-
# The installed iai-callgrind-runner version must match the
72-
# version of iai-callgrind in the Cargo.toml
7370
- uses: cargo-bins/cargo-binstall@main
74-
- name: Install iai-callgrind-runner
75-
run: |
76-
version=$(cargo metadata --format-version=1 |\
77-
jq '.packages[] | select(.name == "iai-callgrind").version' |\
78-
tr -d '"'
79-
)
80-
cargo binstall --no-confirm iai-callgrind-runner --version $version --force
81-
82-
- uses: bencherdev/bencher@main
83-
- name: Install valgrind
84-
run: sudo apt update && sudo apt install -y valgrind
85-
86-
- name: Track base branch IAI benchmarks
87-
if: github.event_name == 'push'
88-
run: |
89-
bencher run \
90-
--project portgraph \
91-
--token '${{ secrets.BENCHER_API_TOKEN }}' \
92-
--branch main \
93-
--testbed ubuntu-latest \
94-
--threshold-measure instructions \
95-
--threshold-test t_test \
96-
--threshold-max-sample-size 64 \
97-
--threshold-upper-boundary 0.99 \
98-
--thresholds-reset \
99-
--err \
100-
--github-actions '${{ secrets.HUGRBOT_PAT }}' \
101-
--adapter rust_iai_callgrind \
102-
"cargo bench --bench iai_benches"
103-
104-
- name: Track PR IAI benchmarks
105-
if: github.event_name == 'pull_request'
106-
run: |
107-
bencher run \
108-
--project portgraph \
109-
--token '${{ secrets.BENCHER_API_TOKEN }}' \
110-
--branch "${{ github.event.pull_request.head.ref }}" \
111-
--testbed ubuntu-latest \
112-
--start-point "${{ github.event.pull_request.base.ref }}" \
113-
--start-point-clone-thresholds \
114-
--start-point-reset \
115-
--err \
116-
--github-actions '${{ secrets.HUGRBOT_PAT }}' \
117-
--adapter rust_iai_callgrind \
118-
"cargo bench --bench iai_benches"
119-
# --start-point-hash '${{ github.event.pull_request.base.sha }}' \
71+
- name: Install cargo-codspeed
72+
run: cargo binstall cargo-codspeed --force
73+
- name: Override criterion with the CodSpeed harness
74+
run: cargo add --dev codspeed-criterion-compat --rename criterion
75+
- name: Build benchmarks
76+
run: cargo codspeed build criterion_benches --profile bench
77+
- name: Run benchmarks
78+
uses: CodSpeedHQ/action@v3
79+
with:
80+
token: ${{ secrets.CODSPEED_TOKEN }}
81+
run: "cargo codspeed run criterion_benches"
12082

12183
tests:
12284
runs-on: ubuntu-latest

DEVELOPMENT.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,15 @@ This is the simplest kind of benchmark. To run the, use:
5959
cargo bench --bench criterion_benches
6060
```
6161

62+
We run these on CI to track historical performance using a special single-shot test harness,
63+
and upload them to [codspeed.io](https://codspeed.io/CQCL/portgraph).
64+
6265
### Single-shot benchmarking
6366

64-
These benchmarks are useful when running in noisy environments, in addition to
65-
being faster than criterion. We run these on CI to track historical performance
66-
in [bencher.dev](https://bencher.dev/perf/portgraph).
67+
We use [`iai-callgrind`](https://iai-callgrind.github.io/iai-callgrind) for
68+
single-shot benchmarking, measuring instruction counts rather than wall-clock
69+
time. These benchmarks are more precise when running in noisy environments, in
70+
addition to being faster than criterion.
6771

6872
To run these, you must have [`valgrind`](https://valgrind.org/) installed.
6973
Support for Apple Silicon (M1/M2/...) macs is

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ portgraph
55
[![crates][]](https://crates.io/crates/portgraph)
66
[![msrv][]](https://github.com/CQCL/portgraph)
77
[![codecov][]](https://codecov.io/gh/CQCL/portgraph)
8-
[![bencher][]](https://bencher.dev/perf/portgraph)
8+
[![codspeed][]](https://codspeed.io/CQCL/portgraph)
99

1010
Data structure library for directed graphs with first-level ports. Includes
1111
secondary data structures for node and port weights, and node hierarchies.
@@ -38,5 +38,5 @@ This project is licensed under Apache License, Version 2.0 ([LICENSE][] or http:
3838
[LICENSE]: LICENCE
3939
[msrv]: https://img.shields.io/badge/rust-1.75.0%2B-blue.svg?maxAge=3600
4040
[codecov]: https://img.shields.io/codecov/c/gh/CQCL/portgraph?logo=codecov
41-
[bencher]: https://img.shields.io/badge/bencher-.dev-blue.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAtFBMVEVHcEwEBAT+/v4AAADi4uKenp7u7/ABAQEAAAAAAAAAAAAwMDAAAAAAAAAAAACGh4e2tLJfX18AAAAAAAD///++wMEAAABoaGiRkZEAAABucXMAAAAAAAB1dXUxMTHMzMzh4eH/0rRJSUmsrKz29vb////+q3v8bQD9+PP/8+kZGhp9fn/8dAD/3cXk4OT/tIL9p2z8ZwD+vI+UlJTPmnn/5tT/xqH/2cD9k1D9kkL8ijj8fhszkVn/AAAAJXRSTlMA4fgz7ePq/o3zRv0hfcfb7dJoVubyDvvpqfjTt+Dl+tTz3uPjxce2cgAAAaJJREFUOI2lklmTqjAQhcMSOpFFQHB3nJl7O2wii46z/f//daOOJYkvU3XPA6Q4X53udEPIbxWv1+x2ZsF6ovsLd05n/PJ5wmd07jLVj7mDaFKwCPE4NREdrmbwEOu+MOerKQnmZtHXGBpDfwp28dV9YgKWxf/iZ/dV2OV0CLjO227X1cgnE451t9u9Oa43jChtCWQ9vsbxK/aZBOxS6cFI848sE7jx/Q2KLPvIU6UHwiJszsCYsfEZaDBS72nxJO/uQJcn3FIHEVBsuxvQtUgDbZIj1ym+BUZBEKH4Lhx3pM+aUzy1GBlGhO0JqaH7ZARy2Dc58BBAGDzfgWdguu+7gwAZoW/T4jYqsrUiK4qa1DanpQw4VObVM6uDjCiHy4pnJqYA1RWoAFI0Z/HwChW+HwEOV+AAcHzHiilA3TbH8FY/PDZtrQD+8kWIppBecXk0Qrws/QHglfZJ/oeIuRC5fNX9SW2SGBTPRo77/c9hrG7D4uml+l7qctNQ/x9GsEnuU0qWj9vyFvwp3NpS2z9PsPB0/1zGDziUJfCV/7js/9A/nA48HxVN/KwAAAAASUVORK5CYII=
41+
[codspeed]: https://img.shields.io/endpoint?url=https://codspeed.io/badge.json
4242
[CHANGELOG]: CHANGELOG.md

0 commit comments

Comments
 (0)