If you embed V8 yourself, the runtime flags --regexp-tier-up and --regexp-tier-up-ticks <https://cs.chromium.org/chromium/src/v8/src/flags/flag-definitions.h?l=1267&rcl=be638514c9876e80c222068059b205d64091c78d> control tier-up behavior.
Do you have an example of a particularly slow regexp pattern and subject string? On Thu, Oct 24, 2019 at 10:14 PM Joel Scarfone <joelrscarf...@gmail.com> wrote: > 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 <joelrs...@gmail.com> >> 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 >>> v8-u...@googlegroups.com >>> 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 v8-u...@googlegroups.com. >>> 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 > v8-users@googlegroups.com > 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 v8-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/v8-users/ecb02276-8ccd-4f1f-b3bd-6aba79799985%40googlegroups.com > <https://groups.google.com/d/msgid/v8-users/ecb02276-8ccd-4f1f-b3bd-6aba79799985%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- -- v8-users mailing list v8-users@googlegroups.com 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 v8-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/CAH3p7oMO5UNfKy%2BBdujiq5YHY4X95evgfu9x-z3M3ZYdVEoP8g%40mail.gmail.com.