mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmselect/netstorage: remove superflouos map lookup at ProcessSearchQuery
This should reduce CPU usage a bit during querying
This commit is contained in:
parent
519bd2af7b
commit
cae0f37edd
1 changed files with 10 additions and 6 deletions
|
@ -1011,7 +1011,10 @@ func ProcessSearchQuery(qt *querytracer.Tracer, sq *storage.SearchQuery, deadlin
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
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)
|
||||||
m := make(map[string][]blockRef, maxSeriesCount)
|
type blockRefs struct {
|
||||||
|
brs []blockRef
|
||||||
|
}
|
||||||
|
m := make(map[string]*blockRefs, maxSeriesCount)
|
||||||
orderedMetricNames := make([]string, 0, maxSeriesCount)
|
orderedMetricNames := make([]string, 0, maxSeriesCount)
|
||||||
blocksRead := 0
|
blocksRead := 0
|
||||||
samples := 0
|
samples := 0
|
||||||
|
@ -1040,13 +1043,14 @@ func ProcessSearchQuery(qt *querytracer.Tracer, sq *storage.SearchQuery, deadlin
|
||||||
}
|
}
|
||||||
metricName := sr.MetricBlockRef.MetricName
|
metricName := sr.MetricBlockRef.MetricName
|
||||||
brs := m[string(metricName)]
|
brs := m[string(metricName)]
|
||||||
brs = append(brs, blockRef{
|
if brs == nil {
|
||||||
|
brs = &blockRefs{}
|
||||||
|
}
|
||||||
|
brs.brs = append(brs.brs, blockRef{
|
||||||
partRef: br.PartRef(),
|
partRef: br.PartRef(),
|
||||||
addr: addr,
|
addr: addr,
|
||||||
})
|
})
|
||||||
if len(brs) > 1 {
|
if len(brs.brs) == 1 {
|
||||||
m[string(metricName)] = brs
|
|
||||||
} else {
|
|
||||||
// An optimization for big number of time series with long metricName values:
|
// An optimization for big number of time series with long metricName values:
|
||||||
// use only a single copy of metricName for both orderedMetricNames and m.
|
// use only a single copy of metricName for both orderedMetricNames and m.
|
||||||
orderedMetricNames = append(orderedMetricNames, string(metricName))
|
orderedMetricNames = append(orderedMetricNames, string(metricName))
|
||||||
|
@ -1075,7 +1079,7 @@ func ProcessSearchQuery(qt *querytracer.Tracer, sq *storage.SearchQuery, deadlin
|
||||||
for i, metricName := range orderedMetricNames {
|
for i, metricName := range orderedMetricNames {
|
||||||
pts[i] = packedTimeseries{
|
pts[i] = packedTimeseries{
|
||||||
metricName: metricName,
|
metricName: metricName,
|
||||||
brs: m[metricName],
|
brs: m[metricName].brs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rss.packedTimeseries = pts
|
rss.packedTimeseries = pts
|
||||||
|
|
Loading…
Reference in a new issue