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

asv benchmark setup #151

Merged
merged 7 commits into from
Oct 19, 2023
Merged

Conversation

scottstanie
Copy link
Collaborator

@scottstanie scottstanie commented Oct 19, 2023

(Dumping some of my initial notes about why I ended up picking this)

Airspeed Velocity (asv) seems to be the best existing way to run a few benchmarks and get progress over time. It's used by numpy, pandas, scikit-image, xarray, and a few others.

Basics: making these new configuration files, and running test benchmarks

  1. I installed asv (which is added to the test requirements), ran asf quickstart to make a template asv.conf.json, then filled it out
  2. To run locally, you can run asv machine or asv machine --yes to have it save info about the computer you are on
  3. Runing benchmarks with asv run will install the environment(s) that are specified, and these can be reused for future runs.
  4. You compile the results with asv publish, and view locally with asv preview

Naming the benchmark tests

The benchmarks almost look like normal pytest or UnitTest files, except all the names have time_ or mem_ as the function names... And that's because asv will use that to figure out what it's tracking

  • time_<blah> will run a function (and call the result whatever you've named this function). and measure the runtime
  • peakmem_<blah> records the peak memory usage

Using it in CI

  • You can run against a specific git commit, or a tag, like
asv run v0.5.0^!

This PR is attempting to have a nice way to trigger this on Github actions only if you want it run on specific PRs (which I do), rather than every single change/push.
This section of the new Github Action:

on:
  pull_request:
    types: [labeled]

jobs:
  benchmark:
    if: ${{ github.event.label.name == 'run-benchmark' && github.event_name == 'pull_request' }}

means that when you label a PR with "run-benchmark" it should kick off the asv workflow. If you add more commits, you'll need to remove and re-add if you want it run again. You can also go to the "Actions" tab to run it.

Running on our big server

I started the test_run_bench.sh script for running on aurora, where I manually set the number of threads and use asvs --cpu-affinity 0-15 option to really limit the number of cores.

(The problem with only running this on the CI is that it'll be single CPU... we're also interested in how the main functions perform with access to multiple CPUs, since that's the more realistic setting. Open to discussing this part more.)

Examples repos' example usages

@scottstanie scottstanie added the run-benchmark Label which triggers a benchmark run on a PR label Oct 19, 2023
@scottstanie scottstanie added run-benchmark Label which triggers a benchmark run on a PR and removed run-benchmark Label which triggers a benchmark run on a PR labels Oct 19, 2023
@scottstanie
Copy link
Collaborator Author

scottstanie commented Oct 19, 2023

As a preview of what this gives us (this is from running it on aurora):

image image

it seems like it might be possible to merge results from multiple machines too. I'm not too worried about that, since this alone was about 90% of what I wanted in the first place- you can tell from the bottom plot that with 20 SLCs, phase linking on CPU is taking ~4 seconds. For COMPASS-sized SLCs, that's ~18-20 minutes for the whole stack, which lines up quite well with the other rough time estimates we'd been giving.

@scottstanie scottstanie merged commit 718cb51 into isce-framework:main Oct 19, 2023
4 checks passed
@scottstanie scottstanie deleted the asv-benchmark-setup branch October 19, 2023 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-benchmark Label which triggers a benchmark run on a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant