Commit e4c8b2a
committed
Replace per-gen EMA adaptive controller with biased constrained random walk
Remove per-generation EMA hill-climbing (8 parameters, ~90 lines) and
replace with a simpler biased constrained random walk (~25 lines):
- Start at min(4, num_workers) workers
- Each collection: with 20% probability, step ±1 (60% bias toward increase)
- Clamp to [2, num_workers]
- No per-gen state, no EMA, no epsilon, no warmup, no dead zone
The proactive walk continuously explores nearby worker counts even when
performance is stable, preventing the controller from getting trapped at
suboptimal configurations after load spikes.
API changes:
- get_parallel_config: adaptive_workers (single int) replaces per-gen arrays
- get_parallel_stats: prev_cost_per_obj_ns replaces per-gen EMAs
Forward-ported from commit 5114778 on parallel_gc_backport (3.12).
3.15 routing: controller body moved from Modules/gcmodule.c to Python/gc.c.
The flaky test_gen2_allows_more_workers from Phase 5.4 is no longer
applicable — without per-gen state there is nothing for gen2 to converge
to differently from gen0. The test still exists in the file but its
class-level skip (_has_adaptive_controller checks per-gen API presence)
now skips the whole TestAdaptiveControllerConvergence class on builds
where that API is absent (i.e. this build). The test runs cleanly:
SUCCESS, 31 tests run, 9 skipped (the now-inapplicable convergence
class), 0 failures.
Part of Phase 5 of the 3.15 consolidation.1 parent 03a9c51 commit e4c8b2a
3 files changed
Lines changed: 47 additions & 129 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
368 | 368 | | |
369 | 369 | | |
370 | 370 | | |
371 | | - | |
372 | | - | |
| 371 | + | |
| 372 | + | |
373 | 373 | | |
374 | 374 | | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
387 | 380 | | |
388 | | - | |
389 | | - | |
390 | 381 | | |
391 | 382 | | |
392 | 383 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2178 | 2178 | | |
2179 | 2179 | | |
2180 | 2180 | | |
2181 | | - | |
2182 | | - | |
| 2181 | + | |
| 2182 | + | |
2183 | 2183 | | |
2184 | 2184 | | |
2185 | 2185 | | |
2186 | 2186 | | |
2187 | 2187 | | |
2188 | 2188 | | |
2189 | | - | |
2190 | 2189 | | |
2191 | 2190 | | |
2192 | 2191 | | |
| |||
2280 | 2279 | | |
2281 | 2280 | | |
2282 | 2281 | | |
2283 | | - | |
2284 | | - | |
2285 | | - | |
2286 | | - | |
2287 | | - | |
2288 | | - | |
2289 | | - | |
2290 | | - | |
| 2282 | + | |
| 2283 | + | |
| 2284 | + | |
2291 | 2285 | | |
2292 | 2286 | | |
2293 | 2287 | | |
2294 | | - | |
2295 | | - | |
2296 | | - | |
2297 | | - | |
2298 | | - | |
2299 | | - | |
2300 | | - | |
2301 | | - | |
2302 | | - | |
2303 | | - | |
2304 | | - | |
2305 | | - | |
2306 | | - | |
2307 | | - | |
2308 | | - | |
2309 | | - | |
2310 | | - | |
2311 | | - | |
2312 | | - | |
2313 | | - | |
2314 | | - | |
| 2288 | + | |
| 2289 | + | |
| 2290 | + | |
2315 | 2291 | | |
2316 | | - | |
2317 | | - | |
2318 | | - | |
2319 | | - | |
2320 | | - | |
2321 | | - | |
2322 | | - | |
2323 | | - | |
2324 | | - | |
2325 | | - | |
| 2292 | + | |
| 2293 | + | |
2326 | 2294 | | |
2327 | 2295 | | |
2328 | 2296 | | |
2329 | | - | |
2330 | | - | |
| 2297 | + | |
2331 | 2298 | | |
2332 | 2299 | | |
2333 | 2300 | | |
2334 | 2301 | | |
2335 | 2302 | | |
2336 | 2303 | | |
2337 | 2304 | | |
2338 | | - | |
2339 | | - | |
2340 | | - | |
2341 | | - | |
2342 | | - | |
2343 | | - | |
2344 | | - | |
2345 | | - | |
2346 | | - | |
2347 | | - | |
2348 | | - | |
2349 | | - | |
2350 | | - | |
2351 | | - | |
2352 | | - | |
2353 | | - | |
2354 | | - | |
2355 | | - | |
2356 | | - | |
2357 | | - | |
2358 | | - | |
2359 | | - | |
2360 | | - | |
2361 | | - | |
2362 | | - | |
| 2305 | + | |
| 2306 | + | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
2363 | 2318 | | |
| 2319 | + | |
2364 | 2320 | | |
2365 | 2321 | | |
2366 | 2322 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
501 | 501 | | |
502 | 502 | | |
503 | 503 | | |
504 | | - | |
| 504 | + | |
505 | 505 | | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | 506 | | |
| 507 | + | |
511 | 508 | | |
512 | | - | |
513 | | - | |
| 509 | + | |
514 | 510 | | |
515 | 511 | | |
516 | 512 | | |
| |||
522 | 518 | | |
523 | 519 | | |
524 | 520 | | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | 521 | | |
530 | 522 | | |
531 | 523 | | |
| |||
853 | 845 | | |
854 | 846 | | |
855 | 847 | | |
856 | | - | |
| 848 | + | |
857 | 849 | | |
858 | | - | |
859 | | - | |
860 | | - | |
861 | | - | |
862 | | - | |
863 | | - | |
864 | | - | |
865 | | - | |
866 | | - | |
867 | | - | |
868 | | - | |
869 | | - | |
870 | | - | |
871 | | - | |
872 | | - | |
873 | | - | |
874 | | - | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
875 | 853 | | |
876 | 854 | | |
877 | 855 | | |
878 | | - | |
| 856 | + | |
879 | 857 | | |
880 | 858 | | |
881 | 859 | | |
| |||
1239 | 1217 | | |
1240 | 1218 | | |
1241 | 1219 | | |
1242 | | - | |
| 1220 | + | |
1243 | 1221 | | |
1244 | | - | |
1245 | | - | |
1246 | | - | |
1247 | | - | |
1248 | | - | |
1249 | | - | |
1250 | | - | |
1251 | | - | |
1252 | | - | |
1253 | | - | |
1254 | | - | |
1255 | | - | |
1256 | | - | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
1257 | 1227 | | |
| 1228 | + | |
1258 | 1229 | | |
1259 | 1230 | | |
1260 | 1231 | | |
| |||
0 commit comments