]> git.kaiwu.me - nginx.git/commitdiff
QUIC: optimized ack range processing.
authorVladimir Homutov <vl@nginx.com>
Fri, 15 Oct 2021 09:26:42 +0000 (12:26 +0300)
committerVladimir Homutov <vl@nginx.com>
Fri, 15 Oct 2021 09:26:42 +0000 (12:26 +0300)
The sent queue is sorted by packet number.  It is possible to avoid
traversing full queue while handling ack ranges.  It makes sense to
start traversing from the queue head (i.e. check oldest packets first).

src/event/quic/ngx_event_quic_ack.c

index 3e4bb6d4fcca6f3d2bbb500fe5a9d7481dfe7ae0..22697ccb6c6d87e56e984f838dfe1929dc74475c 100644 (file)
@@ -223,14 +223,18 @@ ngx_quic_handle_ack_frame_range(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx,
     st->max_pn = NGX_TIMER_INFINITE;
     found = 0;
 
-    q = ngx_queue_last(&ctx->sent);
+    q = ngx_queue_head(&ctx->sent);
 
     while (q != ngx_queue_sentinel(&ctx->sent)) {
 
         f = ngx_queue_data(q, ngx_quic_frame_t, queue);
-        q = ngx_queue_prev(q);
+        q = ngx_queue_next(q);
+
+        if (f->pnum > max) {
+            break;
+        }
 
-        if (f->pnum >= min && f->pnum <= max) {
+        if (f->pnum >= min) {
             ngx_quic_congestion_ack(c, f);
 
             switch (f->type) {