valyala / fasthttp

Fast HTTP package for Go. Tuned for high performance. Zero memory allocations in hot paths. Up to 10x faster than net/http
MIT License
21.94k stars 1.76k forks source link

copyZeroAlloc: Try WriteTo and ReadFrom before acquiring a buffer #1673

Closed Jille closed 12 months ago

Jille commented 12 months ago

These are the same statements at the beginning of io.CopyBuffer, but by doing them ourselves first we trade off a little cpu for not holding the 4kb buffer during the write.

Jille commented 12 months ago

I only ran go test, no other testing nor benchmarks.

erikdubbelboer commented 12 months ago

Thanks! Makes sense.