Commit a384956
authored
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 c1ece81 commit a384956
1 file changed
+12
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
86 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
87 | 88 | | |
88 | 89 | | |
89 | | - | |
90 | | - | |
| 90 | + | |
| 91 | + | |
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| |||
196 | 197 | | |
197 | 198 | | |
198 | 199 | | |
199 | | - | |
200 | | - | |
201 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
202 | 203 | | |
203 | | - | |
204 | | - | |
205 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
206 | 207 | | |
207 | 208 | | |
208 | 209 | | |
209 | 210 | | |
210 | | - | |
| 211 | + | |
211 | 212 | | |
212 | 213 | | |
213 | 214 | | |
| |||
0 commit comments