diff src/http/v3/ngx_http_v3_request.c @ 8838:d6e191a583cc quic

HTTP/3: bulk parse functions. Previously HTTP/3 streams were parsed by one character. Now all parse functions receive buffers. This should optimize parsing time and CPU load.
author Roman Arutyunyan <arut@nginx.com>
date Thu, 08 Jul 2021 21:52:47 +0300
parents d8d48c977b0f
children e29c1ede905f
line wrap: on
line diff
--- a/src/http/v3/ngx_http_v3_request.c
+++ b/src/http/v3/ngx_http_v3_request.c
@@ -207,6 +207,7 @@ ngx_http_v3_cleanup_request(void *data)
 static void
 ngx_http_v3_process_request(ngx_event_t *rev)
 {
+    u_char                       *p;
     ssize_t                       n;
     ngx_buf_t                    *b;
     ngx_int_t                     rc;
@@ -273,7 +274,9 @@ ngx_http_v3_process_request(ngx_event_t 
             b->last = b->start + n;
         }
 
-        rc = ngx_http_v3_parse_headers(c, st, *b->pos);
+        p = b->pos;
+
+        rc = ngx_http_v3_parse_headers(c, st, b);
 
         if (rc > 0) {
             ngx_http_v3_finalize_connection(c, rc,
@@ -302,8 +305,7 @@ ngx_http_v3_process_request(ngx_event_t 
             break;
         }
 
-        b->pos++;
-        r->request_length++;
+        r->request_length += b->pos - p;
 
         if (rc == NGX_AGAIN) {
             continue;
@@ -1024,6 +1026,7 @@ ngx_http_v3_request_body_filter(ngx_http
 {
     off_t                      max;
     size_t                     size;
+    u_char                    *p;
     ngx_int_t                  rc;
     ngx_buf_t                 *b;
     ngx_uint_t                 last;
@@ -1078,9 +1081,11 @@ ngx_http_v3_request_body_filter(ngx_http
         while (cl->buf->pos < cl->buf->last) {
 
             if (st->length == 0) {
-                r->request_length++;
+                p = cl->buf->pos;
 
-                rc = ngx_http_v3_parse_data(r->connection, st, *cl->buf->pos++);
+                rc = ngx_http_v3_parse_data(r->connection, st, cl->buf);
+
+                r->request_length += cl->buf->pos - p;
 
                 if (rc == NGX_AGAIN) {
                     continue;