bytebufferpool
bytebufferpool copied to clipboard
Go runtime adoption
I was thinking- couldn't Go perform pooling for byte arrays natively and implicitly? Thought I'd bring it up here if this sounds like a logical optimization the runtime could perform.
It's very difficult to implement byte buffer pooling that satisfies all the needs. butebufferpool isn't a silver bullet yet.
It performs better than a dumb sync.Pool when working with variously-sized byte buffers when a small fraction of such buffers has much higher size comparing to the rest (this helps real-world apps based on fasthttp and quicktemplate).
But it still may waste a lot of memory in the case of buffers with wide-range equally distributed sizes. It is advisable to create a separate pool per each use in this case - see Pool docs for details.
@valyala i have the exact situation from your comment, any chance that you can show me some example how to get it done?