Mercurial > hg > nginx
annotate src/core/ngx_hash.h @ 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 | f8f6b9fee66a |
children |
rev | line source |
---|---|
507 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4412 | 4 * Copyright (C) Nginx, Inc. |
507 | 5 */ |
6 | |
7 | |
8 #ifndef _NGX_HASH_H_INCLUDED_ | |
9 #define _NGX_HASH_H_INCLUDED_ | |
10 | |
11 | |
12 #include <ngx_config.h> | |
13 #include <ngx_core.h> | |
14 | |
15 | |
16 typedef struct { | |
589 | 17 void *value; |
3510
4c70bbdfd076
allow hash key values more than 255 bytes, it does not actually increase mean
Igor Sysoev <igor@sysoev.ru>
parents:
2136
diff
changeset
|
18 u_short len; |
589 | 19 u_char name[1]; |
20 } ngx_hash_elt_t; | |
507 | 21 |
589 | 22 |
23 typedef struct { | |
24 ngx_hash_elt_t **buckets; | |
25 ngx_uint_t size; | |
507 | 26 } ngx_hash_t; |
27 | |
28 | |
29 typedef struct { | |
589 | 30 ngx_hash_t hash; |
31 void *value; | |
32 } ngx_hash_wildcard_t; | |
33 | |
34 | |
35 typedef struct { | |
36 ngx_str_t key; | |
37 ngx_uint_t key_hash; | |
38 void *value; | |
39 } ngx_hash_key_t; | |
40 | |
41 | |
42 typedef ngx_uint_t (*ngx_hash_key_pt) (u_char *data, size_t len); | |
43 | |
44 | |
45 typedef struct { | |
1253
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1241
diff
changeset
|
46 ngx_hash_t hash; |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1241
diff
changeset
|
47 ngx_hash_wildcard_t *wc_head; |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1241
diff
changeset
|
48 ngx_hash_wildcard_t *wc_tail; |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1241
diff
changeset
|
49 } ngx_hash_combined_t; |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1241
diff
changeset
|
50 |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1241
diff
changeset
|
51 |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1241
diff
changeset
|
52 typedef struct { |
589 | 53 ngx_hash_t *hash; |
54 ngx_hash_key_pt key; | |
55 | |
56 ngx_uint_t max_size; | |
57 ngx_uint_t bucket_size; | |
58 | |
59 char *name; | |
60 ngx_pool_t *pool; | |
61 ngx_pool_t *temp_pool; | |
62 } ngx_hash_init_t; | |
63 | |
64 | |
593 | 65 #define NGX_HASH_SMALL 1 |
66 #define NGX_HASH_LARGE 2 | |
67 | |
68 #define NGX_HASH_LARGE_ASIZE 16384 | |
69 #define NGX_HASH_LARGE_HSIZE 10007 | |
70 | |
71 #define NGX_HASH_WILDCARD_KEY 1 | |
597 | 72 #define NGX_HASH_READONLY_KEY 2 |
593 | 73 |
74 | |
75 typedef struct { | |
76 ngx_uint_t hsize; | |
77 | |
78 ngx_pool_t *pool; | |
79 ngx_pool_t *temp_pool; | |
80 | |
81 ngx_array_t keys; | |
82 ngx_array_t *keys_hash; | |
83 | |
1253
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1241
diff
changeset
|
84 ngx_array_t dns_wc_head; |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1241
diff
changeset
|
85 ngx_array_t *dns_wc_head_hash; |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1241
diff
changeset
|
86 |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1241
diff
changeset
|
87 ngx_array_t dns_wc_tail; |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1241
diff
changeset
|
88 ngx_array_t *dns_wc_tail_hash; |
593 | 89 } ngx_hash_keys_arrays_t; |
90 | |
91 | |
8020
f8f6b9fee66a
FastCGI: combining headers with identical names (ticket #1724).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
92 typedef struct ngx_table_elt_s ngx_table_elt_t; |
f8f6b9fee66a
FastCGI: combining headers with identical names (ticket #1724).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
93 |
f8f6b9fee66a
FastCGI: combining headers with identical names (ticket #1724).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
94 struct ngx_table_elt_s { |
589 | 95 ngx_uint_t hash; |
96 ngx_str_t key; | |
97 ngx_str_t value; | |
649 | 98 u_char *lowcase_key; |
8020
f8f6b9fee66a
FastCGI: combining headers with identical names (ticket #1724).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
99 ngx_table_elt_t *next; |
f8f6b9fee66a
FastCGI: combining headers with identical names (ticket #1724).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
100 }; |
507 | 101 |
102 | |
589 | 103 void *ngx_hash_find(ngx_hash_t *hash, ngx_uint_t key, u_char *name, size_t len); |
1253
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1241
diff
changeset
|
104 void *ngx_hash_find_wc_head(ngx_hash_wildcard_t *hwc, u_char *name, size_t len); |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1241
diff
changeset
|
105 void *ngx_hash_find_wc_tail(ngx_hash_wildcard_t *hwc, u_char *name, size_t len); |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1241
diff
changeset
|
106 void *ngx_hash_find_combined(ngx_hash_combined_t *hash, ngx_uint_t key, |
8ef04207c84f
the "www.example.*" wildcard hash support
Igor Sysoev <igor@sysoev.ru>
parents:
1241
diff
changeset
|
107 u_char *name, size_t len); |
589 | 108 |
109 ngx_int_t ngx_hash_init(ngx_hash_init_t *hinit, ngx_hash_key_t *names, | |
110 ngx_uint_t nelts); | |
111 ngx_int_t ngx_hash_wildcard_init(ngx_hash_init_t *hinit, ngx_hash_key_t *names, | |
112 ngx_uint_t nelts); | |
113 | |
649 | 114 #define ngx_hash(key, c) ((ngx_uint_t) key * 31 + c) |
589 | 115 ngx_uint_t ngx_hash_key(u_char *data, size_t len); |
116 ngx_uint_t ngx_hash_key_lc(u_char *data, size_t len); | |
2136 | 117 ngx_uint_t ngx_hash_strlow(u_char *dst, u_char *src, size_t n); |
118 | |
589 | 119 |
593 | 120 ngx_int_t ngx_hash_keys_array_init(ngx_hash_keys_arrays_t *ha, ngx_uint_t type); |
121 ngx_int_t ngx_hash_add_key(ngx_hash_keys_arrays_t *ha, ngx_str_t *key, | |
122 void *value, ngx_uint_t flags); | |
123 | |
589 | 124 |
507 | 125 #endif /* _NGX_HASH_H_INCLUDED_ */ |