-
Notifications
You must be signed in to change notification settings - Fork 543
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
MQE: improve performance of subqueries when the parent query is a range query with many steps #9719
Conversation
6fc4fe2
to
de410ca
Compare
c4b87bc
to
3e3d637
Compare
…s populated This also avoids unnecessarily calling `accumulate()` on the first point in `floatRate()` for `rate`.
…n remainder operation
# Conflicts: # CHANGELOG.md
1eb59c8
to
13939cf
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, some nice collection of optimisations.
I think we can optimise the bucketed pools somewhat by enforcing the factor to be 2. I can look at doing that as a followup if you prefer though.
count-- | ||
// Last returns the last point in this ring buffer view. | ||
// It returns false if the view is empty. | ||
func (v FPointRingBufferView) Last() (promql.FPoint, bool) { |
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.
(nit, probably for follow up). I feel like First()
and Last()
should have the same signature. It seems weird to panic in one situation and return false for another.
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.
Agreed, but I'd like to keep this for a separate PR as you suggest.
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.
Just a nit on the test, not blocking on it :-).
lgtm 🚀
What this PR does
This PR is a follow-up PR to #9664.
This PR improves the performance of subqueries when the parent query is a range query with many steps.
It does this by changing the behaviour of the ring buffer implementations to search forwards through the buffer to find the end of the range when a subquery is being evaluated, rather than backwards. Searching backwards makes sense for range vector selectors, where there is expected to only be one point, if any, at the end of the buffer outside the range, but for subqueries in range queries it is expected that there will be many points at the end of the buffer outside the range, so it is usually faster to search from the beginning of the buffer.
I'd suggest reviewing each commit separately, as each builds on the previous one and incrementally improves things.
In benchmarking, peak memory consumption is unchanged, and latency is reduced for both subqueries and range vector selectors. For example:
Which issue(s) this PR fixes or relates to
#9664
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]
.about-versioning.md
updated with experimental features.