lib/storage: limit loops count in order to reduce max CPU usage during filter search

This commit is contained in:
Aliaksandr Valialkin 2021-03-17 00:46:22 +02:00
parent e2a0c8bd72
commit 41fe707bec

View File

@ -2979,6 +2979,9 @@ func (is *indexSearch) getMetricIDsForDateAndFilters(date uint64, tfs *TagFilter
break
}
maxLoopsCount := getFirstPositiveFilterLoopsCount(tfws[i+1:])
if maxLoopsCount == int64Max {
maxLoopsCount = int64(metricIDsLen) * loopsCountPerMetricNameMatch
}
m, filterLoopsCount, err := is.getMetricIDsForDateTagFilter(tf, date, tfs.commonPrefix, intMax, maxLoopsCount)
if err != nil {
if errors.Is(err, errTooManyLoops) {