Cyril Tovena
5c5b38712f
Add more comments.
...
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
2021-10-11 10:10:51 +02:00
Cyril Tovena
9c33f392e6
Better benchmarks values.
...
```
❯ benchcmp before.txt after.txt
benchmark old ns/op new ns/op delta
BenchmarkNewFastRegexMatcher/(foo|bar)-16 2487 2520 +1.33%
BenchmarkNewFastRegexMatcher/foo.*-16 8856 4531 -48.84%
BenchmarkNewFastRegexMatcher/.*foo-16 25195 6389 -74.64%
BenchmarkNewFastRegexMatcher/^.*foo$-16 25626 6253 -75.60%
BenchmarkNewFastRegexMatcher/^.+foo$-16 25429 6248 -75.43%
BenchmarkNewFastRegexMatcher/.*-16 429707 8439 -98.04%
BenchmarkNewFastRegexMatcher/.+-16 380165 8503 -97.76%
BenchmarkNewFastRegexMatcher/foo.+-16 8180 4586 -43.94%
BenchmarkNewFastRegexMatcher/.+foo-16 25214 6255 -75.19%
BenchmarkNewFastRegexMatcher/foo_.+-16 8116 4334 -46.60%
BenchmarkNewFastRegexMatcher/foo_.*-16 8354 4287 -48.68%
BenchmarkNewFastRegexMatcher/.*foo.*-16 206076 19227 -90.67%
BenchmarkNewFastRegexMatcher/.+foo.+-16 208434 18793 -90.98%
BenchmarkNewFastRegexMatcher/#00-16 33045 3936 -88.09%
BenchmarkNewFastRegexMatcher/(?s:.*)-16 403806 4208 -98.96%
BenchmarkNewFastRegexMatcher/(?s:.+)-16 418177 4150 -99.01%
BenchmarkNewFastRegexMatcher/(?s:^.*foo$)-16 24452 5661 -76.85%
BenchmarkNewFastRegexMatcher/^(?i:foo|oo)|(bar)$-16 48087 23183 -51.79%
BenchmarkNewFastRegexMatcher/((.*)(bar|b|buzz)(.+)|foo)$-16 645430 47193 -92.69%
BenchmarkNewFastRegexMatcher/^$-16 37244 3912 -89.50%
BenchmarkNewFastRegexMatcher/(prometheus|api_prom)_api_v1_.+-16 17205 10006 -41.84%
BenchmarkNewFastRegexMatcher/10\.0\.(1|2)\.+-16 6776 7011 +3.47%
BenchmarkNewFastRegexMatcher/10\.0\.(1|2).+-16 14792 4674 -68.40%
BenchmarkNewFastRegexMatcher/((fo(bar))|.+foo)-16 497007 17410 -96.50%
```
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
2021-10-11 09:45:02 +02:00
Cyril Tovena
715274ec9d
Reintroduce tests.
...
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
2021-10-08 10:10:18 +02:00
Cyril Tovena
7dab60e56d
More optimization.
...
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
2021-10-07 17:15:20 +02:00
Cyril Tovena
852b553c00
Fixes the code and improve tests.
...
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
2021-10-07 15:10:26 +02:00
Cyril Tovena
3c13a5e9bd
Improve tests and bench.
...
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
2021-10-07 14:25:31 +02:00
Cyril Tovena
54b3371060
Merge branch 'improvesetmatches' into regexpopti
2021-10-07 14:05:14 +02:00
Cyril Tovena
74c5667b63
implement optimization.
...
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
2021-10-07 13:56:31 +02:00
Cyril Tovena
f7f80a3abf
Update pkg/labels/regexp_test.go
...
Co-authored-by: Peter Štibraný <peter.stibrany@grafana.com>
2021-10-06 16:44:26 +02:00
Cyril Tovena
a1f6c747ed
Merge branch 'improvesetmatches' into regexpopti
2021-10-06 16:36:29 +02:00
Cyril Tovena
f32ec95722
Add more tests and support begin/end text.
...
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
2021-10-06 16:22:48 +02:00
Cyril Tovena
e9f0f0ebed
Improves test and benchmark
...
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
2021-10-06 15:24:57 +02:00
Cyril Tovena
d217825af8
guards against too many matches.
...
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
2021-10-05 16:46:24 +02:00
Cyril Tovena
639cd00721
Uses the variadic function.
...
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
2021-10-05 15:59:40 +02:00
Cyril Tovena
623c3ebeec
Remove redundant code and support charclass without base.
...
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
2021-10-05 15:16:21 +02:00
Cyril Tovena
c751cfbfce
Improve findSetMatches
to support concatenation.
...
This improves how we find `SetMatches` for regexp. Notably it allows to support concatenation
such as `api_(v1|prom)_push` for which the resulting set matches are `api_v1_push` and `api_prom_push`.
I had to support characters classes too since the syntax may try to optimize alternates with them.
In the end the code is also more robust than the previous implementation relying on the stringyfied version of the regexp.
This could be upstreamed later.
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
2021-10-05 13:43:41 +02:00
Julien Pivotto
6c56a1faaa
Testify: move to require ( #8122 )
...
* Testify: move to require
Moving testify to require to fail tests early in case of errors.
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
* More moves
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2020-10-29 09:43:23 +00:00
Julien Pivotto
4e5b1722b3
Move away from testutil, refactor imports ( #8087 )
...
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2020-10-22 11:00:08 +02:00
Brian Brazil
cf273f21bb
Add a testcase for #8040 ( #8042 )
...
This was already fixed by #8013 , but add a test case anyway
in case the regexp engine changes in future.
Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
2020-10-12 12:17:29 +01:00
Brian Brazil
924ce978b7
Don't do literal regex matching optimisation when case insensitive. ( #8013 )
...
Fixes #7994
Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
2020-10-06 13:16:26 +01:00
Marco Pracucci
2f6bf7de4c
Optimise labels regex matchers containing a literal within the pattern ( #7503 )
...
* Added labels matchers regex fast path for literals within the regex
Signed-off-by: Marco Pracucci <marco@pracucci.com>
2020-07-07 09:38:04 +01:00
Marco Pracucci
cef4dd6fff
Optimized label regex matcher with literal prefix and/or suffix ( #7453 )
...
* Optimized label regex matcher with literal prefix and/or suffix
Signed-off-by: Marco Pracucci <marco@pracucci.com>
* Added license
Signed-off-by: Marco Pracucci <marco@pracucci.com>
* Added more tests cases with newlines
Signed-off-by: Marco Pracucci <marco@pracucci.com>
* Restored deleted test
Signed-off-by: Marco Pracucci <marco@pracucci.com>
2020-06-26 15:19:09 +05:30