Skip to content

perf: Improve Runner tick signaling on macrotask-only wait#2999

Merged
karlseguin merged 1 commit into
mainfrom
runner-tick-signal
Jul 22, 2026
Merged

perf: Improve Runner tick signaling on macrotask-only wait#2999
karlseguin merged 1 commit into
mainfrom
runner-tick-signal

Conversation

@karlseguin

Copy link
Copy Markdown
Collaborator

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)

@karlseguin
karlseguin force-pushed the runner-tick-signal branch from a7f87e8 to 21e6851 Compare July 22, 2026 09:11
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
karlseguin force-pushed the runner-tick-signal branch from 21e6851 to 8f56233 Compare July 22, 2026 23:29
@karlseguin
karlseguin merged commit bd19246 into main Jul 22, 2026
26 checks passed
@karlseguin
karlseguin deleted the runner-tick-signal branch July 22, 2026 23:48
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant