Skip to content

Commit e650e91

Browse files
committed
test: stabilize concurrent speedup warmup
1 parent 3698aa1 commit e650e91

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

tests/test_cluster_stress.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)