-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
CI: Run benchmarks #8779
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
CI: Run benchmarks #8779
Conversation
.circleci/config.yml
Outdated
| ram=$(awk -F"[: ]+" '/MemTotal/ {print $2;exit}' /proc/meminfo) | ||
| os=$(uname -sr) | ||
| printf "{\n\"CircleCI\": {\n\"arch\": \"${arch}\",\n\"cpu\": \"${cpu}\",\n\"machine\": \"CircleCI\",\n\"os\": \"${os}\",\n\"ram\": \"${ram}\"\n},\n\"version\": 1\n}" | tee ~/.asv-machine.json | ||
| python -u runtests.py --bench |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll be interested to hear what @pv and others think about this -- in the past I think discussions about adding asv stuff directly to CI were not favorable, but perhaps infrastructure has advanced sufficiently now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have been doing ~2-hour doc builds on master commits on CircleCI on a repo with a similar master-commit-rate for a year or two now. Assuming the time here is in this ballpark and that the number of benchmark-related PRs stays in some reasonable range, this should be fine.
In the future if we get too many PRs, we can start limiting it to master commits only.
|
It got 91% done then timed out on "No output for 10 minutes": @tylerjereddy do you know if there is some particularly slow benchmark that could be split into multiple benchmarks to avoid this? |
|
@larsoner What about adding the From the linked docs there, |
|
I think you'll need the brackets around the |
|
Okay that only took 40 minutes. I think the doc build is around 30. The output does not seem too useful: https://6741-1460385-gh.circle-artifacts.com/0/html-benchmarks/index.html |
|
Looks like there may be 1 or 2 issues (a few Exceptions are raised) in the text output that I see for the benchmarks in the Circle CI console. Does it make sense that only about 12 benchmarks are performed? I guess I normally use |
.circleci/config.yml
Outdated
| . venv/bin/activate | ||
| export SHELL=$(which bash) | ||
| if ! git remote -v | grep upstream ; then git remote add upstream git://github.com/scipy/scipy.git; fi | ||
| changed=$(git diff --name-only $CIRCLE_BRANCH $(git merge-base $CIRCLE_BRANCH upstream/master)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I seem to recall circleci had some syntax to do exactly this (run only if changs under some path), maybe useful to check its docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't find an official implementation, just ideas
|
NumPy has been doing a quick In particular, they use |
a3a9eca to
53f9eca
Compare
I went with the |
|
Okay it runs and renders! The output is not terribly useful, I can't find any benchmarks: https://21265-1460385-gh.circle-artifacts.com/0/html-benchmarks/index.html It would be good if some
This is now ready for review/merge from my end. |
|
There's a bunch of errors during the asv run (e.g. `NameError: name 'magic_square' is not defined), but CI is green. Would be good to make CI fail in this PR, then have a separate PR to fix the bugs that we can merge straight away, and then rebase this PR onto master. |
|
Running benchmarks in only a couple of minutes in CI is great by the way! |
.circleci/config.yml
Outdated
| export PYTHONPATH=$PWD/build/testenv/lib/python3.7/site-packages | ||
| cd benchmarks | ||
| asv machine --machine CircleCI | ||
| asv --config asv.conf.json dev -m CircleCI --python=same --bench [-q] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this [-q] regular expression? It has been awhile since I worked with regular expressions, but doesn't this restrict to only test cases containing a q or a - somewhere in the name or parameters?
With --bench [-q] 41 benchmarks are found, but without this argument asv finds 234 benchmarks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see above that this -q was probably intended to cause "quick" operation but it is instead being interpreted as a regular expression corresponding to the --bench argument.
According to the ASV docs asv dev is already equivalent to asv run --quick --show-stderr --python=same, so I don't think -q needs to be specified to get quick operation.
Unfortunately, removing it is going to make running the benchmarks take much longer as many that didn't match the regular expression were being skipped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see above that this -q was probably intended to cause "quick" operation but it is instead being interpreted as a regular expression corresponding to the --bench argument.
Indeed, I assumed that this was intentional from comments above but I think I misinterpreted them. I agree it's not great to skip that many. I guess we'll see how long it takes to run all of them.
Maybe we'll need to somehow mark some benchmarks as slow so that they aren't run on CircleCI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#12732 would give us some ideas for how to do this maybe
Almost all benchmarks have the boilerplate code along the lines of: I think this is intentional. I guess that we could have an env var |
larsoner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Fixed the bugs with importing. It'll now raise an error when
SCIPY_ALLOW_BENCH_IMPORT_ERRORS=0, which it is in CircleCI (and some failures are visible, for example here) so it seems to be working. - Takes about ~20 minutes to run (which happens in parallel with the doc build, which is ~16 min) after the ~10 minute build time, so hopefully in the same ~30 minute total range as the other elements of the test suite.
- The artifact is still worthless, but that can be a follow-up PR for someone who knows how to make it useful. But at least the CI mechanics should be sorted out.
Ready for review/merge from my end!
| "Note that it can take several hours to run; intermediate output\n" | ||
| "can be found under benchmarks/global-bench-results.json\n" | ||
| "You can specify functions to benchmark via SCIPY_GLOBAL_BENCH=AMGM,Adjiman,...") | ||
| raise NotImplementedError() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pv I had to get rid of this -- it made every of the (hundreds?) of skipped ones emit this message, which made the CircleCI log and local terminal output overly verbose. I refactored it to be code comments above instead
.circleci/config.yml
Outdated
| asv machine --machine CircleCI | ||
| export SCIPY_GLOBAL_BENCH_NUMTRIALS=1 | ||
| export SCIPY_ALLOW_BENCH_IMPORT_ERRORS=0 | ||
| time asv --config asv.conf.json dev -m CircleCI --python=same --bench '^((?!BenchGlobal).)*$' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also explicitly disallow running BenchGlobal benchmark because even with all tests skipped, just having the BenchGlobal.track_all function locally run takes ~1 min of time, even though it's just giving nan for all results. I tried locally various ways of avoiding this, but it must be something in the asv mechanics that makes it take so long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Experiencing the same problem with the new QuadraticAssignment -- it takes 30 seconds just to set up the tests even if none are run. So I'll explicitly skip these, too.
|
CIs fixed, all green (sorry they weren't before) |
|
Rebased to get things green. It showed that #12775 two months ago added some very slow benchmarks. I made a comment in the code that it should use It would be nice to merge this sooner rather than later so that these problems are exposed in PRs directly, though. |
rgommers
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and all green, let's give it a go! Thanks @larsoner!
As mentioned in #8769, tries adding
asvto the CircleCI buildon:1. All commits tomaster2. PRs that touchbenchmark/files3. PR commits that contain[circle benchmark]Also fixes a broken URL.Eventually we probably want to do artifact deployment for
masterbuilds. But hopefully someone who knows more aboutasvcould do that part.First let's see if it actually works in a reasonable amount of time (e.g., under 2 hours).