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,7 +281,6 @@ func (l *LevelDBMetricPersistence) AppendSamples(samples model.Samples) (err err
|
||||||
fingerprintSet, ok := labelNameFingerprints[labelName]
|
fingerprintSet, ok := labelNameFingerprints[labelName]
|
||||||
if !ok {
|
if !ok {
|
||||||
fingerprintSet = utility.Set{}
|
fingerprintSet = utility.Set{}
|
||||||
}
|
|
||||||
|
|
||||||
fingerprints, err := l.GetFingerprintsForLabelName(labelName)
|
fingerprints, err := l.GetFingerprintsForLabelName(labelName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -293,6 +292,8 @@ func (l *LevelDBMetricPersistence) AppendSamples(samples model.Samples) (err err
|
||||||
for _, fingerprint := range fingerprints {
|
for _, fingerprint := range fingerprints {
|
||||||
fingerprintSet.Add(fingerprint)
|
fingerprintSet.Add(fingerprint)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fingerprintSet.Add(fingerprint)
|
fingerprintSet.Add(fingerprint)
|
||||||
labelNameFingerprints[labelName] = fingerprintSet
|
labelNameFingerprints[labelName] = fingerprintSet
|
||||||
}
|
}
|
||||||
|
@ -344,7 +345,6 @@ func (l *LevelDBMetricPersistence) AppendSamples(samples model.Samples) (err err
|
||||||
fingerprintSet, ok := labelPairFingerprints[labelPair]
|
fingerprintSet, ok := labelPairFingerprints[labelPair]
|
||||||
if !ok {
|
if !ok {
|
||||||
fingerprintSet = utility.Set{}
|
fingerprintSet = utility.Set{}
|
||||||
}
|
|
||||||
|
|
||||||
fingerprints, err := l.GetFingerprintsForLabelSet(model.LabelSet{
|
fingerprints, err := l.GetFingerprintsForLabelSet(model.LabelSet{
|
||||||
labelName: labelValue,
|
labelName: labelValue,
|
||||||
|
@ -358,6 +358,8 @@ func (l *LevelDBMetricPersistence) AppendSamples(samples model.Samples) (err err
|
||||||
for _, fingerprint := range fingerprints {
|
for _, fingerprint := range fingerprints {
|
||||||
fingerprintSet.Add(fingerprint)
|
fingerprintSet.Add(fingerprint)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fingerprintSet.Add(fingerprint)
|
fingerprintSet.Add(fingerprint)
|
||||||
labelPairFingerprints[labelPair] = fingerprintSet
|
labelPairFingerprints[labelPair] = fingerprintSet
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue