Let's say I have a Script that uses somewhere in the realm 100 regex's in
different functions. I want the first call to each of those functions to be
fast, so I move the constructor to the global object to pre-compile the
regex's. From the v8 docs, "In its default configuration, V8 compiles
regular expressions to native code upon the first execution", so I force
this pre-complication with something like `for(var rule of regexRules) {
"".match(regex) } `. Doing this, I notice a significant improvement in the
execution on first call back into the context to execute a function that
uses these regex's.
Is there a way to change this default configuration?
Joel
On Thursday, 24 October 2019 01:12:54 UTC-4, Jakob Gruber wrote:
>
>
>
> On Wed, Oct 23, 2019 at 5:12 PM Joel Scarfone <[email protected]
> <javascript:>> wrote:
>
>> Hi!
>>
>> I'm looking for details on how v8's regular expression optimizations work
>> under the covers, and if there might be something to improve the
>> performance of a given regular expressions first execution. From what it
>> looks like trying some things out, v8 does most of it's optimizations after
>> a call that uses the RegExp and not when the constructor is called (eg.
>> through `new RegExp()`).
>>
>
> I'm not aware of much documentation on this topic. A recent blog post (
> https://v8.dev/blog/regexp-tier-up) discusses the recent addition of
> tiering and describes performance work on the interpreter. But for details
> you'll have to dig through the source code.
>
> As you say, a regexp is compiled lazily at the first exec call. With
> tiering, we first compile to bytecode, then later recompile to native code.
> There are many intricacies involved, e.g. we cache compilation artifacts
> keyed on {pattern,flags}, and constructing a regexp instance is expected to
> be cheaper from a literal (/abc/) than when using the constructor (new
> RegExp("abc", "")).
>
>
>>
>> I am Wondering what some options are in this area to move around the cost
>> of compiling/running the regular expression.
>>
>
> I think I'd need more details on what you want to achieve to give a
> meaningful answer.
>
>
>>
>> Thanks in advance!
>>
>> Joel
>>
>> --
>> --
>> v8-users mailing list
>> [email protected] <javascript:>
>> http://groups.google.com/group/v8-users
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "v8-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/v8-users/05a13931-5a1d-4b21-8616-ffd3010dd03a%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/v8-users/05a13931-5a1d-4b21-8616-ffd3010dd03a%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
--
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/v8-users/ecb02276-8ccd-4f1f-b3bd-6aba79799985%40googlegroups.com.