Use sampleBuf instead of maintaining lastValue. (#444)
This cuts the size of memSize by 8B. Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
This commit is contained in:
parent
10632217ce
commit
910f3021b0
5
head.go
5
head.go
|
@ -1364,7 +1364,6 @@ type memSeries struct {
|
|||
firstChunkID int
|
||||
|
||||
nextAt int64 // Timestamp at which to cut the next chunk.
|
||||
lastValue float64
|
||||
sampleBuf [4]sample
|
||||
pendingCommit bool // Whether there are samples waiting to be committed to this series.
|
||||
|
||||
|
@ -1432,7 +1431,7 @@ func (s *memSeries) appendable(t int64, v float64) error {
|
|||
}
|
||||
// We are allowing exact duplicates as we can encounter them in valid cases
|
||||
// like federation and erroring out at that time would be extremely noisy.
|
||||
if math.Float64bits(s.lastValue) != math.Float64bits(v) {
|
||||
if math.Float64bits(s.sampleBuf[3].v) != math.Float64bits(v) {
|
||||
return ErrAmendSample
|
||||
}
|
||||
return nil
|
||||
|
@ -1504,8 +1503,6 @@ func (s *memSeries) append(t int64, v float64) (success, chunkCreated bool) {
|
|||
|
||||
c.maxTime = t
|
||||
|
||||
s.lastValue = v
|
||||
|
||||
s.sampleBuf[0] = s.sampleBuf[1]
|
||||
s.sampleBuf[1] = s.sampleBuf[2]
|
||||
s.sampleBuf[2] = s.sampleBuf[3]
|
||||
|
|
Loading…
Reference in New Issue