-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Optimize StringMatcher for match-all patterns #77738
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
Conversation
Detect a StringMatcher of "*" and optimize it as a predicate of s -> true This is about 80% faster than using an automaton. This speed improvement is very minor on a single execution but can add up to milliseconds is used in a tight loop - e.g. testing against every indices in a large cluster
|
Pinging @elastic/es-security (Team:Security) |
ywangd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
It would be great if you could address two non-critical comments.
| if (nonExactMatch.contains("*")) { | ||
| return new StringMatcher(description, s -> true); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are trying to squeeze every bit for performance, I wonder whether it could help a tiny bit if we perform this check in the include(String pattern) method. It already checks for wildcard and should be easy to tweak it to flag for seeing a match-all pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my original implementation, but it's really not necessary.
We're not looking to squeeze that level of performance in the Builder, just in the StringMatcher itself.
Testing every pattern that is included to see whether it's equal to * and then setting a flag isn't really going to make a difference, and it means carrying more state in the builder.
...gin/core/src/test/java/org/elasticsearch/xpack/core/security/support/StringMatcherTests.java
Show resolved
Hide resolved
|
@elasticmachine update branch |
|
@elasticmachine run elasticsearch-ci/part-2 please Test failed due to: #78035 |
Detect a StringMatcher of "*" and optimize it as a predicate of
s -> true
This is about 80% faster than using an automaton.
This speed improvement is very minor on a single execution but can
add up to milliseconds is used in a tight loop - e.g. testing
against every indices in a large cluster
💚 Backport successful
|
* Optimize StringMatcher for match-all patterns (#77738) Detect a StringMatcher of "*" and optimize it as a predicate of s -> true This is about 80% faster than using an automaton. This speed improvement is very minor on a single execution but can add up to milliseconds is used in a tight loop - e.g. testing against every indices in a large cluster * Fix List references for backport Co-authored-by: Elastic Machine <[email protected]>
Detect a StringMatcher of "*" and optimize it as a predicate of
This is about 80% faster than using an automaton.
The speed improvement is very minor on a single execution but can
add up to milliseconds if used in a tight loop - e.g. testing
against every index in a large cluster