diff --git a/common/pool/alloc.go b/common/pool/alloc.go index ee3fa1a18..0a6294030 100644 --- a/common/pool/alloc.go +++ b/common/pool/alloc.go @@ -12,7 +12,7 @@ var defaultAllocator = NewAllocator() // Allocator for incoming frames, optimized to prevent overwriting after zeroing type Allocator struct { - buffers [17]sync.Pool + buffers [11]sync.Pool } // NewAllocator initiates a []byte allocator for frames less than 65536 bytes, @@ -20,13 +20,7 @@ type Allocator struct { // no more than 50%. func NewAllocator() *Allocator { return &Allocator{ - buffers: [...]sync.Pool{ // 1B -> 64K - {New: func() any { return new([1]byte) }}, - {New: func() any { return new([1 << 1]byte) }}, - {New: func() any { return new([1 << 2]byte) }}, - {New: func() any { return new([1 << 3]byte) }}, - {New: func() any { return new([1 << 4]byte) }}, - {New: func() any { return new([1 << 5]byte) }}, + buffers: [...]sync.Pool{ // 64B -> 64K {New: func() any { return new([1 << 6]byte) }}, {New: func() any { return new([1 << 7]byte) }}, {New: func() any { return new([1 << 8]byte) }}, @@ -52,46 +46,38 @@ func (alloc *Allocator) Get(size int) []byte { case size > 65536: return make([]byte, size) default: - index := msb(size) - if size != 1< 64 { + index = msb(size) + if size != 1<