-
Notifications
You must be signed in to change notification settings - Fork 36
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
Run tests in parallel with pytest-xdist. #705
Conversation
Codecov Report
@@ Coverage Diff @@
## master #705 +/- ##
=======================================
Coverage 78.54% 78.54%
=======================================
Files 65 65
Lines 7141 7141
Branches 1565 1565
=======================================
Hits 5609 5609
Misses 1228 1228
Partials 304 304 Continue to review full report at Codecov.
|
Maybe do |
Unfortunately the CI machine claims to have 36 cores but only schedules 2. Auto ends up oversubscribing really badly. |
Yikes! Okay that makes sense! |
As far as I know, this is specific to circleci. GitHub Actions and Azure pipelines use VMs that advertise the correct number of cores. |
I think we can probably run with this change for now and revisit if we ever switch to a different CI executor, then? |
Yes. I wasn't suggesting action - just providing information for context. |
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.
Nice speedup! Make the changelog entry more specific then this is good to go!
Co-authored-by: Corwin Kerr <[email protected]>
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.
Great! Thanks a lot.
Do you know what is going on with the failing py38 test? Looks like some multi-threaded tests are failing?
It looks like one of the errors is that this line in the test should be modified to catch a KeyError. The existing except clause isn't broad enough in detecting the ways in which multithreaded execution can fail when multithreading support is disabled. My best guess is that the other failure is due to #397, specifically the case that I decided was out of scope when closing that issue: process-parallelism safe buffering. I suspect that we only see failures on PyPy because it executes much faster than CPython. I observed the same type of issue many times when constructing this test, specifically because sequences of operations that could fail when multithreading support was disabled would succeed in PyPy because threads completed too quickly to be preempted and so data was never corrupted even without acquiring mutexes. Buffering safe for multiple processes is still out of scope (especially in conjunction with PyPy), so I don't think diagnosing the exact failure here is worth much further investigation. My recommendation is to check if we're using pytest-xdist (either using the |
The same failure of the multithreaded test with PyPy is showing up on #706. It's possible that tests are suddenly detecting a failure in the multithreading logic that they haven't for the past year, although I don't know why that would be. A possible culprit is #658, which bumped our testing environment for pypy from 3.7 to 3.8. Perhaps something is different in PyPy 3.8 vs 3.7. Now that we've seen this failure on two PRs, my recommendation would be to merge this PR as is and to investigate further in a separate PR. The easiest solution would just be to disable threading support on PyPy if we can't find an underlying cause. I invested a lot of time trying to get to the bottom of this issue in the past and I am unlikely to do so again in the near future. |
Description
This PR adds the plugin pytest-xdist to run tests in parallel. Each CircleCI machine has two cores. This cuts off around 45 seconds from each CI job, which adds up to a decent amount of time across all jobs. The output is a little more verbose.
Before:
![image](https://user-images.githubusercontent.com/3943761/156471389-6a78b5be-60be-42b2-9a78-fbde19da4ea3.png)
After (ignore pypy, I pushed another commit before it finished):
![image](https://user-images.githubusercontent.com/3943761/156471472-93937a96-fe95-44a1-9b85-db80de1297f5.png)
Motivation and Context
Might as well use all of the CI resources we are given. Saves a bit of time and probably reduces the energy needed by the server since it can sleep sooner.
Types of Changes
1The change breaks (or has the potential to break) existing functionality.
Checklist:
If necessary: