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 576a80b3d9
commit ccfb0ae2d3

View file

@ -2954,6 +2954,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) {