Commit 25b0691
committed
http: reuse the connection write buffer when hijacking
Previously, the connection write buffer used an extra 4kB of memory
until the handler finished and the "conn" was garbage collected.
```
goos: linux
goarch: amd64
pkg: net/http
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
│ old.txt │ new.txt │
│ sec/op │ sec/op vs base │
ServerHijack-8 13.28µ ± 2% 10.84µ ± 3% -18.36% (p=0.000 n=10)
│ old.txt │ new.txt │
│ B/op │ B/op vs base │
ServerHijack-8 15.84Ki ± 0% 11.77Ki ± 0% -25.70% (p=0.000 n=10)
│ old.txt │ new.txt │
│ allocs/op │ allocs/op vs base │
ServerHijack-8 50.00 ± 0% 48.00 ± 0% -4.00% (p=0.000 n=10)
```
Signed-off-by: Jakob Ackermann <[email protected]>1 parent 35222ee commit 25b0691
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
322 | 322 | | |
323 | 323 | | |
324 | 324 | | |
325 | | - | |
| 325 | + | |
326 | 326 | | |
327 | 327 | | |
328 | 328 | | |
| |||
0 commit comments