Skip to content

perf(base): retire completed IO.within deadlines - #2206

Open
toprameen wants to merge 2 commits into
bendlang:mainfrom
toprameen:retire-completed-within-deadlines
Open

toprameen wants to merge 2 commits into
bendlang:mainfrom
toprameen:retire-completed-within-deadlines

Conversation

@toprameen

Copy link
Copy Markdown
Contributor

A successful IO.within call can leave its deadline sleep running after the program has finished its work. Positive deadlines now use Chan.try_recv on the action’s result channel, so receiving the result retires the pending timer. A timed-out action still runs to completion, and a zero deadline keeps the existing race.

Positive deadlines now start when the caller begins waiting. If the event loop resumes after the deadline, the timeout can win before the action’s queued continuation sends its result.

On macOS arm64 with Apple Clang 21, the native tests/io/within.bend fixture with an eight-second deadline took 8.05 s on upstream and 0.17 s with the patch. These are single end-to-end runs for each build, including process startup. Both produced identical output.

The extended fixture checks an early result, a zero-deadline winner, and completion of a timed-out action. Under the five-second test alarm, upstream times out and the patch passes on macOS and Linux arm64. The local repository gate passes 56/56, and the fixture passes --verdict.

@toprameen
toprameen marked this pull request as ready for review November 18, 2026 19:34
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