mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmselect/netstorage: limit the maximum brsPool size to 32Kb at ProcessSearchQuery()
This avoids slow path in Go runtime for allocating objects bigger than 32Kb - see704401ffa0/src/runtime/malloc.go (L11)
This also reduces memory usage a bit for vmselect and single-node VictoriaMetrics after the commit5dd37ad836
. Updates https://github.com/VictoriaMetrics/VictoriaMetrics/pull/5527
This commit is contained in:
parent
fe4ea30a79
commit
cfc1193d15
1 changed files with 6 additions and 0 deletions
|
@ -1425,6 +1425,12 @@ func (tbfw *tmpBlocksFileWrapper) RegisterAndWriteBlock(mb *storage.MetricBlock,
|
|||
addrs := &tbfwLocal.addrssPool[addrsIdx]
|
||||
|
||||
addrsPool := tbfwLocal.addrsPool
|
||||
if uintptr(cap(addrsPool)) >= maxFastAllocBlockSize/unsafe.Sizeof(tmpBlockAddr{}) && len(addrsPool) == cap(addrsPool) {
|
||||
// Allocate a new addrsPool in order to avoid slow allocation of an object
|
||||
// bigger than maxFastAllocBlockSize bytes at append() below.
|
||||
addrsPool = make([]tmpBlockAddr, 0, maxFastAllocBlockSize/unsafe.Sizeof(tmpBlockAddr{}))
|
||||
tbfwLocal.addrsPool = addrsPool
|
||||
}
|
||||
if addrs.addrs == nil || haveSameBlockAddrTails(addrs.addrs, addrsPool) {
|
||||
// It is safe appending addr to addrsPool, since there are no other items added there yet.
|
||||
addrsPool = append(addrsPool, addr)
|
||||
|
|
Loading…
Reference in a new issue