fasthttp
fasthttp copied to clipboard
use buffer on response in clientDoDeadline
we want to do this so that we can reuse the response's existing buffer rather than allocating new ones. allocating memory is expensive
isn't it doing that by default? the code as written prior seems to swap the body to reset it after an error occurs.. otherwise it is using the same
Edit: also worth noting that it shouldn't really be allocating unless it needs to.. it's pooling old buffers in http.go for reuse
the key change is L921. L941 is just necessary in order to swap back.
not sure if this actually works - i havent quite got it to do the right thing in media proxy yet. but it does actually use my buffer now, whereas it didnt previously.
also for clarity, in media proxy, fasthttp does not own the buffers, a different part of the server does. so we are in a bad situation because we fasthttp creates a ton of garbage and we have to copy out of its buffers. the idea here is to make fasthttp stop allocating entirely.