comparison src/event/quic/ngx_event_quic_ack.c @ 9138:a90f79792b5d

QUIC: optimized ACK delay. 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.
author Roman Arutyunyan <arut@nginx.com>
date Thu, 27 Jul 2023 16:37:17 +0400
parents a32905d6fc10
children 5d1e7c74aadf
comparison
equal deleted inserted replaced
9137:0ba26c99b3a1 9138:a90f79792b5d
1169 if (ctx->level == ssl_encryption_application) { 1169 if (ctx->level == ssl_encryption_application) {
1170 1170
1171 delay = ngx_current_msec - ctx->ack_delay_start; 1171 delay = ngx_current_msec - ctx->ack_delay_start;
1172 qc = ngx_quic_get_connection(c); 1172 qc = ngx_quic_get_connection(c);
1173 1173
1174 if (ctx->send_ack < NGX_QUIC_MAX_ACK_GAP 1174 if (ngx_queue_empty(&ctx->frames)
1175 && ctx->send_ack < NGX_QUIC_MAX_ACK_GAP
1175 && delay < qc->tp.max_ack_delay) 1176 && delay < qc->tp.max_ack_delay)
1176 { 1177 {
1177 if (!qc->push.timer_set && !qc->closing) { 1178 if (!qc->push.timer_set && !qc->closing) {
1178 ngx_add_timer(&qc->push, 1179 ngx_add_timer(&qc->push,
1179 qc->tp.max_ack_delay - delay); 1180 qc->tp.max_ack_delay - delay);