mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmselect/netstorage: pre-allocate 4 block references per each time series during querying
Usually the number of blocks returned per each time series during queries is around 4. So it is a good idea to pre-allocate 4 block references per time series in order to reduce the number of memory allocations.
This commit is contained in:
parent
c5e0f527bc
commit
df2a494a7c
1 changed files with 3 additions and 1 deletions
|
@ -1061,6 +1061,7 @@ func ProcessSearchQuery(qt *querytracer.Tracer, sq *storage.SearchQuery, deadlin
|
||||||
maxSeriesCount := sr.Init(qt, vmstorage.Storage, tfss, tr, sq.MaxMetrics, deadline.Deadline())
|
maxSeriesCount := sr.Init(qt, vmstorage.Storage, tfss, tr, sq.MaxMetrics, deadline.Deadline())
|
||||||
indexSearchDuration.UpdateDuration(startTime)
|
indexSearchDuration.UpdateDuration(startTime)
|
||||||
type blockRefs struct {
|
type blockRefs struct {
|
||||||
|
brsPrealloc [4]blockRef
|
||||||
brs []blockRef
|
brs []blockRef
|
||||||
}
|
}
|
||||||
m := make(map[string]*blockRefs, maxSeriesCount)
|
m := make(map[string]*blockRefs, maxSeriesCount)
|
||||||
|
@ -1094,6 +1095,7 @@ func ProcessSearchQuery(qt *querytracer.Tracer, sq *storage.SearchQuery, deadlin
|
||||||
brs := m[metricName]
|
brs := m[metricName]
|
||||||
if brs == nil {
|
if brs == nil {
|
||||||
brs = &blockRefs{}
|
brs = &blockRefs{}
|
||||||
|
brs.brs = brs.brsPrealloc[:0]
|
||||||
}
|
}
|
||||||
brs.brs = append(brs.brs, blockRef{
|
brs.brs = append(brs.brs, blockRef{
|
||||||
partRef: br.PartRef(),
|
partRef: br.PartRef(),
|
||||||
|
|
Loading…
Reference in a new issue