]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: mux-h2: send the preface along with the first request if needed
authorWilly Tarreau <w@1wt.eu>
Wed, 29 Oct 2025 16:38:07 +0000 (17:38 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 30 Oct 2025 17:16:54 +0000 (18:16 +0100)
commita1f26ca3078a51f289727d7ad1ffc23fe33f5b49
treec5ce6f1c3f07584c6de0c296631aa7a379194a01
parentd5aa3e19cc8722ff3f28d9a63ffe41366c3fec79
BUG/MINOR: mux-h2: send the preface along with the first request if needed

Tests involving 0-RTT and H2 on the backend show that 0-RTT is being
partially used but does not work. The analysis shows that only the
preface and settings are sent using early-data and the request is sent
separately. As explained in the previous patch, this is caused by the
fact that a wakeup of the iocb is needed just to send the preface, then
a new call to process_stream is needed to try sending again.

Here with this patch, we're making h2_snd_buf() able to send the preface
if it was not yet sent. Thanks to this, the preface, settings and first
request can now leave as a single TCP segment. In case of TLS with 0-RTT,
it now allows all the block to leave in early data.

Even in clear-text H2, we're now seeing a 15% lower context-switch count,
and the number of calls to process_stream() per connection dropped from 3
to 2. The connection rate increased by an extra 9.5%. Compared to without
the last 3 patches, this is a 22% reduction of context-switches, 33%
reduction of process_stream() calls, and 15.7% increase in connection
rate. And more importantly, 0-RTT now really works with H2 on the
backend, saving one full RTT on the first request.

This fix is only for a missed optimization and a non-functional 0-RTT
on the backend. It's worth backporting it, but it doesn't cause enough
harm to hurry a backport. Better wait for it to live a little bit in
3.3 (till at least a week or two after the final release) before
backporting it. It's not sure that it's worth going beyond 3.2 in any
case. It depends on the these two previous commits:

  MEDIUM: mux-h2: do not needlessly refrain from sending data early
  MINOR: mux-h2: extract the code to send preface+settings into its own function
src/mux_h2.c