Skip to content
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: subqueries #9664

Merged
merged 23 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
58bc4a1
Enable upstream tests
charleskorn Oct 17, 2024
f4421f7
Add benchmark
charleskorn Oct 17, 2024
ab68d7e
Introduce feature toggle
charleskorn Oct 17, 2024
9a0372d
Don't assume all operators are running at the top level of a query
charleskorn Oct 17, 2024
f552373
Add ability to reuse an existing point slice for a ring buffer
charleskorn Oct 17, 2024
7fc1348
Add `Release` method to ring buffers
charleskorn Oct 17, 2024
90a2d8d
Introduce range query tests
charleskorn Oct 17, 2024
afa52a2
Bring in TestSubquerySelector from Prometheus
charleskorn Oct 17, 2024
cc200b8
Change `RangeVectorOperator.NextStepSamples` to return ring buffers r…
charleskorn Oct 17, 2024
07842b3
Refactor `TestSubqueries`
charleskorn Oct 18, 2024
0c4eebb
Initial (largely working) implementation
charleskorn Oct 18, 2024
39c15b6
Fix handling of @
charleskorn Oct 18, 2024
8c06a74
Enable newly supported upstream test cases
charleskorn Oct 18, 2024
787630a
Add further benchmark
charleskorn Oct 18, 2024
72bd91d
Add changelog entry
charleskorn Oct 18, 2024
3802b09
Merge branch 'main' into charleskorn/mqe-subqueries
charleskorn Oct 20, 2024
871dd6e
Address PR feedback: clarify comments
charleskorn Oct 21, 2024
c28cd84
Add tests for ring buffer `Release` implementations
charleskorn Oct 21, 2024
489fe40
Address PR feedback: update comment to match new behaviour
charleskorn Oct 21, 2024
6920206
Address PR feedback: fix indentation
charleskorn Oct 21, 2024
ac84802
Expand native histogram tests
charleskorn Oct 21, 2024
220e5de
Add test for deeply nested subqueries with changing step.
charleskorn Oct 21, 2024
deb30ad
Run test cases in TestSubqueries against Prometheus' engine too.
charleskorn Oct 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* `cortex_alertmanager_alerts`
* `cortex_alertmanager_silences`
* [CHANGE] Distributor: Drop experimental `-distributor.direct-otlp-translation-enabled` flag, since direct OTLP translation is well tested at this point. #9647
* [FEATURE] Querier: add experimental streaming PromQL engine, enabled with `-querier.query-engine=mimir`. #9367 #9368 #9398 #9399 #9403 #9417 #9418 #9419 #9420 #9482 #9504 #9505 #9507 #9518 #9531 #9532 #9533 #9553 #9558 #9588 #9589 #9639 #9641 #9642
* [FEATURE] Querier: add experimental streaming PromQL engine, enabled with `-querier.query-engine=mimir`. #9367 #9368 #9398 #9399 #9403 #9417 #9418 #9419 #9420 #9482 #9504 #9505 #9507 #9518 #9531 #9532 #9533 #9553 #9558 #9588 #9589 #9639 #9641 #9642 #9664
* [FEATURE] Query-frontend: added experimental configuration options `query-frontend.cache-errors` and `query-frontend.results-cache-ttl-for-errors` to allow non-transient responses to be cached. When set to `true` error responses from hitting limits or bad data are cached for a short TTL. #9028
* [FEATURE] gRPC: Support S2 compression. #9322
* `-alertmanager.alertmanager-client.grpc-compression=s2`
Expand Down
11 changes: 11 additions & 0 deletions cmd/mimir/config-descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -2032,6 +2032,17 @@
"fieldFlag": "querier.mimir-query-engine.enable-scalars",
"fieldType": "boolean",
"fieldCategory": "experimental"
},
{
"kind": "field",
"name": "enable_subqueries",
"required": false,
"desc": "Enable support for subqueries in Mimir's query engine. Only applies if the Mimir query engine is in use.",
"fieldValue": null,
"fieldDefaultValue": true,
"fieldFlag": "querier.mimir-query-engine.enable-subqueries",
"fieldType": "boolean",
"fieldCategory": "experimental"
}
],
"fieldValue": null,
Expand Down
2 changes: 2 additions & 0 deletions cmd/mimir/help-all.txt.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -1957,6 +1957,8 @@ Usage of ./cmd/mimir/mimir:
[experimental] Enable support for binary comparison operations between two scalars in Mimir's query engine. Only applies if the Mimir query engine is in use. (default true)
-querier.mimir-query-engine.enable-scalars
[experimental] Enable support for scalars in Mimir's query engine. Only applies if the Mimir query engine is in use. (default true)
-querier.mimir-query-engine.enable-subqueries
[experimental] Enable support for subqueries in Mimir's query engine. Only applies if the Mimir query engine is in use. (default true)
-querier.mimir-query-engine.enable-vector-scalar-binary-comparison-operations
[experimental] Enable support for binary comparison operations between a vector and a scalar in Mimir's query engine. Only applies if the Mimir query engine is in use. (default true)
-querier.mimir-query-engine.enable-vector-vector-binary-comparison-operations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1534,6 +1534,11 @@ mimir_query_engine:
# applies if the Mimir query engine is in use.
# CLI flag: -querier.mimir-query-engine.enable-scalars
[enable_scalars: <boolean> | default = true]

