mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-24 21:24:05 -08:00
tsdb/index: don't call ExpandPostings in a benchmark
This allocates memory for all the returned values, which skews the result. We aren't trying to benchmark `ExpandPostings`, so just step through all the values without storing them to consume them. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
parent
4931983ca9
commit
3da2c99ffd
|
@ -280,6 +280,13 @@ func TestMultiIntersect(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func consumePostings(p Postings) error {
|
||||||
|
for p.Next() {
|
||||||
|
p.At()
|
||||||
|
}
|
||||||
|
return p.Err()
|
||||||
|
}
|
||||||
|
|
||||||
func BenchmarkIntersect(t *testing.B) {
|
func BenchmarkIntersect(t *testing.B) {
|
||||||
t.Run("LongPostings1", func(bench *testing.B) {
|
t.Run("LongPostings1", func(bench *testing.B) {
|
||||||
var a, b, c, d []storage.SeriesRef
|
var a, b, c, d []storage.SeriesRef
|
||||||
|
@ -307,7 +314,7 @@ func BenchmarkIntersect(t *testing.B) {
|
||||||
i2 := newListPostings(b...)
|
i2 := newListPostings(b...)
|
||||||
i3 := newListPostings(c...)
|
i3 := newListPostings(c...)
|
||||||
i4 := newListPostings(d...)
|
i4 := newListPostings(d...)
|
||||||
if _, err := ExpandPostings(Intersect(i1, i2, i3, i4)); err != nil {
|
if err := consumePostings(Intersect(i1, i2, i3, i4)); err != nil {
|
||||||
bench.Fatal(err)
|
bench.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,7 +343,7 @@ func BenchmarkIntersect(t *testing.B) {
|
||||||
i2 := newListPostings(b...)
|
i2 := newListPostings(b...)
|
||||||
i3 := newListPostings(c...)
|
i3 := newListPostings(c...)
|
||||||
i4 := newListPostings(d...)
|
i4 := newListPostings(d...)
|
||||||
if _, err := ExpandPostings(Intersect(i1, i2, i3, i4)); err != nil {
|
if err := consumePostings(Intersect(i1, i2, i3, i4)); err != nil {
|
||||||
bench.Fatal(err)
|
bench.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -366,7 +373,7 @@ func BenchmarkIntersect(t *testing.B) {
|
||||||
lps[j].list = refs[j]
|
lps[j].list = refs[j]
|
||||||
its[j] = lps[j]
|
its[j] = lps[j]
|
||||||
}
|
}
|
||||||
if _, err := ExpandPostings(Intersect(its...)); err != nil {
|
if err := consumePostings(Intersect(its...)); err != nil {
|
||||||
bench.Fatal(err)
|
bench.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue