Parallel tests don't finish when the average worker is done. The last worker sets the wait. A test run can have eight green jobs and still keep you…
Parallel tests don't finish when the average worker is done. The last worker sets the wait. A test run can have eight green jobs and still keep you waiting on the ninth. When I worked on test sharding in Automated Security Helper, I wanted to know how much of that wait came from the tests themselves and how much came from the way we divided them. The two problems need different fixes.
The old assignment gave each test module a stable home by hashing its name. That made it easy to reproduce a split and to absorb new modules. But it did not know what a module cost to run. Equal numbers of files looked fair on paper. They could put two slow modules in one worker and a handful of quick ones in another. Equal files are not equal work. I drew the workers as lanes and the tests as blocks.
If two long blocks land on the same lane, the empty space in the other lanes does not help. They cannot go back in time and pick up the work. If the test job is a gate, its finish time depends on the heaviest lane, not the mean. That changed the question I asked of the planner. It didn't need to predict the next run down to the second.
It had to make a better decision about where the expensive work went with the information we already had. Measure the wait reviewers actually see. Look at the last worker to finish Separate test execution from setup Ask which work could have gone elsewhere A test plan can balance recorded execution time without accounting for runner startup, contention, or variance. Give the heavy work a place first. In the change I submitted, recorded durations drive a longest-first plan.
Start with the largest job, put it on the least loaded lane, and repeat. Smaller pieces can fill the gaps that are left. There was also a case where the module itself was too big to balance as one unit. Splitting that module helped in a way that shuffling it around never could. On historical Python 3.12 Windows integration results, the heaviest lane in the replay went from 4,708 to 1,695 test-seconds. An even share of the recorded work would have been about 1,659.
This is a source-linked briefing. Read the original report from Dev Community .