# (experimental) Enable support for subqueries in Mimir's query engine. Only
# applies if the Mimir query engine is in use.
# CLI flag: -querier.mimir-query-engine.enable-subqueries
[enable_subqueries: <boolean> | default = true]
```

### frontend
Expand Down
10 changes: 10 additions & 0 deletions pkg/streamingpromql/benchmarks/benchmarks.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ func TestCases(metricSizes []int) []BenchCase {
//{
// Expr: "absent_over_time(a_X[1d])",
//},
// Subqueries.
{
Expr: "sum_over_time(a_X[10m:3m])",
},
{
Expr: "sum_over_time(nh_X[10m:3m])",
},
{
Expr: "sum(sum_over_time(a_X[10m:3m]))",
},
//// Unary operators.
//{
// Expr: "-a_X",
Expand Down
3 changes: 3 additions & 0 deletions pkg/streamingpromql/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type FeatureToggles struct {
EnableScalarScalarBinaryComparisonOperations bool `yaml:"enable_scalar_scalar_binary_comparison_operations" category:"experimental"`
EnableBinaryLogicalOperations bool `yaml:"enable_binary_logical_operations" category:"experimental"`
EnableScalars bool `yaml:"enable_scalars" category:"experimental"`
EnableSubqueries bool `yaml:"enable_subqueries" category:"experimental"`
}

// EnableAllFeatures enables all features supported by MQE, including experimental or incomplete features.
Expand All @@ -35,6 +36,7 @@ var EnableAllFeatures = FeatureToggles{
true,
true,
true,
true,
}

func (t *FeatureToggles) RegisterFlags(f *flag.FlagSet) {
Expand All @@ -44,4 +46,5 @@ func (t *FeatureToggles) RegisterFlags(f *flag.FlagSet) {
f.BoolVar(&t.EnableScalarScalarBinaryComparisonOperations, "querier.mimir-query-engine.enable-scalar-scalar-binary-comparison-operations", true, "Enable support for binary comparison operations between two scalars in Mimir's query engine. Only applies if the Mimir query engine is in use.")
f.BoolVar(&t.EnableBinaryLogicalOperations, "querier.mimir-query-engine.enable-binary-logical-operations", true, "Enable support for binary logical operations in Mimir's query engine. Only applies if the Mimir query engine is in use.")
f.BoolVar(&t.EnableScalars, "querier.mimir-query-engine.enable-scalars", true, "Enable support for scalars in Mimir's query engine. Only applies if the Mimir query engine is in use.")
f.BoolVar(&t.EnableSubqueries, "querier.mimir-query-engine.enable-subqueries", true, "Enable support for subqueries in Mimir's query engine. Only applies if the Mimir query engine is in use.")
}
22 changes: 12 additions & 10 deletions pkg/streamingpromql/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ func NewEngine(opts EngineOpts, limitsProvider QueryLimitsProvider, metrics *sta
}

return &Engine{
lookbackDelta: lookbackDelta,
timeout: opts.CommonOpts.Timeout,
limitsProvider: limitsProvider,
activeQueryTracker: opts.CommonOpts.ActiveQueryTracker,
featureToggles: opts.FeatureToggles,
lookbackDelta: lookbackDelta,
timeout: opts.CommonOpts.Timeout,
limitsProvider: limitsProvider,
activeQueryTracker: opts.CommonOpts.ActiveQueryTracker,
featureToggles: opts.FeatureToggles,
noStepSubqueryIntervalFn: opts.CommonOpts.NoStepSubqueryIntervalFn,

logger: logger,
estimatedPeakMemoryConsumption: promauto.With(opts.CommonOpts.Reg).NewHistogram(prometheus.HistogramOpts{
Expand All @@ -64,11 +65,12 @@ func NewEngine(opts EngineOpts, limitsProvider QueryLimitsProvider, metrics *sta
}

type Engine struct {
lookbackDelta time.Duration
timeout time.Duration
limitsProvider QueryLimitsProvider
activeQueryTracker promql.QueryTracker
featureToggles FeatureToggles
lookbackDelta time.Duration
timeout time.Duration
limitsProvider QueryLimitsProvider
activeQueryTracker promql.QueryTracker
featureToggles FeatureToggles
noStepSubqueryIntervalFn func(rangeMillis int64) int64

logger log.Logger
estimatedPeakMemoryConsumption prometheus.Histogram
Expand Down
Loading