Repository navigation
Conversation
Signed-off-by: Teiva Harsanyi <[email protected]>
corhere
left a comment
There was a problem hiding this comment.
After examining the implementation of writer, I am very skeptical that pooling buffers from closed writers for reuse in new writers is the right choice of starting point for optimizing the S3 driver's GC pressure. func (*writer) Write and especially func (*writer) flushPart drop buffers all over the place, pretty much guaranteeing that any buffer taken from the pool will be used by at most two writers before becoming garbage. For instance, each call to func (*writer) flushPart drops either w.pendingPart or w.readyPart if the buffers are nonempty. Optimize writer to better reuse its own buffers before thinking about reusing buffers between writers.
For example, flushPart currently flips the pending and ready buffers by
w.readyPart = w.pendingPart
w.pendingPart = nilwhich drops the buffer which was assigned to w.readyPart. That buffer could instead be reused for the next w.pendingPart:
tmp := w.readyPart[:0]
w.readyPart = w.pendingPart
w.pendingPart = tmp| w.pool.Put(w.readyPart[:0]) | ||
| w.pool.Put(w.pendingPart[:0]) |
There was a problem hiding this comment.
The w.pool field is redundant as it can be accessed via w.driver.pool.
| w.pool.Put(w.readyPart[:0]) | |
| w.pool.Put(w.pendingPart[:0]) | |
| w.driver.pool.Put(w.readyPart[:0]) | |
| w.driver.pool.Put(w.pendingPart[:0]) |
|
Closing in favour of #4066 |
Use a pool to store the S3 driver buffers.