From 6fa9b0f5062c00344e449d3282931843b8d2ab0e Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Fri, 1 Feb 2019 11:41:27 +0000 Subject: [PATCH] Strip Chunk interface indirection on bigchunk sub-chunks The Chunk indirection doubles the pointer size for every sub-chunk, which we don't need because there is only one kind of Chunk. Signed-off-by: Bryan Boreham --- encoding/bigchunk.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/encoding/bigchunk.go b/encoding/bigchunk.go index e929d4c99cb56..145564e564ccd 100644 --- a/encoding/bigchunk.go +++ b/encoding/bigchunk.go @@ -15,7 +15,7 @@ const samplesPerChunk = 120 var errOutOfBounds = errors.New("out of bounds") type smallChunk struct { - chunkenc.Chunk + *chunkenc.XORChunk start int64 end int64 } @@ -54,14 +54,14 @@ func (b *bigchunk) addNextChunk(start model.Time) error { // To save memory, we "compact" the previous chunk - the array backing the slice // will be upto 2x too big, and we can save this space. if l := len(b.chunks); l > 0 { - c := b.chunks[l-1].Chunk + c := b.chunks[l-1].XORChunk buf := make([]byte, len(c.Bytes())) copy(buf, c.Bytes()) compacted, err := chunkenc.FromData(chunkenc.EncXOR, buf) if err != nil { return err } - b.chunks[l-1].Chunk = compacted + b.chunks[l-1].XORChunk = compacted.(*chunkenc.XORChunk) } chunk := chunkenc.NewXORChunk() @@ -71,9 +71,9 @@ func (b *bigchunk) addNextChunk(start model.Time) error { } b.chunks = append(b.chunks, smallChunk{ - Chunk: chunk, - start: int64(start), - end: int64(start), + XORChunk: chunk, + start: int64(start), + end: int64(start), }) b.appender = appender @@ -133,9 +133,9 @@ func (b *bigchunk) UnmarshalFromBuf(buf []byte) error { } b.chunks = append(b.chunks, smallChunk{ - Chunk: chunk, - start: int64(start), - end: int64(end), + XORChunk: chunk.(*chunkenc.XORChunk), + start: int64(start), + end: int64(end), }) } return nil