From 0d46e24af5282c8d03e46e630f61db87a4975d42 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 24 Aug 2022 17:15:21 +0300 Subject: [PATCH] lib/storage: increase the maximum possible `or` values extracted from regexp from 20 to 100 This should improve time series search speed for regexp filters with big number of `or` values. --- lib/storage/tag_filters.go | 2 +- lib/storage/tag_filters_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/storage/tag_filters.go b/lib/storage/tag_filters.go index e4f40165b8..cf064b3b4d 100644 --- a/lib/storage/tag_filters.go +++ b/lib/storage/tag_filters.go @@ -872,7 +872,7 @@ func getOrValuesExt(sre *syntax.Regexp) []string { } } -const maxOrValues = 20 +const maxOrValues = 100 var tagCharsRegexpEscaper = strings.NewReplacer( "\\x00", "\\x000", // escapeChar diff --git a/lib/storage/tag_filters_test.go b/lib/storage/tag_filters_test.go index 803df85702..3d692c8713 100644 --- a/lib/storage/tag_filters_test.go +++ b/lib/storage/tag_filters_test.go @@ -1166,14 +1166,14 @@ func TestGetOrValues(t *testing.T) { f("foo|bar", []string{"bar", "foo"}) f("(foo|bar)", []string{"bar", "foo"}) f("(foo|bar)baz", []string{"barbaz", "foobaz"}) - f("[a-z]", nil) + f("[a-z][a-z]", nil) f("[a-d]", []string{"a", "b", "c", "d"}) f("x[a-d]we", []string{"xawe", "xbwe", "xcwe", "xdwe"}) f("foo(bar|baz)", []string{"foobar", "foobaz"}) f("foo(ba[rz]|(xx|o))", []string{"foobar", "foobaz", "fooo", "fooxx"}) f("foo(?:bar|baz)x(qwe|rt)", []string{"foobarxqwe", "foobarxrt", "foobazxqwe", "foobazxrt"}) f("foo(bar||baz)", []string{"foo", "foobar", "foobaz"}) - f("(a|b|c)(d|e|f)(g|h|k)", nil) + f("(a|b|c)(d|e|f|0|1|2)(g|h|k|x|y|z)", nil) f("(?i)foo", nil) f("(?i)(foo|bar)", nil) f("^foo|bar$", []string{"bar", "foo"})