Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9e011e7

Browse files
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 secondsWith this change: Running make test takes 3 min 39 secondsThat'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]
1 parent00e2c59 commit9e011e7

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

‎Lib/test/libregrtest/runtest.py‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,14 @@ def __str__(self) -> str:
143143
# set of tests that we don't want to be executed when using regrtest
144144
NOTTESTS=set()
145145

146+
#If these test directories are encountered recurse into them and treat each
147+
# test_ .py or dir as a separate test module. This can increase parallelism.
148+
# Beware this can't generally be done for any directory with sub-tests as the
149+
# __init__.py may do things which alter what tests are to be run.
150+
151+
SPLITTESTDIRS= {
152+
"test_asyncio",
153+
}
146154

147155
# Storage of uncollectable objects
148156
FOUND_GARBAGE= []
@@ -158,16 +166,21 @@ def findtestdir(path=None):
158166
returnpathoros.path.dirname(os.path.dirname(__file__))oros.curdir
159167

160168

161-
deffindtests(testdir=None,stdtests=STDTESTS,nottests=NOTTESTS):
169+
deffindtests(testdir=None,stdtests=STDTESTS,nottests=NOTTESTS,*,split_test_dirs=SPLITTESTDIRS,base_mod=""):
162170
"""Return a list of all applicable test modules."""
163171
testdir=findtestdir(testdir)
164172
names=os.listdir(testdir)
165173
tests= []
166174
others=set(stdtests)|nottests
167175
fornameinnames:
168176
mod,ext=os.path.splitext(name)
169-
ifmod[:5]=="test_"andextin (".py","")andmodnotinothers:
170-
tests.append(mod)
177+
ifmod[:5]=="test_"andmodnotinothers:
178+
ifmodinsplit_test_dirs:
179+
subdir=os.path.join(testdir,mod)
180+
mod=f"{base_modor'test'}.{mod}"
181+
tests.extend(findtests(subdir, [],nottests,split_test_dirs=split_test_dirs,base_mod=mod))
182+
elifextin (".py",""):
183+
tests.append(f"{base_mod}.{mod}"ifbase_modelsemod)
171184
returnstdtests+sorted(tests)
172185

173186

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp