app/vmselect/netstorage: limit the initial size for brsPoolCap with 32Kb

This should reduce the number of expensive memory allocations with sizes bigger than 32Kb
This commit is contained in:
Aliaksandr Valialkin 2024-01-23 22:29:29 +02:00
parent 43ecd5d258
commit 1c58c00618
No known key found for this signature in database
GPG Key ID: 52C003EE2BCDB9EB

View File

@ -1167,7 +1167,11 @@ func ProcessSearchQuery(qt *querytracer.Tracer, sq *storage.SearchQuery, deadlin
// brsPool is used for holding the most of blockRefs.brs slices across all the loaded time series.
// It should reduce pressure on Go GC by reducing the number of allocations for blockRefs.brs slices.
brsPool := make([]blockRef, 0, maxSeriesCount)
brsPoolCap := uintptr(maxSeriesCount)
if brsPoolCap > maxFastAllocBlockSize/unsafe.Sizeof(blockRef{}) {
brsPoolCap = maxFastAllocBlockSize / unsafe.Sizeof(blockRef{})
}
brsPool := make([]blockRef, 0, brsPoolCap)
// m maps from metricName to the index of blockRefs inside brssPool
m := make(map[string]int, maxSeriesCount)