Skip to content

fix: reset select() polling backoff after real I/O activity - #292

Draft
toddr-bot wants to merge 1 commit into
cpan-authors:mainfrom
toddr-bot:koan.toddr.bot/fix-select-backoff-reset
Draft

fix: reset select() polling backoff after real I/O activity#292
toddr-bot wants to merge 1 commit into
cpan-authors:mainfrom
toddr-bot:koan.toddr.bot/fix-select-backoff-reset

Conversation

@toddr-bot

Copy link
Copy Markdown
Contributor

What

Reset the $not_forever polling backoff in _select_loop after select() 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 the select() 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

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>
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