fix(process-pool): bound shutdown latency#469
Open
dexhunter wants to merge 1 commit into
Open
Conversation
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #297.
Summary
Why
ProcessPoolExecutor future.cancel() cannot cancel a task that is already running. The existing shutdown(wait=True) therefore waits for that task to finish, which matches the 27+ second and multi-hour shutdown hangs reported in #297.
The new path captures only this executor's workers, requests immediate shutdown, waits for those processes to exit, and escalates only workers that survive termination. Unrelated processes are not touched.
Performance
A strict scaled reproduction measures process_pool_shutdown_ms across multiple task durations with correctness gates for completed results, queued/running futures, worker cleanup, repeated stop(), post-return side effects, and unrelated processes.
That is about a 99.76% reduction (about 414x) on the minimum supported Python version. A separate 30-second worker stopped in 3.48 ms with no live worker left behind. Idle-pool shutdown remained effectively unchanged (3.40 ms before, 3.58 ms after).
Supplementary autoresearch: 20-step public dashboard.
Validation