valyala / bytebufferpool

Anti-memory-waste byte buffer pool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Неверный расчёт defaultSize и maxSize

MichaelMonashev opened this issue · comments

Если в строке https://github.com/valyala/bytebufferpool/blob/master/pool.go#L113 сделать вывод результатов калибровки, то окажется, что defaultSize и maxSize очень маленькие. У меня было всего 128 байт почему-то. Хотя данные с которыми работает в основном пул лежат в интервале 1-2кб. Из-за этого естественно append-ы генерят кучу аллокаций сводя на нет все преимущества bytebufferpool .

Google translate:

Incorrect calculation of defaultSize and maxSize

If you output the calibration results in the line https://github.com/valyala/bytebufferpool/blob/master/pool.go#L113 , then it turns out that defaultSize and maxSize are very small. I only had 128 bytes for some reason. Although the data with which the pool mainly works lies in the range of 1-2kb. Because of this, appends naturally generate a bunch of allocations, negating all the benefits of bytebufferpool .

I have this problem as well for larger byte slices.