perf: remove parser-stage guard to expand stats_query_range fast path#352
Merged
Conversation
Rate, count_over_time, bytes_rate, and bytes_over_time queries with | json or | logfmt parser stages now use VL native stats_query_range when the range window equals the step (tumbling window). Previously these were forced to the manual raw-log-fetch path regardless of the window configuration. Sliding-window queries (range > step) remain on the slow path: the !rangeEqualsStep gate is preserved for correct sliding-window semantics. The originalLogql parameter is dropped from shouldUseManualRangeMetricCompat as it was only used by the removed __error__ exception check.
…ast path PR #350 added collectRangeMetricHits inside proxyManualRangeMetricRange which calls stats_query_range for grouped sliding-window queries. Update the test to serve both VL endpoints and verify a 200 response rather than asserting which internal path is taken. The shouldUseManualRangeMetricCompat gate behavior is already verified by the unit test.
fa1f677 to
7ec5e78
Compare
Contributor
PR Quality ReportCompared against base branch Coverage and tests
Compatibility
Performance smokeLower CPU cost (
State
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
queryUsesParserStagesguard fromshouldUseManualRangeMetricCompatforrate,bytes_rate,count_over_time, andbytes_over_time— queries with| jsonor| logfmtparser stages now use VL nativestats_query_rangewhenrange == step(tumbling window)originalLogql4th parameter fromshouldUseManualRangeMetricCompatand updates both callersrange > step) remain on the slow manual path —!rangeEqualsStepgate is preserved for correct semanticsWhy
The guard was conservative: VL
stats_query_rangenatively handles inline filter pipelines including| unpack_jsonand| unpack_logfmt. Parser-stage queries were forced onto the raw-log-fetch + O(N) aggregation slow path even in tumbling-window configurations where VL native stats is semantically equivalent. This removed a significant bottleneck for common Grafana panels wherestep == $__interval == range.Test Plan
TestShouldUseManualRangeMetricCompat_ParserStageRate(9 cases) — parser-stage rate/count/bytes with tumbling window → fast path, sliding window → slow path preservedTestQueryRange_RateParserStageTumblingUsesStatsQueryRangeandTestQueryRange_RateParserStageSlidingUsesSlowPathgo test ./internal/proxy/... -count=1)TestLogQL_Exhaustive_ErrorParity— 32 error parity cases passTestLogQL_Exhaustive_QueryParity— 84 query parity cases passTestPipeline_MetricQueries— parser-stage metric queries passTestRangeMetricCompatibilityMatrixfailures (rate,count_over_time,bytes_rate,bytes_over_timewith step=60) are pre-existing and unrelated to this change (queries use no parser stages; code path is identical before/after)