bneradt opened a new issue, #14020:
URL: https://github.com/apache/trafficserver/issues/14020
With `quic_stream|http3` debug enabled, an HTTP/3 connection that has an
open request stream but nothing to send logs a `VC_EVENT_WRITE_READY` on that
stream roughly every 2.5 ms for as long as it stays open. Nothing is written
and HttpSM is not signaled, so the events do no useful work. They are the
visible part of a 2 ms polling loop that every QUIC connection runs for its
whole lifetime, idle or not.
## Where the loop comes from
`QUICNetVConnection` (quiche) drives sending from a timer instead of from
data becoming available:
- `state_handshake()` and `state_established()` handle
`QUIC_EVENT_PACKET_WRITE_READY` by calling `_handle_write_ready()` and then
always calling `_schedule_packet_write_ready(true)`, which re-arms the event
`WRITE_READY_INTERVAL` (2 ms) later. The only thing that stops it is EOS, an
error, or a timeout.
- Each `_handle_write_ready()` walks `quiche_conn_writable()` twice (once to
count streams for the fair-send budget, once to send) and calls
`quiche_conn_send()`, even when nothing is queued.
- quiche reports a stream as writable whenever it has flow-control credit,
not when ATS has data for it. For each such stream, `QUICStream::send_data()`
finds the adapter's buffer empty and calls
`QUICStreamVCAdapter::encourge_write()`. That schedules `VC_EVENT_WRITE_READY`
to `Http3App`, which passes it on to the `Http3Transaction`.
- `HQTransaction::state_stream_open()` makes no progress, so it does not
signal HttpSM. It still calls `write_vio->reenable()`, though.
`QUICStreamVCAdapter::reenable()` then calls `QUICStream::on_write()` and
`on_stream_updated()`. That would schedule an immediate packet write, except
the 2 ms one is already pending, so the cycle repeats on the timer.
The polling interval dates back to the original QUIC implementation (2019).
It survived the move to quiche.
## Why it matters
- **Idle cost:** every open QUIC connection costs about 500 event-thread
wakeups per second, plus the per-stream event fan-out above. This happens with
no traffic, so CPU use grows with the number of open connections, not with
load. Clients that keep connections alive (for example with PINGs inside the
idle timeout) can keep that cost up indefinitely.
- **Latency:** data that isn't sent right away waits up to 2 ms for the next
tick, adding latency to the response.
## Possible direction
- Arm `QUIC_EVENT_PACKET_WRITE_READY` only when there is something to send:
- stream data was produced (`on_stream_updated()`, which already schedules
an immediate write)
- packets were received
- quiche's timeout fired
- a connection close was queued
- Stop re-arming after a `_handle_write_ready()` that wrote nothing and has
no stream data pending.
- Leave pacing to `quiche_conn_timeout_as_millis()` and the existing
`EVENT_INTERVAL`, plus the `send_info.at` hint already used for `SO_TXTIME`.
- Separately, `QUICStream::send_data()` should not call `encourge_write()`
when the stream's write VIO is already waiting on its producer. Then a
writable-but-empty stream does not bounce `WRITE_READY` through `Http3App` and
the transaction on each pass.
A urtest could count `WRITE_READY` debug lines on a connection held idle for
a second with an open request stream. Today it would see hundreds.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]