Mercurial > hg > nginx
comparison src/http/v3/ngx_http_v3_table.c @ 8989:81a3429db8b0 quic
HTTP/3: delayed Insert Count Increment instruction.
Sending the instruction is delayed until the end of the current event cycle.
Delaying the instruction is allowed by quic-qpack-21, section 2.2.2.3.
The goal is to reduce the amount of data sent back to client by accumulating
several inserts in one instruction and sometimes not sending the instruction at
all, if Section Acknowledgement was sent just before it.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Thu, 27 Jan 2022 12:20:47 +0300 |
parents | 18d23ed15eef |
children | efbcdb9b37dc |
comparison
equal
deleted
inserted
replaced
8988:6434160b4b78 | 8989:81a3429db8b0 |
---|---|
230 ngx_memcpy(field->value.data, value->data, value->len); | 230 ngx_memcpy(field->value.data, value->data, value->len); |
231 | 231 |
232 dt->elts[dt->nelts++] = field; | 232 dt->elts[dt->nelts++] = field; |
233 dt->size += size; | 233 dt->size += size; |
234 | 234 |
235 /* TODO increment can be sent less often */ | 235 dt->insert_count++; |
236 | 236 |
237 if (ngx_http_v3_send_inc_insert_count(c, 1) != NGX_OK) { | 237 ngx_post_event(&dt->send_insert_count, &ngx_posted_events); |
238 return NGX_ERROR; | |
239 } | |
240 | 238 |
241 if (ngx_http_v3_new_entry(c) != NGX_OK) { | 239 if (ngx_http_v3_new_entry(c) != NGX_OK) { |
242 return NGX_ERROR; | 240 return NGX_ERROR; |
243 } | 241 } |
244 | 242 |
245 return NGX_OK; | 243 return NGX_OK; |
244 } | |
245 | |
246 | |
247 void | |
248 ngx_http_v3_inc_insert_count_handler(ngx_event_t *ev) | |
249 { | |
250 ngx_connection_t *c; | |
251 ngx_http_v3_session_t *h3c; | |
252 ngx_http_v3_dynamic_table_t *dt; | |
253 | |
254 c = ev->data; | |
255 | |
256 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
257 "http3 inc insert count handler"); | |
258 | |
259 h3c = ngx_http_v3_get_session(c); | |
260 dt = &h3c->table; | |
261 | |
262 if (dt->insert_count > dt->ack_insert_count) { | |
263 if (ngx_http_v3_send_inc_insert_count(c, | |
264 dt->insert_count - dt->ack_insert_count) | |
265 != NGX_OK) | |
266 { | |
267 return; | |
268 } | |
269 | |
270 dt->ack_insert_count = dt->insert_count; | |
271 } | |
246 } | 272 } |
247 | 273 |
248 | 274 |
249 ngx_int_t | 275 ngx_int_t |
250 ngx_http_v3_set_capacity(ngx_connection_t *c, ngx_uint_t capacity) | 276 ngx_http_v3_set_capacity(ngx_connection_t *c, ngx_uint_t capacity) |
605 | 631 |
606 return NGX_BUSY; | 632 return NGX_BUSY; |
607 } | 633 } |
608 | 634 |
609 | 635 |
636 void | |
637 ngx_http_v3_ack_insert_count(ngx_connection_t *c, uint64_t insert_count) | |
638 { | |
639 ngx_http_v3_session_t *h3c; | |
640 ngx_http_v3_dynamic_table_t *dt; | |
641 | |
642 h3c = ngx_http_v3_get_session(c); | |
643 dt = &h3c->table; | |
644 | |
645 if (dt->ack_insert_count < insert_count) { | |
646 dt->ack_insert_count = insert_count; | |
647 } | |
648 } | |
649 | |
650 | |
610 static void | 651 static void |
611 ngx_http_v3_unblock(void *data) | 652 ngx_http_v3_unblock(void *data) |
612 { | 653 { |
613 ngx_http_v3_block_t *block = data; | 654 ngx_http_v3_block_t *block = data; |
614 | 655 |