Running tests in parallel is not any faster than without pytest-xdist anymore
See original GitHub issueI have no idea what is going on here, but no matter how I run the tests, I’m not getting them to run any faster in parallel. These commands all give me the same timings (about 21 sec):
python -c "import scipy; scipy.test()"
python -c "import scipy; scipy.test(parallel=4)"
pytest --pyargs scipy.linalg
pytest -n 4 --pyargs scipy.linalg
And the same if I try it on other submodules or on scipy as a whole. I even uninstalled pytest-xdist
to make sure - no difference whatsoever.
This used to work after gh-10172 two years ago. Does this still work for anyone else?
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Why does pytest-xdist make my tests run slower, not faster?
The big downside is that when I run with -n 4 , the test suite becomes slower than without the -n flag at...
Read more >Changelog — pytest documentation
#10060: When running with --pdb , TestCase.tearDown is no longer called for tests when the class has been skipped via unittest.skip or pytest.mark.skip...
Read more >test - Pants build
Given enough cores, Pants will be able to run all your tests at the same time. ... pytest-xdist already: Pants will run each...
Read more >pytest-cov - Read the Docs
Xdist support: you can use all of pytest-xdist's features and still get coverage. ... Do not report coverage if test run fails. Default:...
Read more >Load-balanced xdist - Ned Batchelder
I wrote a pytest plugin to evenly balance tests across xdist workers. ... runs slightly faster than before, but as is typical, not...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Okay you do have a good point with the influence of parallelism @tylerjereddy. The oversubscription issue matters more on a larger machine.
To verify that
OMP_NUM_THREADS
actually has an effect (also shows up intop
with the process using >100% CPU):Conclusions:
pytest-xdist
scalability is really bad, it doesn’t help beyond-n 4
and may even have a negative effect on machines with a lot of cores.I briefly played with
pytest-split
as well, and it looks much more capable of scaling linearly, because there’s no communication overhead -i f you do a 10-fold split, it just runs 10% of the tests (balanced so total time for each split is about equal) in a process and reports the 10 results separately. The price you pay is doing test collection separately in all 10 processes.Thanks Thomas!