model/labels: Add case-insensitive contains StringMatcher#1
Open
chencs wants to merge 2 commits intocase-insensitive-prefix-matchingfrom
Open
model/labels: Add case-insensitive contains StringMatcher#1chencs wants to merge 2 commits intocase-insensitive-prefix-matchingfrom
chencs wants to merge 2 commits intocase-insensitive-prefix-matchingfrom
Conversation
3a24433 to
f0bdb9b
Compare
e9a055f to
39c979e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change introduces a new
containsCaseInsensitiveStringMatcherwhich is similar to thecontainsStringMatcherbut matches case-insensitive substrings. For now, this is built off of prometheus#18540 for convenience.There are a couple benchmark cases that are notably slower:
"(?i:foo)": parsed as a concat with only one subexpression (the literal)"(?i:(foo|bar))": parsed as an alternate of two literals"(?i:(foo1|foo2|bar))": parsed to an alternate ofFOO[12]orbar"(?i:(AAAAAAAAAAAAAAAAAAAAAAAA|BBBBBBBBBBBBBBBBBBBBBBBB|cccccccccccccccccccccccC|ſſſſſſſſſſſſſſſſſſſſſſſſS|SSSSSSSSSSSSSSSSSSSSSSSSſ))": case-insensitivity causes the ſs and the Ss to be simplified away, but the S alternate is now concatenated with an empty non-capturing group on the end.So in 3/4 of these cases, I think we incur some extra overhead to check case-insensitive concats, and then end up not being able to use the new matcher anyways. I'm not sure what's happening with the second case (
(?i:(foo|bar))), but I'm also not sure these are too much to worry about given that they're already pretty fast.On the flip side, note the performance improvement for these examples, all of which were up in the microseconds:
(?i).*foo.*"(?i).*/label/.*|.*/labels.*|.*/series.*".*zQPbMkNO.*BenchmarkFastRegexMatcher results
Which issue(s) does the PR fix:
Does this PR introduce a user-facing change?