Commit 88518a8
committed
tls: Avoid holding a large buffer across await (#1879)
The TLS detection code holds a ~512B buffer when peeking on a socket to
parse an SNI value from a client connection. This is done to avoid a
heap allocation--this optimization is probably premature.
Per a conversation with @carllerche, holding data across an `await` is a
painful anti-pattern that can have severe performance impacts, since the
generated `Future` ends up holding all of this data (on the stack).
Instead, our default behavior should be to use a heap-allocated data
structure for any data that crosses an async `await`.
This change eliminates the stack-allocated buffer in our TLS server in
favor of a heap-allocated buffer.
Signed-off-by: Oliver Gould <[email protected]>1 parent 090d82d commit 88518a8
1 file changed
+12
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
99 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
100 | 101 | | |
101 | 102 | | |
102 | | - | |
103 | | - | |
| 103 | + | |
| 104 | + | |
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
| |||
219 | 220 | | |
220 | 221 | | |
221 | 222 | | |
222 | | - | |
223 | | - | |
224 | | - | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
225 | 226 | | |
226 | | - | |
227 | | - | |
228 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
229 | 230 | | |
230 | 231 | | |
231 | 232 | | |
232 | 233 | | |
233 | | - | |
| 234 | + | |
234 | 235 | | |
235 | 236 | | |
236 | 237 | | |
| |||
0 commit comments