mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/storage: do not reload metricName for the same metricID in Search.NextMetricBlock
This should speed up Search.NextMetricBlock a bit
This commit is contained in:
parent
9c566f7db9
commit
3a3d2165f9
1 changed files with 15 additions and 9 deletions
|
@ -109,6 +109,8 @@ type Search struct {
|
|||
needClosing bool
|
||||
|
||||
loops int
|
||||
|
||||
prevMetricID uint64
|
||||
}
|
||||
|
||||
func (s *Search) reset() {
|
||||
|
@ -123,6 +125,7 @@ func (s *Search) reset() {
|
|||
s.err = nil
|
||||
s.needClosing = false
|
||||
s.loops = 0
|
||||
s.prevMetricID = 0
|
||||
}
|
||||
|
||||
// Init initializes s from the given storage, tfss and tr.
|
||||
|
@ -190,16 +193,19 @@ func (s *Search) NextMetricBlock() bool {
|
|||
}
|
||||
s.loops++
|
||||
tsid := &s.ts.BlockRef.bh.TSID
|
||||
var err error
|
||||
s.MetricBlockRef.MetricName, err = s.idb.searchMetricNameWithCache(s.MetricBlockRef.MetricName[:0], tsid.MetricID)
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
// Skip missing metricName for tsid.MetricID.
|
||||
// It should be automatically fixed. See indexDB.searchMetricName for details.
|
||||
continue
|
||||
if tsid.MetricID != s.prevMetricID {
|
||||
var err error
|
||||
s.MetricBlockRef.MetricName, err = s.idb.searchMetricNameWithCache(s.MetricBlockRef.MetricName[:0], tsid.MetricID)
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
// Skip missing metricName for tsid.MetricID.
|
||||
// It should be automatically fixed. See indexDB.searchMetricName for details.
|
||||
continue
|
||||
}
|
||||
s.err = err
|
||||
return false
|
||||
}
|
||||
s.err = err
|
||||
return false
|
||||
s.prevMetricID = tsid.MetricID
|
||||
}
|
||||
s.MetricBlockRef.BlockRef = s.ts.BlockRef
|
||||
return true
|
||||
|
|
Loading…
Reference in a new issue