mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-26 21:22:33 -08:00
storage: Simplify evictChunkDesc method
This commit is contained in:
parent
65dc8f44d3
commit
31e9db7f0c
|
@ -277,24 +277,23 @@ func (s *memorySeries) maybeCloseHeadChunk() (bool, error) {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// evictChunkDescs evicts chunkDescs if the chunk is evicted.
|
// evictChunkDescs evicts chunkDescs. lenToEvict is the index within the current
|
||||||
// iOldestNotEvicted is the index within the current chunkDescs of the oldest
|
// chunkDescs of the oldest chunk that is not evicted.
|
||||||
// chunk that is not evicted.
|
func (s *memorySeries) evictChunkDescs(lenToEvict int) {
|
||||||
func (s *memorySeries) evictChunkDescs(iOldestNotEvicted int) {
|
if lenToEvict < 1 {
|
||||||
lenToKeep := len(s.chunkDescs) - iOldestNotEvicted
|
return
|
||||||
if lenToKeep < len(s.chunkDescs) {
|
|
||||||
s.savedFirstTime = s.firstTime()
|
|
||||||
lenEvicted := len(s.chunkDescs) - lenToKeep
|
|
||||||
s.chunkDescsOffset += lenEvicted
|
|
||||||
s.persistWatermark -= lenEvicted
|
|
||||||
chunk.DescOps.WithLabelValues(chunk.Evict).Add(float64(lenEvicted))
|
|
||||||
chunk.NumMemDescs.Sub(float64(lenEvicted))
|
|
||||||
s.chunkDescs = append(
|
|
||||||
make([]*chunk.Desc, 0, lenToKeep),
|
|
||||||
s.chunkDescs[lenEvicted:]...,
|
|
||||||
)
|
|
||||||
s.dirty = true
|
|
||||||
}
|
}
|
||||||
|
lenToKeep := len(s.chunkDescs) - lenToEvict
|
||||||
|
s.savedFirstTime = s.firstTime()
|
||||||
|
s.chunkDescsOffset += lenToEvict
|
||||||
|
s.persistWatermark -= lenToEvict
|
||||||
|
chunk.DescOps.WithLabelValues(chunk.Evict).Add(float64(lenToEvict))
|
||||||
|
chunk.NumMemDescs.Sub(float64(lenToEvict))
|
||||||
|
s.chunkDescs = append(
|
||||||
|
make([]*chunk.Desc, 0, lenToKeep),
|
||||||
|
s.chunkDescs[lenToEvict:]...,
|
||||||
|
)
|
||||||
|
s.dirty = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// dropChunks removes chunkDescs older than t. The caller must have locked the
|
// dropChunks removes chunkDescs older than t. The caller must have locked the
|
||||||
|
|
Loading…
Reference in a new issue