Skip to content

Commit 157164f

Browse files
committed
Increase W1!=W2 adaptation test to 50 collections per phase
With 50/50 unbiased walk, 30 collections gave 80% pass rate (4/5). Increasing to 50 collections gives 100% pass rate (5/5) by allowing the walker more exploration steps to differentiate workloads.
1 parent 35ae253 commit 157164f

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

Lib/test/test_gc_parallel_mark_alive.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -922,14 +922,14 @@ def run_cyclic(rng, collections_per_phase=5, cycles=2):
922922
def test_walker_settles_differently_per_workload(self):
923923
"""Different workloads must produce different final worker counts.
924924
925-
Run 30 dense collections (200K objects) → record W1.
926-
Run 30 simple collections (5K objects) → record W2.
925+
Run 50 dense collections (200K objects) → record W1.
926+
Run 50 simple collections (5K objects) → record W2.
927927
Assert W1 != W2.
928928
929929
This proves the walker ADAPTS to workload, not just explores
930930
randomly. A fixed controller or cost-blind PRNG cannot reliably
931-
pass this — the worker count after 30 dense collections should
932-
be different from after 30 simple collections because the
931+
pass this — the worker count after 50 dense collections should
932+
be different from after 50 simple collections because the
933933
performance landscape is different.
934934
"""
935935
import random
@@ -938,7 +938,9 @@ def test_walker_settles_differently_per_workload(self):
938938
gc.enable_parallel(8)
939939

940940
# Phase 1: dense collections (200K objects, graph traversal)
941-
for _ in range(30):
941+
# 50 collections gives the unbiased (50/50) walker enough steps
942+
# to differentiate between workloads reliably.
943+
for _ in range(50):
942944
nodes = [{'id': i, 'refs': []} for i in range(200_000)]
943945
for i in range(0, len(nodes), 50):
944946
targets = rng.sample(range(len(nodes)), min(3, len(nodes)))
@@ -949,7 +951,7 @@ def test_walker_settles_differently_per_workload(self):
949951
W1 = gc.get_parallel_config()['adaptive_workers']
950952

951953
# Phase 2: simple collections (5K objects, chains)
952-
for _ in range(30):
954+
for _ in range(50):
953955
objs = [{'ref': None} for _ in range(5_000)]
954956
for i in range(len(objs) - 1):
955957
objs[i]['ref'] = objs[i + 1]

0 commit comments

Comments
 (0)