hhvm icon indicating copy to clipboard operation
hhvm copied to clipboard

Optimize PCRE for StaticStrings

Open paulbiss opened this issue 9 years ago • 3 comments

When we statically know the regex string passed to PCRE we can avoid a cache lookup on each call by burning the handle for the compiled regex into the TC.

paulbiss avatar May 07 '15 21:05 paulbiss

Is it the right path to add a service request to compile the static string regex and write the handle in TC for the first time? The pcre caches for these regex can't be freed.

wjywbs avatar Aug 05 '15 17:08 wjywbs

Well, it probably wouldn't be a service request, but the idea behind doing this with static strings is that they live forever anyway so it should be safe to burn the pcre handle in.

paulbiss avatar Aug 05 '15 20:08 paulbiss

HH\Lib\Regex\Pattern<T> literals are easy to spot in code.

re"/ab?cdc/"

In an ideal world, these would be compiled once and only once when this file is loaded (or even as a repo auth step, provided pcre handles can be serialized to disk). Hack can currently observe that re"" strings are just strings. A opaque value would be in order if changing this to a pcre handle expression.

lexidor avatar Oct 04 '23 23:10 lexidor