Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize .? in the FastRegexMatcher #537

Merged
merged 3 commits into from
Oct 2, 2023

Conversation

pracucci
Copy link
Collaborator

@pracucci pracucci commented Sep 29, 2023

This PR builds on top of #536 and optimize for the ".?" case. I don't feel strong about this optimization, but we believe it's not too risky (from a correctness perspective), may be another bullet in our optimization arsenal.

Performance change for the queries containing ".?":

goos: darwin
goarch: amd64
pkg: github.com/prometheus/prometheus/model/labels
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
                              │ before-quest.txt │           after-quest.txt           │
                              │      sec/op      │   sec/op     vs base                │
FastRegexMatcher/fo.?-12             191.5n ± 1%   141.3n ± 1%  -26.21% (p=0.000 n=10)
FastRegexMatcher/foo.?-12            193.9n ± 3%   140.8n ± 2%  -27.40% (p=0.000 n=10)
FastRegexMatcher/f.?o-12             136.5n ± 2%   138.2n ± 2%   +1.28% (p=0.017 n=10)
FastRegexMatcher/.*foo.?-12         1843.0n ± 2%   298.2n ± 7%  -83.82% (p=0.000 n=10)
FastRegexMatcher/.?foo.+-12          850.9n ± 2%   289.7n ± 5%  -65.96% (p=0.000 n=10)
FastRegexMatcher/foo.?|bar-12        961.7n ± 2%   224.7n ± 2%  -76.63% (p=0.000 n=10)
geomean

Base automatically changed from more-regexp-optimizations to main September 29, 2023 13:32
Signed-off-by: Marco Pracucci <[email protected]>
Signed-off-by: Marco Pracucci <[email protected]>
@pracucci pracucci force-pushed the more-regexp-optimizations-with-dot-quest-support branch from 5bf3393 to 5d7eb6d Compare September 29, 2023 13:33
@pracucci pracucci marked this pull request as ready for review September 29, 2023 13:33
@pracucci pracucci merged commit c7c149e into main Oct 2, 2023
5 checks passed
@pracucci pracucci deleted the more-regexp-optimizations-with-dot-quest-support branch October 2, 2023 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants