Skip to content

Commit

Permalink
plan,execution: tests,benchmarks
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Hoffmann <[email protected]>
  • Loading branch information
MichaHoffmann committed Dec 22, 2023
1 parent ccd2596 commit d3c891c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
6 changes: 5 additions & 1 deletion engine/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ func BenchmarkRangeQuery(b *testing.B) {
query string
storage *teststorage.TestStorage
}{
{
name: "experiment",
query: "sum(http_requests_total)",
storage: sixHourDataset,
},
{
name: "vector selector",
query: "http_requests_total",
Expand Down Expand Up @@ -298,7 +303,6 @@ func BenchmarkRangeQuery(b *testing.B) {
EnableAtModifier: true,
EnableNegativeOffset: true,
},
SelectorBatchSize: 256,
}

for _, tc := range cases {
Expand Down
10 changes: 10 additions & 0 deletions engine/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2671,6 +2671,16 @@ func TestInstantQuery(t *testing.T) {
query string
queryTime time.Time
}{
{
name: "experiment",
load: `load 30s
http_requests_total{pod="nginx-0", route="/"} 1+1x30
http_requests_total{pod="nginx-1", route="/"} 2+1x30
http_requests_total{pod="nginx-2", route="/"} 3+1x30
http_requests_total{pod="nginx-3", route="/"} 4+1x30`,
query: `sum(exp(http_requests_total))`,
queryTime: time.Unix(300, 0),
},
{
name: "offset and @ modifiers",
load: `load 30s
Expand Down
22 changes: 9 additions & 13 deletions logicalplan/sharded_aggregations.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,23 @@ func (m ShardedAggregations) Optimize(plan parser.Expr, _ *query.Options) (parse
return false
}
// TODO: only care about sum now
if aggr.Op != parser.SUM {
if aggr.Op == parser.COUNT {
return false
}
call, ok := (*current).(*parser.Call)
if !ok {
return false
}
if len(call.Args) != 1 {
return false
}
vs, ok := call.Args[0].(*parser.VectorSelector)
vs, ok := (*current).(*parser.VectorSelector)
if !ok {
return false
}

coalesce := Coalesce{make([]parser.Expr, m.Shards)}
for i := range coalesce.Shards {
coalesce.Shards[i] = &parser.Call{
Func: call.Func,
PosRange: call.PosRange,
Args: []parser.Expr{vectorSelectorForShard(vs, i, m.Shards)},
coalesce.Shards[i] = &parser.AggregateExpr{
Op: aggr.Op,
Expr: vectorSelectorForShard(vs, i, m.Shards),
Param: aggr.Param,
Grouping: aggr.Grouping,
Without: aggr.Without,
PosRange: aggr.PosRange,
}
}

Expand Down
4 changes: 2 additions & 2 deletions logicalplan/sharded_aggregations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ func TestShardedAggregations(t *testing.T) {
expected string
}{
{
name: "sum exp",
expr: `sum(exp(X))`,
name: "sum",
expr: `topk(10, X)`,
expected: ``,
},
}
Expand Down

0 comments on commit d3c891c

Please sign in to comment.