Skip to content

perf(http1): reuse the header read timer across requests - #4288

Open
yussypu wants to merge 1 commit into
hyperium:masterfrom
yussypu:perf-h1-reuse-header-read-timer
Open

yussypu wants to merge 1 commit into
hyperium:masterfrom
yussypu:perf-h1-reuse-header-read-timer

Conversation

@yussypu

@yussypu yussypu commented Nov 27, 2026 •

Copy link
Copy Markdown

Closes #4280

poll_read_head cleared h1_header_read_timeout_fut after every parsed head, aka the reset branch never ran on keep alive connections, and every request allocated a fresh sleep and registered it with the timer driver. This keeps the sleep and only clears the running flag, next head resets the existing timer.

Old sleep stays registered until the next head resets it. If a request takes longer than the timeout to handle, that can cause one spurious wakeup of the connection task, which does nothing because the timer isn't polled while it's not running.

Added header_read_timeout_reuses_timer_across_requests, which counts sleep_until calls over three keep alive requests. On master it counts 4 timers for one connection; with this change it counts 1. The existing header read timeout tests still pass, including the slow writes multiple requests case, which exercises the reset path.

  • The description, docs, and comments (words meant for humans) are written by a human, not by an LLM.

P.S. didnt see #4285 before submitting, if that works, just lmk and Ill delete this

The header read sleep was dropped after every parsed request head, so
the reset path never ran on keep alive connections and each request
allocated and registered a new timer. Keep the sleep and reset it for
the next head instead.

Closes hyperium#4280

This branch has not been deployed

No deployments
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.

HTTP/1 server: the header read timer is re-created for every request

1 participant