Conditionalize LevelDB index retrievals.
The LevelDB index retrievals could be repeated in a given operation batch if multiple queued mutations affect the same (Label Name) singles and (Label Name, Label Value) doubles. This is wasteful and inefficient, as a single retrieval suffices. Thusly this commit retrieves the canonical index mappings if the said mapping has not been looked up in a given batch.
This commit is contained in:
parent
34a921e16d
commit
1e0d740f2a
|
@ -281,18 +281,19 @@ func (l *LevelDBMetricPersistence) AppendSamples(samples model.Samples) (err err
|
|||
fingerprintSet, ok := labelNameFingerprints[labelName]
|
||||
if !ok {
|
||||
fingerprintSet = utility.Set{}
|
||||
|
||||
fingerprints, err := l.GetFingerprintsForLabelName(labelName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
doneBuildingLabelNameIndex <- err
|
||||
return
|
||||
}
|
||||
|
||||
for _, fingerprint := range fingerprints {
|
||||
fingerprintSet.Add(fingerprint)
|
||||
}
|
||||
}
|
||||
|
||||
fingerprints, err := l.GetFingerprintsForLabelName(labelName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
doneBuildingLabelNameIndex <- err
|
||||
return
|
||||
}
|
||||
|
||||
for _, fingerprint := range fingerprints {
|
||||
fingerprintSet.Add(fingerprint)
|
||||
}
|
||||
fingerprintSet.Add(fingerprint)
|
||||
labelNameFingerprints[labelName] = fingerprintSet
|
||||
}
|
||||
|
@ -344,20 +345,21 @@ func (l *LevelDBMetricPersistence) AppendSamples(samples model.Samples) (err err
|
|||
fingerprintSet, ok := labelPairFingerprints[labelPair]
|
||||
if !ok {
|
||||
fingerprintSet = utility.Set{}
|
||||
|
||||
fingerprints, err := l.GetFingerprintsForLabelSet(model.LabelSet{
|
||||
labelName: labelValue,
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
doneBuildingLabelPairIndex <- err
|
||||
return
|
||||
}
|
||||
|
||||
for _, fingerprint := range fingerprints {
|
||||
fingerprintSet.Add(fingerprint)
|
||||
}
|
||||
}
|
||||
|
||||
fingerprints, err := l.GetFingerprintsForLabelSet(model.LabelSet{
|
||||
labelName: labelValue,
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
doneBuildingLabelPairIndex <- err
|
||||
return
|
||||
}
|
||||
|
||||
for _, fingerprint := range fingerprints {
|
||||
fingerprintSet.Add(fingerprint)
|
||||
}
|
||||
fingerprintSet.Add(fingerprint)
|
||||
labelPairFingerprints[labelPair] = fingerprintSet
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue