mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/streamaggr: make the BenchmarkAggregatorsPushByJobAvg closer to production case with long list of labels per sample
This commit is contained in:
parent
44e15c866a
commit
6f203ebc9f
1 changed files with 15 additions and 19 deletions
|
@ -37,42 +37,38 @@ func benchmarkAggregatorsPush(b *testing.B, output string) {
|
||||||
without: [job]
|
without: [job]
|
||||||
outputs: [%q]
|
outputs: [%q]
|
||||||
`, output)
|
`, output)
|
||||||
pushCalls := 0
|
pushFunc := func(tss []prompbmarshal.TimeSeries) {}
|
||||||
pushFunc := func(tss []prompbmarshal.TimeSeries) {
|
|
||||||
pushCalls++
|
|
||||||
if pushCalls > 1 {
|
|
||||||
panic(fmt.Errorf("pushFunc is expected to be called exactly once at MustStop"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
a, err := newAggregatorsFromData([]byte(config), pushFunc, 0)
|
a, err := newAggregatorsFromData([]byte(config), pushFunc, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("unexpected error when initializing aggregators: %s", err)
|
b.Fatalf("unexpected error when initializing aggregators: %s", err)
|
||||||
}
|
}
|
||||||
defer a.MustStop()
|
defer a.MustStop()
|
||||||
|
|
||||||
|
const loops = 5
|
||||||
|
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
b.SetBytes(int64(len(benchSeries)))
|
b.SetBytes(int64(len(benchSeries) * loops))
|
||||||
b.RunParallel(func(pb *testing.PB) {
|
b.RunParallel(func(pb *testing.PB) {
|
||||||
var matchIdxs []byte
|
var matchIdxs []byte
|
||||||
for pb.Next() {
|
for pb.Next() {
|
||||||
matchIdxs = a.Push(benchSeries, matchIdxs)
|
for i := 0; i < loops; i++ {
|
||||||
|
matchIdxs = a.Push(benchSeries, matchIdxs)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func newBenchSeries(seriesCount, samplesPerSeries int) []prompbmarshal.TimeSeries {
|
func newBenchSeries(seriesCount int) []prompbmarshal.TimeSeries {
|
||||||
a := make([]string, seriesCount*samplesPerSeries)
|
a := make([]string, seriesCount)
|
||||||
for i := 0; i < samplesPerSeries; i++ {
|
for j := 0; j < seriesCount; j++ {
|
||||||
for j := 0; j < seriesCount; j++ {
|
s := fmt.Sprintf(`http_requests_total{path="/foo/%d",job="foo",instance="bar",pod="pod-123232312",namespace="kube-foo-bar",node="node-123-3434-443",`+
|
||||||
s := fmt.Sprintf(`http_requests_total{path="/foo/%d",job="foo",instance="bar"} %d`, j, i*10)
|
`some_other_label="foo-bar-baz",environment="prod",label1="value1",label2="value2",label3="value3"} %d`, j, j*1000)
|
||||||
a = append(a, s)
|
a = append(a, s)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
metrics := strings.Join(a, "\n")
|
metrics := strings.Join(a, "\n")
|
||||||
return mustParsePromMetrics(metrics)
|
return mustParsePromMetrics(metrics)
|
||||||
}
|
}
|
||||||
|
|
||||||
const seriesCount = 10000
|
const seriesCount = 10_000
|
||||||
const samplesPerSeries = 10
|
|
||||||
|
|
||||||
var benchSeries = newBenchSeries(seriesCount, samplesPerSeries)
|
var benchSeries = newBenchSeries(seriesCount)
|
||||||
|
|
Loading…
Reference in a new issue