Skip to content

Commit

Permalink
Optimized deduplication for deduplicated chunk on query level as well.
Browse files Browse the repository at this point in the history
Never use proto .String() in fast path!

Signed-off-by: Bartlomiej Plotka <[email protected]>
  • Loading branch information
bwplotka committed Jun 3, 2020
1 parent 3de467a commit 00c71a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions pkg/query/iter.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ func (s *promSeriesSet) Next() bool {
return s.currChunks[i].MinTime < s.currChunks[j].MinTime
})

// newChunkSeriesIterator will handle overlaps well, however we don't need to iterate over those samples,
// removed early duplicates here.
// TODO(bwplotka): Remove chunk duplicates on proxy level as well to avoid decoding those.
// https://github.com/thanos-io/thanos/issues/2546, consider skipping removal here then.
// Proxy handles duplicates between different series, let's handle duplicates within single series now as well.
// We don't need to decode those.
s.currChunks = removeExactDuplicates(s.currChunks)
return true
}
Expand All @@ -81,7 +79,7 @@ func removeExactDuplicates(chks []storepb.AggrChunk) []storepb.AggrChunk {
ret = append(ret, chks[0])

for _, c := range chks[1:] {
if ret[len(ret)-1].String() == c.String() {
if ret[len(ret)-1].Compare(c) == 0 {
continue
}
ret = append(ret, c)
Expand Down
2 changes: 1 addition & 1 deletion pkg/store/storepb/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
package storepb

import (
"bytes"
"fmt"
"sort"
"strconv"
"bytes"
"strings"
"unsafe"

Expand Down

0 comments on commit 00c71a4

Please sign in to comment.