]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding...
authorJoshua Herman <zitterbewegung@gmail.com>
Sun, 30 Apr 2023 01:26:24 +0000 (20:26 -0500)
committerGitHub <noreply@github.com>
Sun, 30 Apr 2023 01:26:24 +0000 (18:26 -0700)
commit9e011e7c77dad7d0bbb944c44891531606caeb21
tree799270174ddd0c5ab93a149212a0dbd6aedeb292
parent00e2c5960ea785e4659187335c29ab19df9298a4
gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)

This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.

After porting we can see the direct impact on a multicore system.

Without this change:
  Running make test is 5 min 26 seconds
With this change:
  Running make test takes 3 min 39 seconds

That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.

The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.

Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.

---------

Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
Lib/test/libregrtest/runtest.py