Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Start adding some basic benchmarking infrastructure #372

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
593b672
Add very very basic benchmark test just to get things rolling
SolarDrew Apr 17, 2024
de7ef0b
Add tox env
SolarDrew Apr 17, 2024
dac0e20
Add benchmarks tox env to gh jobs list
SolarDrew Apr 17, 2024
a99d255
Move unzipping out of benchmark to just measure opening the asdf
SolarDrew Apr 18, 2024
bfc31c5
Pull benchmark data for latest release and compare
SolarDrew Apr 22, 2024
76e4e92
Add tox env for benchmarking main and tweak not-main benchmark run
SolarDrew Apr 22, 2024
b6d0792
Add workflow to run benchmarks on main
SolarDrew Apr 22, 2024
82332ea
Make file copying work in tox
SolarDrew Apr 24, 2024
0d59140
Make github workflow push main benchmark results to repo
SolarDrew Apr 24, 2024
2edc30d
Make some steps towards getting gh worklow working
SolarDrew Apr 24, 2024
075e6de
Need to actually push changes for github workflow to see them
SolarDrew Apr 24, 2024
3e3cafd
Make workflow push benchmark to repo
SolarDrew Apr 24, 2024
234af5d
Make tox do it instead
SolarDrew Apr 24, 2024
36bd260
Using different version of Python for workflow and local clearly a ba…
SolarDrew Apr 24, 2024
fe83f56
Committing needs user config
SolarDrew Apr 24, 2024
31895ed
Need to know why push isn't working
SolarDrew Apr 25, 2024
18700f2
Try disabling git terminal prompts
SolarDrew Apr 25, 2024
ddde74a
Well that hasn't helped, it just errors instead of hanging
SolarDrew Apr 25, 2024
831c41d
Try doing the git bit in the workflow instead again
SolarDrew Apr 25, 2024
fae780a
Share volumes across docker images so we can commit results in the wo…
SolarDrew Apr 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/benchmark-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Run benchmarks for main

on:
workflow_dispatch:
push:
branches:
- 'main'
schedule:
# ┌───────── minute (0 - 59)
# │ ┌───────── hour (0 - 23)
# │ │ ┌───────── day of the month (1 - 31)
# │ │ │ ┌───────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────── day of the week (0 - 6 or SUN-SAT)
- cron: '0 9 * * 1' # Every Monday at 0900 UTC

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
benchmarks:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main
container:
volumes:
- ~:/github
with:
default_python: '3.10'
envs: |
- linux: benchmark-main

update-repo:
runs-on: ubuntu-latest
container:
volumes:
- ~:/github
needs: [benchmarks]
run: |
git clone https://github.com/DKISTDC/dkist-benchmarks.git /github/dkist-benchmarks
cd /dkist-benchmarks
git add main.json
git commit -m "Update benchmark data for main"
git push origin main
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
- windows: py311-online
- macos: py310
- linux: py310-oldestdeps
- linux: benchmarks
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Expand Down
17 changes: 17 additions & 0 deletions dkist/tests/test_benchmarks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import gzip
from pathlib import Path

from dkist import load_dataset
from dkist.data.test import rootdir


def load_asdf(vispdir):
ds = load_dataset(vispdir / "test_visp.asdf")


def test_load_asdf(benchmark, tmp_path_factory):
vispdir = tmp_path_factory.mktemp("data")
with gzip.open(Path(rootdir) / "large_visp.asdf.gz", mode="rb") as gfo:
with open(vispdir / "test_visp.asdf", mode="wb") as afo:
afo.write(gfo.read())
benchmark(load_asdf, vispdir)
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ tests = [
"pytest-mpl",
"pytest-httpserver",
"pytest-filter-subpackage",
"pytest-benchmark",
"hypothesis",
"tox",
"pydot",
Expand Down
15 changes: 15 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ envlist =
py310-oldestdeps
build_docs{,-notebooks}
codestyle
benchmarks

[testenv]
pypi_filter = https://raw.githubusercontent.com/sunpy/sunpy/main/.test_package_pins.txt
Expand Down Expand Up @@ -89,3 +90,17 @@ commands =
!notebooks: sphinx-build -j 1 --color -W --keep-going -b html -d _build/.doctrees . _build/html -D nb_execution_mode=off {posargs}
notebooks: sphinx-build -j 1 --color -W --keep-going -b html -d _build/.doctrees . _build/html {posargs}
python -c 'import pathlib; print("Documentation available under file://\{0\}".format(pathlib.Path(r"{toxinidir}") / "docs" / "_build" / "index.html"))'

[testenv:benchmarks]
description = Run benchmarks on PR and compare against main to ensure there are no performance regressions
allowlist_externals=git
commands =
git clone https://github.com/DKISTDC/dkist-benchmarks.git {env_tmp_dir}/dkist-benchmarks
{env:PYTEST_COMMAND} -k test_benchmarks --benchmark-autosave --benchmark-compare={env_tmp_dir}/dkist-benchmarks/main.json --benchmark-compare-fail=mean:5%

[testenv:benchmark-main]
description = Run benchmarks on main to keep comparison data up to date
allowlist_externals = git,cp
commands =
{env:PYTEST_COMMAND} -k test_benchmarks --benchmark-save=main
cp {toxinidir}/.tmp/benchmark-main/.benchmarks/Linux-CPython-3.10-64bit/0001_main.json /github/main.json
Loading