-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
query: introduce dynamic lookback interval #3277
Conversation
Closes thanos-io#2608 This allows queries with large step to make use of downsampled data. Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com>
Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com>
Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com>
ec0651e
to
5262d98
Compare
Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com>
Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job! Thanks for this 👍
Overall to me, it makes sense, just some implementation suggestion etc. 🤗
NOTE: Let's reduce amount of engines we create - can we create just 3 engines (number of resolution we have) and just create promql.Engine wrapper that routes to correct one based on maxSourceResolution? 🤔
cmd/thanos/query.go
Outdated
totalEngines int | ||
newEngine = func(ld time.Duration) *promql.Engine { | ||
var r prometheus.Registerer = reg | ||
if dynamicLookbackDelta { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wow 😱 Makes sense, wonder if it's doable to contribute to Promtheus some tweak to allow us to avoid creating 3 engines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a TODO for now
cmd/thanos/query.go
Outdated
return defaultEvaluationInterval.Milliseconds() | ||
} | ||
totalEngines int | ||
newEngine = func(ld time.Duration) *promql.Engine { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a bit confused, do we need two functions? What about engineFunc
? I guess you wanted to have large number of args in function, but it might be cleaner to embed engineFunc
here, not embedding this function in engineFunc
. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right, having two functions is confusing. Got some coffee, merged engineFunc and newEngine into single engineFactory. IMO things got a lot more unerstandable. I hope this isn't just coffee speaking.
cmd/thanos/query.go
Outdated
for i, d := range deltas[1:] { | ||
if ld < d { | ||
// Convert delta from milliseconds to time.Duration (nanoseconds). | ||
engines[i+1] = newEngine(time.Duration(d * 1_000_000)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks weird and should fail our lints: 1_000_000
- what about using timestamp.Time(...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced with standard time.Duration(d) * time.Millisecond
. Prometheus'es timestamp
seems unhelpful here, as it's Duration
we need, not Time
Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com> Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com>
Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com>
2d31bfe
to
29ea24e
Compare
Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com>
Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com>
Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com>
Well, this seems to be more or less similar to how it is done already - we create at most three engines, but choose correct one with an anonymous function call (note |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One important question that came to my mind before going full for this solution (:
Wait, which one is the current fix / better? (: #3267 or this one? |
Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com>
0cd7f56
to
8daedb0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Some ideas for simplifying the code still, but otherwise LGTM (:
cmd/thanos/query.go
Outdated
totalEngines++ | ||
return wr | ||
} | ||
rawEngine := newEngine(promql.EngineOpts{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this and init all engines in exactly the same way (no matter if raw or not raw) (:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might simplify the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. Done.
Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com>
dda5b24
to
886ddd8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks 👍
Sorry for delayed review 🤗
ld = eo.LookbackDelta.Milliseconds() | ||
) | ||
wrapReg := func(engineNum int) prometheus.Registerer { | ||
return extprom.WrapRegistererWith(map[string]string{"engine": strconv.Itoa(engineNum)}, eo.Reg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just inline this (:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker (:
* query: introduce dynamic lookback interval Closes thanos-io#2608 This allows queries with large step to make use of downsampled data. Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com> * Fix minor checks Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com> * Append changelog Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com> * Add missing copyright Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com> * Use pre-defined downsampling resolution constatns Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com> * Use dynamic lookback delta by default Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com> Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com> * Rename defaultEngine to rawEngine Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com> * Merge engineFunc and newEngine into single engineFactory Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com> * Remove query.dynamic-lookback-delta from docs Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com> * Rename test Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com> * Review fixes Signed-off-by: Vladimir Kononov <krya-kryak@users.noreply.github.com> Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com> Signed-off-by: Oghenebrume50 <raphlbrume@gmail.com>
Closes #2608
This allows queries with large step to make use of downsampled data.
Changes
Verification
This patch was tested with 0.15 branch (minor conflict solved manually), works as expected
Signed-off-by: Vladimir Kononov krya-kryak@users.noreply.github.com