Skip to content

Commit 3c6be01

Browse files
jbower-fbfacebook-github-bot
authored andcommitted
Run test_asyncio and test_compiler sub-tests in parallel
Summary: These two tests are typically the long-poles in runs because they are modules with a lot of further sub-tests run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel. The real win comes in the next diff but with this change alone on my devserver: * With a debug build: * `time make testcinder` goes from ~25m -> ~19m. * `time make testcinder_jit` goes from ~26m -> ~18m. * With a release build: * `time make testcinder` goes from ~6m15s -> ~4m45s. * `time make testcinder_jit` goes from ~6m -> ~5m30s. While this is a bit hacky and annoyingly involves changing CPython test infra, I think the maintenance overhead is worth it. It's not a complicated change and I think the win in productivity with the diff above is significant. Reviewed By: sinancepel Differential Revision: D35383641 fbshipit-source-id: eaacb81
1 parent 09becce commit 3c6be01

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

Lib/test/libregrtest/runtest.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@
6161
# set of tests that we don't want to be executed when using regrtest
6262
NOTTESTS = set()
6363

64+
# If these test directories are encountered recurse into them and treat each
65+
# test_ .py or dir as a separate test module. This can increase parallelism.
66+
# Beware this can't generally be done for any directory with sub-tests as the
67+
# __init__.py may do things which alter what tests are to be run.
68+
SPLITTESTDIRS = {
69+
"test_asyncio",
70+
"test_compiler",
71+
}
6472

6573
# used by --findleaks, store for gc.garbage
6674
FOUND_GARBAGE = []
@@ -87,16 +95,30 @@ def findtestdir(path=None):
8795
return path or os.path.dirname(os.path.dirname(__file__)) or os.curdir
8896

8997

90-
def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):
98+
def findtests(
99+
testdir=None,
100+
stdtests=STDTESTS,
101+
nottests=NOTTESTS,
102+
splittestdirs=SPLITTESTDIRS,
103+
base_mod="",
104+
):
91105
"""Return a list of all applicable test modules."""
92106
testdir = findtestdir(testdir)
93107
names = os.listdir(testdir)
94108
tests = []
95109
others = set(stdtests) | nottests
96110
for name in names:
97111
mod, ext = os.path.splitext(name)
98-
if mod[:5] == "test_" and ext in (".py", "") and mod not in others:
99-
tests.append(mod)
112+
if mod[:5] == "test_" and mod not in others:
113+
if mod in splittestdirs:
114+
subdir = os.path.join(testdir, mod)
115+
if len(base_mod):
116+
mod = f"{base_mod}.{mod}"
117+
else:
118+
mod = f"test.{mod}"
119+
tests.extend(findtests(subdir, [], nottests, splittestdirs, mod))
120+
elif ext in (".py", ""):
121+
tests.append(f"{base_mod}.{mod}" if len(base_mod) else mod)
100122
return stdtests + sorted(tests)
101123

102124

Lib/test/test_asyncio/test_sock_lowlevel.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
from test import support
88

99

10+
def tearDownModule():
11+
asyncio.set_event_loop_policy(None)
12+
13+
1014
class MyProto(asyncio.Protocol):
1115
connected = None
1216
done = None

0 commit comments

Comments
 (0)