fix: reset select() polling backoff after real I/O activity - #292
Draft
toddr-bot wants to merge 1 commit into
Draft
fix: reset select() polling backoff after real I/O activity#292toddr-bot wants to merge 1 commit into
toddr-bot wants to merge 1 commit into
Conversation
The $not_forever backoff in _select_loop grows from 0.01s to 0.5s when polling for child exits, but it never resets when real I/O occurs. This means harnesses that alternate between active I/O and waiting for children inherit a stale 0.5s backoff, adding unnecessary latency to child reaping. Reset $not_forever to $min_select_timeout whenever select() reports ready file descriptors ($nfound > 0). This ensures each idle period starts with a responsive timeout. Addresses item 2 from GH#291. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
What
Reset the
$not_foreverpolling backoff in_select_loopafterselect()reports ready file descriptors.Why
The backoff grows from 0.01s to 0.5s when polling for child exits, but never resets when real I/O occurs (GH#291 item 2). In harnesses that alternate between active I/O and waiting-for-children phases, each idle period inherits the stale 0.5s cap from the previous one, adding unnecessary latency to child reaping.
How
Single line:
$not_forever = $min_select_timeout if $nfound > 0;— placed right after theselect()call, before EINTR handling. Only resets on positive$nfound(actual ready fds), not on errors or EINTR.Testing
Full test suite passes (863 tests). The backoff behavior is internal to the select loop and timing-sensitive, so no new timing-based test was added — the fix is structurally obvious and doesn't change observable API behavior, only responsiveness.
🤖 Generated with Claude Code