From 92736182ce07eb70088903f5874225ad487a41fa Mon Sep 17 00:00:00 2001 From: Cyril Tovena Date: Wed, 6 Oct 2021 14:16:14 +0200 Subject: [PATCH] Adding benchmark. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` benchstat before.txt after.txt name old time/op new time/op delta PostingsForMatchers/Head/n="1"-16 480ns ± 4% 469ns ± 4% ~ (p=0.095 n=5+5) PostingsForMatchers/Head/n="1",j="foo"-16 720ns ± 1% 705ns ± 2% ~ (p=0.056 n=5+5) PostingsForMatchers/Head/j="foo",n="1"-16 712ns ± 3% 726ns ± 7% ~ (p=0.841 n=5+5) PostingsForMatchers/Head/n="1",j!="foo"-16 833ns ± 3% 827ns ± 1% ~ (p=0.548 n=5+5) PostingsForMatchers/Head/i=~"1[0-9]",j=~"foo|bar"-16 6.66ms ± 4% 0.00ms ± 1% -99.97% (p=0.008 n=5+5) PostingsForMatchers/Head/j=~"foo|bar"-16 897ns ± 2% 675ns ± 2% -24.80% (p=0.008 n=5+5) PostingsForMatchers/Head/i=~"(1|2|3|4|5|6|20|55)"-16 20.1ms ± 2% 0.0ms ± 2% -99.99% (p=0.008 n=5+5) PostingsForMatchers/Head/i=~".*"-16 74.4ms ± 3% 81.3ms ± 3% +9.29% (p=0.008 n=5+5) PostingsForMatchers/Head/i=~"1.*"-16 20.3ms ±27% 17.2ms ± 2% -15.15% (p=0.008 n=5+5) PostingsForMatchers/Head/i=~".*1"-16 6.22ms ±10% 5.60ms ± 1% -9.95% (p=0.008 n=5+5) PostingsForMatchers/Head/i=~".+"-16 146ms ± 4% 126ms ± 1% -13.63% (p=0.016 n=4+5) PostingsForMatchers/Head/i=~""-16 77.0ms ±23% 68.2ms ± 5% -11.47% (p=0.032 n=5+5) PostingsForMatchers/Head/i!=""-16 57.0ms ± 4% 56.9ms ± 6% ~ (p=1.000 n=5+5) PostingsForMatchers/Head/n="1",i=~".*",j="foo"-16 77.1ms ± 2% 79.2ms ± 4% ~ (p=0.095 n=5+5) PostingsForMatchers/Head/n="1",i=~".*",i!="2",j="foo"-16 77.2ms ± 3% 81.2ms ± 3% +5.17% (p=0.016 n=5+5) PostingsForMatchers/Head/n="1",i!=""-16 64.7ms ±34% 58.4ms ± 7% ~ (p=0.421 n=5+5) name old alloc/op new alloc/op delta PostingsForMatchers/Head/n="1"-16 80.0B ± 0% 80.0B ± 0% ~ (all equal) PostingsForMatchers/Head/n="1",j="foo"-16 208B ± 0% 208B ± 0% ~ (all equal) PostingsForMatchers/Head/j="foo",n="1"-16 208B ± 0% 208B ± 0% ~ (all equal) PostingsForMatchers/Head/n="1",j!="foo"-16 240B ± 0% 240B ± 0% ~ (all equal) PostingsForMatchers/Head/i=~"1[0-9]",j=~"foo|bar"-16 1.61MB ± 0% 0.00MB ± 0% ~ (p=0.079 n=4+5) PostingsForMatchers/Head/j=~"foo|bar"-16 360B ± 0% 232B ± 0% -35.56% (p=0.008 n=5+5) PostingsForMatchers/Head/i=~"(1|2|3|4|5|6|20|55)"-16 1.61MB ± 0% 0.00MB ± 0% -99.97% (p=0.008 n=5+5) PostingsForMatchers/Head/i=~".*"-16 1.61MB ± 0% 1.61MB ± 0% ~ (all equal) PostingsForMatchers/Head/i=~"1.*"-16 3.15MB ± 0% 3.15MB ± 0% -0.00% (p=0.008 n=5+5) PostingsForMatchers/Head/i=~".*1"-16 1.61MB ± 0% 1.61MB ± 0% -0.00% (p=0.008 n=5+5) PostingsForMatchers/Head/i=~".+"-16 17.3MB ± 0% 17.3MB ± 0% -0.00% (p=0.008 n=5+5) PostingsForMatchers/Head/i=~""-16 17.3MB ± 0% 17.3MB ± 0% ~ (p=0.238 n=5+5) PostingsForMatchers/Head/i!=""-16 17.3MB ± 0% 17.3MB ± 0% ~ (all equal) PostingsForMatchers/Head/n="1",i=~".*",j="foo"-16 1.61MB ± 0% 1.61MB ± 0% -0.00% (p=0.032 n=5+5) PostingsForMatchers/Head/n="1",i=~".*",i!="2",j="foo"-16 1.61MB ± 0% 1.61MB ± 0% ~ (p=0.651 n=5+4) PostingsForMatchers/Head/n="1",i!=""-16 17.3MB ± 0% 17.3MB ± 0% ~ (all equal) name old allocs/op new allocs/op delta PostingsForMatchers/Head/n="1"-16 4.00 ± 0% 4.00 ± 0% ~ (all equal) PostingsForMatchers/Head/n="1",j="foo"-16 9.00 ± 0% 9.00 ± 0% ~ (all equal) PostingsForMatchers/Head/j="foo",n="1"-16 9.00 ± 0% 9.00 ± 0% ~ (all equal) PostingsForMatchers/Head/n="1",j!="foo"-16 10.0 ± 0% 10.0 ± 0% ~ (all equal) PostingsForMatchers/Head/i=~"1[0-9]",j=~"foo|bar"-16 19.0 ± 0% 23.0 ± 0% +21.05% (p=0.008 n=5+5) PostingsForMatchers/Head/j=~"foo|bar"-16 13.0 ± 0% 7.0 ± 0% -46.15% (p=0.008 n=5+5) PostingsForMatchers/Head/i=~"(1|2|3|4|5|6|20|55)"-16 4.00 ± 0% 13.00 ± 0% +225.00% (p=0.008 n=5+5) PostingsForMatchers/Head/i=~".*"-16 7.00 ± 0% 7.00 ± 0% ~ (all equal) PostingsForMatchers/Head/i=~"1.*"-16 11.1k ± 0% 11.1k ± 0% -0.01% (p=0.008 n=5+5) PostingsForMatchers/Head/i=~".*1"-16 4.00 ± 0% 3.00 ± 0% -25.00% (p=0.008 n=5+5) PostingsForMatchers/Head/i=~".+"-16 100k ± 0% 100k ± 0% -0.00% (p=0.008 n=5+5) PostingsForMatchers/Head/i=~""-16 100k ± 0% 100k ± 0% ~ (all equal) PostingsForMatchers/Head/i!=""-16 100k ± 0% 100k ± 0% ~ (all equal) PostingsForMatchers/Head/n="1",i=~".*",j="foo"-16 12.0 ± 0% 12.0 ± 0% ~ (all equal) PostingsForMatchers/Head/n="1",i=~".*",i!="2",j="foo"-16 18.0 ± 0% 18.0 ± 0% ~ (all equal) PostingsForMatchers/Head/n="1",i!=""-16 100k ± 0% 100k ± 0% ~ (all equal) ``` Signed-off-by: Cyril Tovena --- tsdb/querier_bench_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tsdb/querier_bench_test.go b/tsdb/querier_bench_test.go index 242759b79..72e4b287f 100644 --- a/tsdb/querier_bench_test.go +++ b/tsdb/querier_bench_test.go @@ -108,7 +108,9 @@ func benchmarkPostingsForMatchers(b *testing.B, ir IndexReader) { iNot2 := labels.MustNewMatcher(labels.MatchNotEqual, "n", "2"+postingsBenchSuffix) iNot2Star := labels.MustNewMatcher(labels.MatchNotRegexp, "i", "^2.*$") iNotStar2Star := labels.MustNewMatcher(labels.MatchNotRegexp, "i", "^.*2.*$") - + jFooBar := labels.MustNewMatcher(labels.MatchRegexp, "j", "foo|bar") + iCharSet := labels.MustNewMatcher(labels.MatchRegexp, "i", "1[0-9]") + iAlternate := labels.MustNewMatcher(labels.MatchRegexp, "i", "(1|2|3|4|5|6|20|55)") cases := []struct { name string matchers []*labels.Matcher @@ -117,6 +119,9 @@ func benchmarkPostingsForMatchers(b *testing.B, ir IndexReader) { {`n="1",j="foo"`, []*labels.Matcher{n1, jFoo}}, {`j="foo",n="1"`, []*labels.Matcher{jFoo, n1}}, {`n="1",j!="foo"`, []*labels.Matcher{n1, jNotFoo}}, + {`i=~"1[0-9]",j=~"foo|bar"`, []*labels.Matcher{iCharSet, jFooBar}}, + {`j=~"foo|bar"`, []*labels.Matcher{jFooBar}}, + {`i=~"(1|2|3|4|5|6|20|55)"`, []*labels.Matcher{iAlternate}}, {`i=~".*"`, []*labels.Matcher{iStar}}, {`i=~"1.*"`, []*labels.Matcher{i1Star}}, {`i=~".*1"`, []*labels.Matcher{iStar1}},