regexp: fast path for prefix/suffix literals matching on anchored regexps #39869
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
Milestone
To my understanding, currently there's no fast path for anchored regular expressions starting/ending with a literal, like
^something.*$
or^.*something$
. I'm wondering if you have considered adding a specific optimisation for this use case.Use case
I'm raising this issue, because in Prometheus we do a large use of anchored regexps (for labels matching) and having prefix/suffix literals in the regex looks to be quite a common use case.
In past few days I've worked on a small optimization in Prometheus (PR) to detect safe cases when we can circuit break the regex matching with a
strings.HasPrefix()
andstrings.HasSuffix()
, and it showed to bring significant benefits for our specific use case.The text was updated successfully, but these errors were encountered: