From 910f3021b054c52cb8bde1ab1964eae3eceb84fd Mon Sep 17 00:00:00 2001 From: Brian Brazil Date: Wed, 14 Nov 2018 14:02:32 +0000 Subject: [PATCH] Use sampleBuf instead of maintaining lastValue. (#444) This cuts the size of memSize by 8B. Signed-off-by: Brian Brazil --- head.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/head.go b/head.go index 0a67400e0..30ab05b29 100644 --- a/head.go +++ b/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]