Skip to content

Commit 017db76

Browse files
committed
changelog/comments
Signed-off-by: Alan Protasio <[email protected]>
1 parent 5a0086a commit 017db76

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## master / unreleased
44

5+
* [ENHANCEMENT] Querier: Batch Iterator optimization to prevent transversing it multiple times query ranges steps does not overlap. #5237
6+
57
## 1.15.0 in progress
68

79
* [CHANGE] Storage: Make Max exemplars config per tenant instead of global configuration. #5016

pkg/querier/batch/batch.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type iterator interface {
4343
// Seek or Next have returned true.
4444
AtTime() int64
4545

46-
// MaxCurrentChunkTime returns the max time on the current chunk
46+
// MaxCurrentChunkTime returns the max time on the current chunk.
4747
MaxCurrentChunkTime() int64
4848

4949
// Batch returns the current batch. Must only be called after Seek or Next
@@ -103,7 +103,10 @@ func (a *iteratorAdapter) Seek(t int64) bool {
103103
return true
104104
} else if t <= a.underlying.MaxCurrentChunkTime() {
105105
// In this case, some timestamp inside the current underlying chunk can fulfill the seek.
106-
// In this case we will call next until we find the sample as it will be faster than calling seek directly.
106+
// In this case we will call next until we find the sample as it will be faster than calling
107+
// `a.underlying.Seek` directly as this would cause the iterator to start from the beginning of the chunk.
108+
// See: https://github.com/cortexproject/cortex/blob/f69452975877c67ac307709e5f60b8d20477764c/pkg/querier/batch/chunk.go#L26-L45
109+
// https://github.com/cortexproject/cortex/blob/f69452975877c67ac307709e5f60b8d20477764c/pkg/chunk/encoding/prometheus_chunk.go#L90-L95
107110
for a.Next() {
108111
if t <= a.curr.Timestamps[a.curr.Index] {
109112
return true

0 commit comments

Comments
 (0)