Skip to content

Commit

Permalink
Fix constructor for BytePool
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
  • Loading branch information
chaudum committed Jun 10, 2024
1 parent 97ee3ff commit 9ee6b31
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 13 deletions.
6 changes: 1 addition & 5 deletions pkg/loki/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,11 +763,7 @@ func (t *Loki) initBloomStore() (services.Service, error) {
case "dynamic":
// sync buffer pool for bloom pages
// 128KB 256KB 512KB 1MB 2MB 4MB 8MB 16MB 32MB 64MB 128MB
pageAllocator = mempool.NewBytePoolAllocator(
128<<10, 128<<20, 2,
func(size int) interface{} {
return make([]byte, size)
})
pageAllocator = mempool.NewBytePoolAllocator(128<<10, 128<<20, 2)
case "fixed":
pageAllocator = mempool.New("bloom-page-pool", bsCfg.MemoryManagement.BloomPageMemPoolBuckets, reg)
default:
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/bloom/v1/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ type BlockQuerier struct {
}

// NewBlockQuerier returns a new BlockQuerier for the given block.
// WARNING: You can pass an implementation of Allocator that is responsibe for
// WARNING: You can pass an implementation of Allocator that is responsible for
// whether the underlying byte slice of the bloom page will be returned to the
// pool for efficiency or not. Returning to the pool can only safely be used
// when the underlying bloom bytes don't escape the decoder, i.e. when loading
Expand Down
6 changes: 1 addition & 5 deletions pkg/storage/bloom/v1/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ var (

// buffer pool for series pages
// 1KB 2KB 4KB 8KB 16KB 32KB 64KB 128KB
SeriesPagePool = mempool.NewBytePoolAllocator(
1<<10, 128<<10, 2,
func(size int) interface{} {
return make([]byte, size)
})
SeriesPagePool = mempool.NewBytePoolAllocator(1<<10, 128<<10, 2)
)

func newCRC32() hash.Hash32 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/mempool/allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ type BytePool struct {
pool *pool.Pool
}

func NewBytePoolAllocator(minSize, maxSize int, factor float64, makeFunc func(int) interface{}) *BytePool {
func NewBytePoolAllocator(minSize, maxSize int, factor float64) *BytePool {
return &BytePool{
pool: pool.New(
128<<10, 128<<20, 2,
minSize, maxSize, factor,
func(size int) interface{} {
return make([]byte, size)
}),
Expand Down

0 comments on commit 9ee6b31

Please sign in to comment.