hero icon indicating copy to clipboard operation
hero copied to clipboard

newPool fills pool.ch with 10000 buffers, but it is never used

Open ekle opened this issue 8 years ago • 4 comments

ekle avatar Feb 13 '17 12:02 ekle

Yes, you are right. I did it on purpose. Cause it's much faster with it than without it.

shiyanhui avatar Feb 13 '17 12:02 shiyanhui

would it make sense to put them in the pool instead of a unused channel ?

with go1.8rc3 linux/amd64 i get similar results no matter if the pool is/not prefilled or the channel way.

ekle avatar Feb 13 '17 13:02 ekle

Nope, because the gc will clear them if they are in sync.Pool. I test it in go1.7 on mac and it did run faster.

shiyanhui avatar Feb 14 '17 02:02 shiyanhui

So that, sync.Pool guarantees that memory is not overused. I doubt one allocation per GC really matters that much. Probably I'm mistaken.

I test it in go1.7 on mac and it did run faster.

Was it benchmark or realworld workload ?

funny-falcon avatar Feb 14 '17 13:02 funny-falcon