Commit 2c01429
authored
tonic: Server::default(): Set TCP_NODELAY to true; improve docs (#2413)
## Motivation
I recently ran into problems where we accidentally "lost" the
tcp_nodelay=true setting, due to refactoring some code to make it easier
to test. This caused mysterious 40 ms latency increases. I hope this
makes it less likely for others to make this mistake.
## Solution
The documentation of the `Server::tcp_nodelay()` function said "Enabled
by default", but that was only true when using `Server::builder()`. The
`default()` method set this to false. To fix this:
* Change Server::default() to set tcp_nodelay: true.
* Change Server::builder() to just call Server::default().
* Add a test to verify the settings for nodelay and keepalive.
* Document the functions to note that the TCP settings are ignored when
using `serve_with_incoming`. `tcp_keepalive` already had this note. I
added the same documentation to `tcp_nodelay` and to
`serve_with_incoming` so it is less likely to be missed.1 parent 2f39519 commit 2c01429
1 file changed
+37
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
| 151 | + | |
156 | 152 | | |
157 | 153 | | |
158 | 154 | | |
| |||
346 | 342 | | |
347 | 343 | | |
348 | 344 | | |
349 | | - | |
| 345 | + | |
350 | 346 | | |
351 | 347 | | |
352 | 348 | | |
| |||
359 | 355 | | |
360 | 356 | | |
361 | 357 | | |
| 358 | + | |
| 359 | + | |
362 | 360 | | |
363 | 361 | | |
364 | 362 | | |
| |||
607 | 605 | | |
608 | 606 | | |
609 | 607 | | |
| 608 | + | |
| 609 | + | |
610 | 610 | | |
611 | 611 | | |
612 | 612 | | |
| |||
1154 | 1154 | | |
1155 | 1155 | | |
1156 | 1156 | | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
0 commit comments