hero
hero copied to clipboard
newPool fills pool.ch with 10000 buffers, but it is never used
Yes, you are right. I did it on purpose. Cause it's much faster with it than without it.
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.
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.
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 ?