mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-01 14:47:38 +00:00
lib/storage: do not prefetch metric names for small number of metricIDs
This eliminates prefetchedMetricIDsLock lock contention for queries, which return less than 500 time series.
This is a follow-up for 9d886a2eb0
This commit is contained in:
parent
ecb0a3d27d
commit
41d6c8a7dd
1 changed files with 4 additions and 3 deletions
|
@ -1208,8 +1208,9 @@ func (s *Storage) SearchMetricNames(qt *querytracer.Tracer, tfss []*TagFilters,
|
||||||
func (s *Storage) prefetchMetricNames(qt *querytracer.Tracer, accountID, projectID uint32, srcMetricIDs []uint64, deadline uint64) error {
|
func (s *Storage) prefetchMetricNames(qt *querytracer.Tracer, accountID, projectID uint32, srcMetricIDs []uint64, deadline uint64) error {
|
||||||
qt = qt.NewChild("prefetch metric names for %d metricIDs", len(srcMetricIDs))
|
qt = qt.NewChild("prefetch metric names for %d metricIDs", len(srcMetricIDs))
|
||||||
defer qt.Done()
|
defer qt.Done()
|
||||||
if len(srcMetricIDs) == 0 {
|
|
||||||
qt.Printf("nothing to prefetch")
|
if len(srcMetricIDs) < 500 {
|
||||||
|
qt.Printf("skip pre-fetching metric names for low number of metric ids=%d", len(srcMetricIDs))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1227,7 +1228,7 @@ func (s *Storage) prefetchMetricNames(qt *querytracer.Tracer, accountID, project
|
||||||
qt.Printf("%d out of %d metric names must be pre-fetched", len(metricIDs), len(srcMetricIDs))
|
qt.Printf("%d out of %d metric names must be pre-fetched", len(metricIDs), len(srcMetricIDs))
|
||||||
if len(metricIDs) < 500 {
|
if len(metricIDs) < 500 {
|
||||||
// It is cheaper to skip pre-fetching and obtain metricNames inline.
|
// It is cheaper to skip pre-fetching and obtain metricNames inline.
|
||||||
qt.Printf("skip pre-fetching metric names for low number of metric ids=%d", len(metricIDs))
|
qt.Printf("skip pre-fetching metric names for low number of missing metric ids=%d", len(metricIDs))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
atomic.AddUint64(&s.slowMetricNameLoads, uint64(len(metricIDs)))
|
atomic.AddUint64(&s.slowMetricNameLoads, uint64(len(metricIDs)))
|
||||||
|
|
Loading…
Reference in a new issue