mirror of
https://github.com/prometheus/prometheus.git
synced 2026-02-03 20:39:32 -05:00
[PromQL] Improve BenchmarkJoinQuery
Signed-off-by: Linas Medziunas <linas.medziunas@gmail.com>
This commit is contained in:
parent
cefefc6897
commit
de084ae0e7
1 changed files with 23 additions and 11 deletions
|
|
@ -393,40 +393,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)),
|
||||
|
|
@ -439,6 +443,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