From 6181d1f18fc8578a89ccbabe8cee907e536aa034 Mon Sep 17 00:00:00 2001 From: yeya24 Date: Tue, 29 Jan 2019 10:25:12 +0800 Subject: [PATCH 1/3] fix two typos in db_test Signed-off-by: yeya24 --- db_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db_test.go b/db_test.go index e3e90ce8b..f727a7919 100644 --- a/db_test.go +++ b/db_test.go @@ -1604,9 +1604,9 @@ func TestCorrectNumTombstones(t *testing.T) { // TestBlockRanges checks the following use cases: // - No samples can be added with timestamps lower than the last block maxt. -// - The compactor doesn't create overlaping blocks +// - The compactor doesn't create overlapping blocks // even when the last blocks is not within the default boundaries. -// - Lower bondary is based on the smallest sample in the head and +// - Lower boundary is based on the smallest sample in the head and // upper boundary is rounded to the configured block range. // // This ensures that a snapshot that includes the head and creates a block with a custom time range From eb5034d5b0c54651beee345590b17a1040d67f9c Mon Sep 17 00:00:00 2001 From: radek_lesniewski Date: Tue, 29 Jan 2019 12:23:53 +0100 Subject: [PATCH 2/3] Additional logging in compact.go - logged time needed for writing blocks (#505) * Additional logging in compact.go - logged time needed for writing blocks to disk Signed-off-by: Radoslaw Lesniewski * Additional logging in compact.go - code formatted Signed-off-by: Radoslaw Lesniewski --- compact.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/compact.go b/compact.go index 5d8155f51..0358a8006 100644 --- a/compact.go +++ b/compact.go @@ -414,6 +414,8 @@ func (c *LeveledCompactor) Compact(dest string, dirs []string, open []*Block) (u } func (c *LeveledCompactor) Write(dest string, b BlockReader, mint, maxt int64, parent *BlockMeta) (ulid.ULID, error) { + start := time.Now() + entropy := rand.New(rand.NewSource(time.Now().UnixNano())) uid := ulid.MustNew(ulid.Now(), entropy) @@ -440,7 +442,13 @@ func (c *LeveledCompactor) Write(dest string, b BlockReader, mint, maxt int64, p return ulid.ULID{}, nil } - level.Info(c.logger).Log("msg", "write block", "mint", meta.MinTime, "maxt", meta.MaxTime, "ulid", meta.ULID) + level.Info(c.logger).Log( + "msg", "write block", + "mint", meta.MinTime, + "maxt", meta.MaxTime, + "ulid", meta.ULID, + "duration", time.Since(start), + ) return uid, nil } From ee99718ff622f7b8b6ecdee3db6592e5184023ec Mon Sep 17 00:00:00 2001 From: Krasi Georgiev Date: Tue, 29 Jan 2019 20:46:12 +0300 Subject: [PATCH 3/3] rename chunk reader vars to make it easier to follow. (#508) * rename chunk reader vars to make it easyer to understand. Signed-off-by: Krasi Georgiev --- chunks/chunks.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/chunks/chunks.go b/chunks/chunks.go index f35ad2cdd..fe3e982e8 100644 --- a/chunks/chunks.go +++ b/chunks/chunks.go @@ -352,30 +352,31 @@ func (s *Reader) Size() int64 { return s.size } +// Chunk returns a chunk from a given reference. func (s *Reader) Chunk(ref uint64) (chunkenc.Chunk, error) { var ( - seq = int(ref >> 32) - off = int((ref << 32) >> 32) + sgmSeq = int(ref >> 32) + sgmOffset = int((ref << 32) >> 32) ) - if seq >= len(s.bs) { - return nil, errors.Errorf("reference sequence %d out of range", seq) + if sgmSeq >= len(s.bs) { + return nil, errors.Errorf("reference sequence %d out of range", sgmSeq) } - b := s.bs[seq] + chkS := s.bs[sgmSeq] - if off >= b.Len() { - return nil, errors.Errorf("offset %d beyond data size %d", off, b.Len()) + if sgmOffset >= chkS.Len() { + return nil, errors.Errorf("offset %d beyond data size %d", sgmOffset, chkS.Len()) } // With the minimum chunk length this should never cause us reading // over the end of the slice. - r := b.Range(off, off+binary.MaxVarintLen32) + chk := chkS.Range(sgmOffset, sgmOffset+binary.MaxVarintLen32) - l, n := binary.Uvarint(r) + chkLen, n := binary.Uvarint(chk) if n <= 0 { return nil, errors.Errorf("reading chunk length failed with %d", n) } - r = b.Range(off+n, off+n+1+int(l)) + chk = chkS.Range(sgmOffset+n, sgmOffset+n+1+int(chkLen)) - return s.pool.Get(chunkenc.Encoding(r[0]), r[1:1+l]) + return s.pool.Get(chunkenc.Encoding(chk[0]), chk[1:1+chkLen]) } func nextSequenceFile(dir string) (string, int, error) {