Skip to content

ASV custom build command and file-based benchmark triggers #5776

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

Merged
merged 22 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6fd04e6
Trigger benchmarks if lock files have changed.
trexfeathers Feb 22, 2024
9cb5830
Check for 'true' string not boolean
trexfeathers Feb 22, 2024
621a774
Temporarily disable other CI.
trexfeathers Feb 23, 2024
bce39e3
Limit branch actions to pull requests
trexfeathers Feb 23, 2024
4c18e23
Unified continue check.
trexfeathers Feb 23, 2024
8f097b1
Benchmarks temporary debug mode.
trexfeathers Feb 23, 2024
5522251
Demonstrate lock file trigger for benchmarks.
trexfeathers Feb 23, 2024
fbb4ab7
Demonstrate overnight mode.
trexfeathers Feb 23, 2024
d18f300
Revert "Demonstrate overnight mode."
trexfeathers Feb 23, 2024
5a5edca
Revert "Demonstrate lock file trigger for benchmarks."
trexfeathers Feb 23, 2024
cc03034
Minor visual improvements.
trexfeathers Feb 23, 2024
2c41fb5
Explanatory notes.
trexfeathers Feb 23, 2024
7806ff5
Revert "Benchmarks temporary debug mode."
trexfeathers Feb 23, 2024
bff3510
Revert "Temporarily disable other CI."
trexfeathers Feb 23, 2024
b3660bd
Fix docs indentation.
trexfeathers Feb 23, 2024
14a8f35
Custom ASV build command using setup.py.
trexfeathers Feb 27, 2024
c490597
Remove ASV pin.
trexfeathers Feb 27, 2024
218bdb7
Don't trigger benchmarks when pyproject.toml changes.
trexfeathers Feb 27, 2024
6030c98
More accurate name for files-changed step.
trexfeathers Feb 27, 2024
b95548b
Don't have a continue output.
trexfeathers Feb 27, 2024
21b1b91
Remove confusing variable name clash.
trexfeathers Feb 27, 2024
cd19693
Update What's New entry.
trexfeathers Feb 27, 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
11 changes: 7 additions & 4 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Make sure any dependency changes are benchmarked (only changes to the locks
# make a material difference - changes to the Conda YAML files are not
# benchmarked).
# benchmark_this automatically triggers the benchmark workflow when added by
# a user. No triggering happens when GitHub Actions adds the label (this
# avoids security vulnerabilities), so alternative triggers for the below
# files are therefore included in workflows/benchmarks_run.yml. Automatic
# labelling is still included here to make it easier to search pull requests,
# and to reinforce the culture of using this label.
benchmark_this:
- changed-files:
- any-glob-to-any-file: 'requirements/locks/*.lock'
- any-glob-to-any-file: ['requirements/locks/*.lock', "setup.py"]
5 changes: 5 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@

---
[Consult Iris pull request check list]( https://scitools-iris.readthedocs.io/en/latest/developers_guide/contributing_pull_request_checklist.html)

---
Add any of the below labels to trigger actions on this PR:

- https://github.com/SciTools/iris/labels/benchmark_this
47 changes: 39 additions & 8 deletions .github/workflows/benchmarks_run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,46 @@ on:
required: false
type: string
pull_request:
types: [labeled]
# Add the `labeled` type to the default list.
types: [labeled, opened, synchronize, reopened]

jobs:
pre-checks:
runs-on: ubuntu-latest
if: github.repository == 'SciTools/iris'
outputs:
overnight: ${{ steps.overnight.outputs.check }}
branch: ${{ steps.branch.outputs.check }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- id: files-changed
uses: marceloprado/has-changed-path@df1b7a3161b8fb9fd8c90403c66a9e66dfde50cb
with:
# SEE ALSO .github/labeler.yml .
paths: requirements/locks/*.lock setup.py
- id: overnight
if: github.event_name != 'pull_request'
run: echo "check=true" >> "$GITHUB_OUTPUT"
- id: branch
if: >
github.event_name == 'pull_request'
&&
(
steps.files-changed.outputs.changed == 'true'
||
github.event.label.name == 'benchmark_this'
)
run: echo "check=true" >> "$GITHUB_OUTPUT"


benchmark:
if: >
github.repository == 'SciTools/iris' &&
(github.event_name != 'pull_request' ||
github.event.label.name == 'benchmark_this')
runs-on: ubuntu-latest
needs: pre-checks
if: >
needs.pre-checks.outputs.overnight == 'true' ||
needs.pre-checks.outputs.branch == 'true'

env:
IRIS_TEST_DATA_LOC_PATH: benchmarks
Expand All @@ -42,7 +73,7 @@ jobs:

- name: Install ASV & Nox
run: |
pip install "asv!=0.6.2" nox
pip install asv nox

- name: Cache environment directories
id: cache-env-dir
Expand Down Expand Up @@ -76,7 +107,7 @@ jobs:
echo "OVERRIDE_TEST_DATA_REPOSITORY=${GITHUB_WORKSPACE}/${IRIS_TEST_DATA_PATH}/test_data" >> $GITHUB_ENV

- name: Benchmark this pull request
if: ${{ github.event.label.name == 'benchmark_this' }}
if: needs.pre-checks.outputs.branch == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
Expand All @@ -85,7 +116,7 @@ jobs:

- name: Run overnight benchmarks
id: overnight
if: ${{ github.event_name != 'pull_request' }}
if: needs.pre-checks.outputs.overnight == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
Expand Down
4 changes: 4 additions & 0 deletions benchmarks/asv.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"environment_type": "conda-delegated",
"show_commit_url": "https://github.com/scitools/iris/commit/",
"branches": ["upstream/main"],
"build_command": [
"python setup.py build",
"python -mpip wheel --no-deps -w {build_cache_dir} {build_dir}"
],

"benchmark_dir": "./benchmarks",
"env_dir": ".asv/env",
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/bm_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def _gh_create_reports(commit_sha: str, results_full: str, results_shifts: str)
performance_report = dedent(
(
"""
### Performance Benchmark Report: {commit_sha}
# :stopwatch: Performance Benchmark Report: {commit_sha}

<details>
<summary>Performance shifts</summary>
Expand Down
9 changes: 4 additions & 5 deletions docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,10 @@ This document explains the changes made to Iris for this release
💼 Internal
===========

#. `@trexfeathers`_ used the `Pull Request Labeler Github action`_ to add the
``benchmark_this`` label (:ref:`more info <on_demand_pr_benchmark>`) to
pull requests that modify ``requirements/locks/*.lock`` files - ensuring
that we know whether dependency changes will affect performance.
(:pull:`5763`)
#. `@trexfeathers`_ setup automatic benchmarking on pull requests that modify
files likely to affect performance or performance testing. Such pull
requests are also labelled using the `Pull Request Labeler Github action`_
to increase visibility. (:pull:`5763`, :pull:`5776`)


.. comment
Expand Down