mirror of
https://github.com/prometheus/prometheus.git
synced 2026-02-03 20:39:32 -05:00
Merge pull request #17548 from linasm/improve-BenchmarkJoinQuery
PromQL: Improve BenchmarkJoinQuery
This commit is contained in:
commit
02c68154bc
1 changed files with 23 additions and 11 deletions
|
|
@ -392,40 +392,44 @@ func BenchmarkJoinQuery(b *testing.B) {
|
|||
}
|
||||
engine := promqltest.NewTestEngineWithOpts(b, opts)
|
||||
|
||||
const interval = 10000 // 10s interval.
|
||||
const (
|
||||
interval = 10000 // 10s interval.
|
||||
steps = 5000
|
||||
numInstances = 1000
|
||||
)
|
||||
|
||||
// A day of data plus 10k steps.
|
||||
numIntervals := 8640 + 10000
|
||||
// A day of data plus steps.
|
||||
numIntervals := 8640 + steps
|
||||
|
||||
require.NoError(b, setupJoinQueryTestData(stor, engine, interval, numIntervals, 1000))
|
||||
require.NoError(b, setupJoinQueryTestData(stor, engine, interval, numIntervals, numInstances))
|
||||
|
||||
for _, c := range []benchCase{
|
||||
{
|
||||
expr: `rpc_request_success_total + rpc_request_error_total`,
|
||||
steps: 10000,
|
||||
steps: steps,
|
||||
},
|
||||
{
|
||||
expr: `rpc_request_success_total + ON (job, instance) GROUP_LEFT rpc_request_error_total`,
|
||||
steps: 10000,
|
||||
steps: steps,
|
||||
},
|
||||
{
|
||||
expr: `rpc_request_success_total AND rpc_request_error_total{instance=~"0.*"}`, // 0.* keeps 1/16 of UUID values
|
||||
steps: 10000,
|
||||
steps: steps,
|
||||
},
|
||||
{
|
||||
expr: `rpc_request_success_total OR rpc_request_error_total{instance=~"0.*"}`, // 0.* keeps 1/16 of UUID values
|
||||
steps: 10000,
|
||||
steps: steps,
|
||||
},
|
||||
{
|
||||
expr: `rpc_request_success_total UNLESS rpc_request_error_total{instance=~"0.*"}`, // 0.* keeps 1/16 of UUID values
|
||||
steps: 10000,
|
||||
steps: steps,
|
||||
},
|
||||
} {
|
||||
name := fmt.Sprintf("expr=%s/steps=%d", c.expr, c.steps)
|
||||
b.Run(name, func(b *testing.B) {
|
||||
ctx := context.Background()
|
||||
b.ReportAllocs()
|
||||
for b.Loop() {
|
||||
|
||||
queryFn := func() {
|
||||
qry, err := engine.NewRangeQuery(
|
||||
ctx, stor, nil, c.expr,
|
||||
timestamp.Time(int64((numIntervals-c.steps)*10_000)),
|
||||
|
|
@ -438,6 +442,14 @@ func BenchmarkJoinQuery(b *testing.B) {
|
|||
|
||||
qry.Close()
|
||||
}
|
||||
|
||||
queryFn() // Warm up run.
|
||||
|
||||
b.ResetTimer()
|
||||
b.ReportAllocs()
|
||||
for b.Loop() {
|
||||
queryFn()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue