]> git.kaiwu.me - nginx.git/commitdiff
QUIC: optimized ACK delay.
authorRoman Arutyunyan <arut@nginx.com>
Thu, 27 Jul 2023 12:37:17 +0000 (16:37 +0400)
committerRoman Arutyunyan <arut@nginx.com>
Thu, 27 Jul 2023 12:37:17 +0000 (16:37 +0400)
Previously ACK was not generated if max_ack_delay was not yet expired and the
number of unacknowledged ack-eliciting packets was less than two, as allowed by
RFC 9000 13.2.1-13.2.2.  However this only makes sense to avoid sending ACK-only
packets, as explained by the RFC:

  On the other hand, reducing the frequency of packets that carry only
  acknowledgments reduces packet transmission and processing cost at both
  endpoints.

Now ACK is delayed only if output frame queue is empty.  Otherwise ACK is sent
immediately, which significantly improves QUIC performance with certain tests.

src/event/quic/ngx_event_quic_ack.c

index f194abfffdbcda7d4ce2104822c6282337364bb3..865be2e6afe8f66aad8990f23a5ed0ced63c62e7 100644 (file)
@@ -1171,7 +1171,8 @@ ngx_quic_generate_ack(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx)
         delay = ngx_current_msec - ctx->ack_delay_start;
         qc = ngx_quic_get_connection(c);
 
-        if (ctx->send_ack < NGX_QUIC_MAX_ACK_GAP
+        if (ngx_queue_empty(&ctx->frames)
+            && ctx->send_ack < NGX_QUIC_MAX_ACK_GAP
             && delay < qc->tp.max_ack_delay)
         {
             if (!qc->push.timer_set && !qc->closing) {