Skip to content

Fix process-pool readiness under uneven worker startup - #982

Draft
bradhilton wants to merge 3 commits into
mainfrom
hayek/process-pool-readiness-20260926
Draft

bradhilton wants to merge 3 commits into
mainfrom
hayek/process-pool-readiness-20260926

Conversation

@bradhilton

@bradhilton bradhilton commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

Process-pool startup used N short identity tasks as a census of N workers. With uneven imports, one early worker can finish several tasks before another is ready, causing the dispatcher to disable a healthy process backend. A public four-worker run returned only two distinct warmup PIDs despite startup evidence from all four children; a deterministic two-worker regression reproduces that race.

Pass a spawn-context barrier through each worker initializer so every readiness task occupies a distinct worker until all workers arrive. Keep the distinct-PID check, a shared 60-second parent wait deadline and bounded child barrier, and cleanup of the exact failed executor on startup/submission failure. Healthy waiter cancellation leaves the shared pool usable. Adaptive routing, worker limits, fallback policy, tokenization and result ordering remain unchanged. The timeout bounds readiness waits, not synchronous process creation.

Cleanup also coordinates with the executor manager: that thread can reap a child before publishing its exit status, while concurrent joins transiently report the child alive. Capture the manager before shutdown and give it the remaining final reap window, outside its shutdown lock and without self-joining. Killing workers and waiting for their manager share that final one-second window; a blocked manager cannot extend it. This does not add a guarantee of shutting down arbitrarily blocked user callback threads.

Validation: 14 focused controls pass, including delayed initialization, cancelled waiter/reuse, initializer failure, duplicate PID refusal, shared timeout, public fallback, spawned-family cleanup, original exception identity, a deterministic real-worker concurrent-reap regression, and the shared cleanup deadline/self-join boundaries. Eight inherited ordering/grouping/nonmutation/rebinding/error controls are retained. Ruff and focused type checks pass. The failed CI cleanup case and its causal reproduction remain retained; its assertion was preserved.

A separate finite public CPU run exercised the prior readiness implementation at naturally selected process widths 4, 8 and 16, with all 30 calls preserving complete results, source ownership and all masks. That run predates this final cleanup-only correction and does not prove production throughput or authorize a worker-limit change.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant