Commit 2748b2d
committed
Demonstrate test.regrtest unittest sharding.
An incomplete implementation with details to be worked out, but it
works! It makes our long tail tests take significantly less time. At
least when run on their own.
Example: ~25 seconds wall time to run test_multiprocessing_spawn and
test_concurrent_futures on a 12 thread machine for example.
`python -m test -r -j 20 test_multiprocessing_spawn test_concurrent_futures`
Known Issues to work out: result reporting and libregrtest accounting.
You see any sharded test "complete" multiple times and your total tests
run count goes higher than the total number of tests. 😂
Real caveat: This exposes ordering and concurrency weaknesses in some
tests like test_asyncio that'll need fixing.
Which tests get sharded is explicitly opt-in. Currently not in a
maintainable spot. How best to maintain that needs to be worked out,
but I expect we only ever have 10-20 test modules that we declare as
worth sharding.
This implementation is inspired by and with the unittest TestLoader bits
derived directly from the Apache 2.0 licensed
https://github.com/abseil/abseil-py/blob/v1.3.0/absl/testing/absltest.py#L2359
```
:~/oss/cpython (performance/test-sharding)$ ../b/python -m test -r -j 20
test_multiprocessing_spawn test_concurrent_futures
Using random seed 8555091
0:00:00 load avg: 0.98 Run tests in parallel using 20 child processes
0:00:08 load avg: 1.30 [1/2] test_multiprocessing_spawn passed
0:00:10 load avg: 1.68 [2/2] test_concurrent_futures passed
0:00:11 load avg: 1.68 [3/2] test_multiprocessing_spawn passed
0:00:12 load avg: 1.68 [4/2] test_multiprocessing_spawn passed
0:00:12 load avg: 1.68 [5/2] test_multiprocessing_spawn passed
0:00:14 load avg: 1.87 [6/2] test_multiprocessing_spawn passed
0:00:15 load avg: 1.87 [7/2] test_multiprocessing_spawn passed
0:00:16 load avg: 1.87 [8/2] test_concurrent_futures passed
0:00:16 load avg: 1.87 [9/2] test_multiprocessing_spawn passed
0:00:18 load avg: 1.87 [10/2] test_concurrent_futures passed
0:00:20 load avg: 1.72 [11/2] test_concurrent_futures passed
0:00:20 load avg: 1.72 [12/2] test_concurrent_futures passed
0:00:21 load avg: 1.72 [13/2] test_multiprocessing_spawn passed
0:00:21 load avg: 1.72 [14/2] test_concurrent_futures passed
0:00:22 load avg: 1.72 [15/2] test_concurrent_futures passed
0:00:25 load avg: 1.58 [16/2] test_concurrent_futures passed
== Tests result: SUCCESS ==
All 16 tests OK.
Total duration: 25.6 sec
Tests result: SUCCESS
```1 parent e13d1d9 commit 2748b2d
File tree
3 files changed
+132
-15
lines changed- Lib
- test/libregrtest
- unittest
3 files changed
+132
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
67 | 84 | | |
68 | 85 | | |
69 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | | - | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
45 | 53 | | |
46 | 54 | | |
47 | 55 | | |
| |||
56 | 64 | | |
57 | 65 | | |
58 | 66 | | |
59 | | - | |
| 67 | + | |
60 | 68 | | |
61 | 69 | | |
62 | 70 | | |
| |||
75 | 83 | | |
76 | 84 | | |
77 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
78 | 93 | | |
79 | 94 | | |
80 | 95 | | |
| |||
109 | 124 | | |
110 | 125 | | |
111 | 126 | | |
112 | | - | |
| 127 | + | |
113 | 128 | | |
114 | 129 | | |
115 | 130 | | |
| |||
215 | 230 | | |
216 | 231 | | |
217 | 232 | | |
218 | | - | |
| 233 | + | |
| 234 | + | |
219 | 235 | | |
220 | 236 | | |
221 | | - | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
222 | 241 | | |
223 | | - | |
| 242 | + | |
| 243 | + | |
224 | 244 | | |
225 | 245 | | |
226 | 246 | | |
| |||
240 | 260 | | |
241 | 261 | | |
242 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
243 | 274 | | |
244 | 275 | | |
245 | 276 | | |
| |||
269 | 300 | | |
270 | 301 | | |
271 | 302 | | |
272 | | - | |
| 303 | + | |
273 | 304 | | |
274 | 305 | | |
275 | 306 | | |
| |||
290 | 321 | | |
291 | 322 | | |
292 | 323 | | |
293 | | - | |
| 324 | + | |
294 | 325 | | |
295 | 326 | | |
296 | 327 | | |
| |||
335 | 366 | | |
336 | 367 | | |
337 | 368 | | |
338 | | - | |
| 369 | + | |
339 | 370 | | |
340 | 371 | | |
341 | 372 | | |
342 | | - | |
| 373 | + | |
343 | 374 | | |
344 | 375 | | |
345 | 376 | | |
| |||
402 | 433 | | |
403 | 434 | | |
404 | 435 | | |
| 436 | + | |
405 | 437 | | |
406 | | - | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
407 | 449 | | |
408 | 450 | | |
409 | 451 | | |
| |||
416 | 458 | | |
417 | 459 | | |
418 | 460 | | |
419 | | - | |
| 461 | + | |
420 | 462 | | |
421 | 463 | | |
422 | 464 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
8 | | - | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
66 | | - | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| |||
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
76 | 114 | | |
77 | 115 | | |
78 | 116 | | |
| |||
198 | 236 | | |
199 | 237 | | |
200 | 238 | | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
201 | 251 | | |
202 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
203 | 261 | | |
204 | 262 | | |
205 | 263 | | |
| |||
0 commit comments