File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -315,9 +315,16 @@ def run_serial():
315315
316316 # Concurrent execution
317317 with concurrent .futures .ThreadPoolExecutor (max_workers = num_tools ) as pool :
318- # Warm the pool before measuring; this test is about concurrent
319- # execution throughput, not OS thread startup jitter.
320- warmup = [pool .submit (lambda : None ) for _ in range (num_tools )]
318+ # A barrier forces every worker to exist before timing starts. Fast
319+ # no-op submissions can otherwise all run on one worker while the
320+ # executor is still creating the remaining threads.
321+ warmup_barrier = threading .Barrier (num_tools + 1 )
322+
323+ def warm_worker () -> None :
324+ warmup_barrier .wait ()
325+
326+ warmup = [pool .submit (warm_worker ) for _ in range (num_tools )]
327+ warmup_barrier .wait ()
321328 for f in warmup :
322329 f .result ()
323330
You can’t perform that action at this time.
0 commit comments