perf: Improve Runner tick signaling on macrotask-only wait#2999
Merged
Conversation
karlseguin
force-pushed
the
runner-tick-signal
branch
from
July 22, 2026 09:11
a7f87e8 to
21e6851
Compare
Currently, Runner assumes that HttpClient.tick did something. But it's possible
that HttpClient had nothing to do, and thus didn't poll. In that case, Runner
would return .{.ok = 0} and Runner's caller would also certainly call
Runner.tick again, resulting in a spin-loop.
The reason Runner allows this to happen is because it can still have macrotasks
to run. So now, when HttpClient.tick has done nothing, Runner will return its
ms_to_next_task, rather than 0.
On sites where all i/o is completed, and only macrotasks are waiting, this
significantly reduces CPU usage.
karlseguin
force-pushed
the
runner-tick-signal
branch
from
July 22, 2026 23:29
21e6851 to
8f56233
Compare
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Currently, Runner assumes that HttpClient.tick did something. But it's possible that HttpClient had nothing to do, and thus didn't poll. In that case, Runner would return .{.ok = 0} and Runner's caller would also certainly call Runner.tick again, resulting in a spin-loop.
The reason Runner allows this to happen is because it can still have macrotasks to run. So now, when HttpClient.tick has done nothing, Runner will return its ms_to_next_task, rather than 0.
On sites where all i/o is completed, and only macrotasks are waiting, this significantly reduces CPU usage.
(This is part of ongoing work for #1507)