lib/storage: do not increment vm_slow_metric_name_loads_total counter for metric_ids which shouldnt be prefetched, since this may mislead users

This commit is contained in:
Aliaksandr Valialkin 2020-05-16 10:21:17 +03:00
parent 4e850cd6a7
commit b19ca3eb5f

View File

@ -817,11 +817,11 @@ func (s *Storage) prefetchMetricNames(tsids []TSID) error {
}
metricIDs = append(metricIDs, metricID)
}
atomic.AddUint64(&s.slowMetricNameLoads, uint64(len(metricIDs)))
if len(metricIDs) < 500 {
// It is cheaper to skip pre-fetching and obtain metricNames inline.
return nil
}
atomic.AddUint64(&s.slowMetricNameLoads, uint64(len(metricIDs)))
// Pre-fetch metricIDs.
sort.Sort(metricIDs)