Skip to content

Commit caa7cae

Browse files
committed
Remove uphill bias from random walk controller (50/50)
Change directional bias from 60/40 (favoring increase) to 50/50 (no directional bias). The A/B comparison showed 8 workers was 5.2% slower than 4 on 200K heaps, and the uphill bias was actively guiding the walker toward a worse operating point. Per Alex's direction: "no bias." Forward-ported from commit 95d98be on parallel_gc_backport (3.12). 3.15 routing: controller body is in Python/gc.c rather than Modules/gcmodule.c.
1 parent 61d4ab5 commit caa7cae

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Python/gc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2304,9 +2304,9 @@ gc_collect_region(PyThreadState *tstate,
23042304

23052305
// 20% chance to step ±1 (proactive exploration)
23062306
if (rand_val < 0.2) {
2307-
// Bias uphill: 60% chance to increase, 40% to decrease
2307+
// No directional bias: 50/50 chance to increase or decrease
23082308
double dir_val = (double)((rng >> 16) & 0xFFFF) / 65535.0;
2309-
int delta = (dir_val < 0.6) ? 1 : -1;
2309+
int delta = (dir_val < 0.5) ? 1 : -1;
23102310

23112311
// Always step when the dice fires. Good values stick
23122312
// because they don't trigger further corrective steps.

0 commit comments

Comments
 (0)