-
Notifications
You must be signed in to change notification settings - Fork 697
Adding step invariant metrics and fast path for instant queries. #13911
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
Conversation
tacole02
left a comment
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.
Changelog LGTM
pkg/streamingpromql/operators/metrics/operator_metrics_tracker.go
Outdated
Show resolved
Hide resolved
|
Bugbot Autofix prepared a fix for the bug found in the latest run.
|
| // It increments the nodes counter by 1, and the steps saved counter is incremented by the given stepCount-1. | ||
| // If the stepCount is less than or equal to 1 then this function is a no-op. | ||
| func (t *StepInvariantExpressionMetricsTracker) OnStepInvariantExpressionAdded(stepCount int) { | ||
| if stepCount <= 1 { |
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.
If this method is called, then doesn't that mean that a step-invariant node has been added and therefore we should always call t.nodes.Inc()?
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's just an extra safety check ... but I will remove since the planner already checks the step count before calling this function.
pkg/streamingpromql/planning/metrics/planning_metrics_tracker.go
Outdated
Show resolved
Hide resolved
pkg/streamingpromql/planning/metrics/planning_metrics_tracker.go
Outdated
Show resolved
Hide resolved
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.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is ON. A Cloud Agent has been kicked off to fix the reported issues.
pkg/streamingpromql/planning/metrics/planning_metrics_tracker_test.go
Outdated
Show resolved
Hide resolved
|
Bugbot Autofix prepared a fix for 2 of the 2 bugs found in the latest run.
|
What this PR does
This PR introduces metrics for tracking the effectiveness of the step invariant operator.
When an expression is marked as a step invariant, the float or histogram points are assumed to be the same at each step. As such, the inner data only needs to be queried once and the value re-used in each subsequent step.
This PR provides a metric to track the number of points saved / re-used.
This PR also adds a metric for tracking the total number of step invariant nodes which have been observed. Note that not ever step invariant node will result in savings. This can occur if the inner operator returns no data.
An enhancement has also been made to remove the step invariant operator if the query is an instant query - as this operator does not provide any useful value when there is only a single step of data.
The new metrics are;
cortex_mimir_query_engine_step_invariant_nodes_totalcortex_mimir_query_engine_step_invariant_points_saved_total- and this will have a type label of fpoint or hpointTo assist in supporting a metric tracker being passed into the operator, a new
MetricsTrackerhas been added to the query planner which is passed down to operators within theOperatorParameters. This could be re-used to allow other metric trackers to be passed into operators.Which issue(s) this PR fixes or relates to
Fixes #
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]. If changelog entry is not needed, please add thechangelog-not-neededlabel to the PR.about-versioning.mdupdated with experimental features.Note
Introduces metrics and planner changes for step-invariant handling, plus an instant-query fast path.
cortex_mimir_query_engine_step_invariant_nodes_totalandcortex_mimir_query_engine_step_invariant_steps_saved_totalQueryPlannerand increment on step-invariant node creation; passtimeRangethrough planning and compute subquery child ranges to calculate saved stepsStepInvariantExpressionfor instant queriesCHANGELOG.mdWritten by Cursor Bugbot for commit 48928e9. This will update automatically on new commits. Configure here.