-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Execution times with double star syntax and dashes #121
Comments
This is reproducible in Node.js and Deno (both use V8), but not in Bun (uses WebKit). The actual regex which takes exponential time in this case is Running that RegEx in Firefox, SpiderMonkey notably gives up with an "InternalError: too much recursion". Epiphany (based on WebKit) behaves just like Bun, so WebKit is quite clearly is not affected. Even much longer test strings do not lead to an observable rise in execution time with WebKit. Using V8's experimental linear time modifier (
Using this Node.js debugging script: const v8 = require('node:v8');
v8.setFlagsFromString('--enable-experimental-regexp-engine');
v8.setFlagsFromString('--default-to-experimental-regexp-engine');
v8.setFlagsFromString('--enable-experimental-regexp-engine-on-excessive-backtracks');
v8.setFlagsFromString('--trace-experimental-regexp-engine');
console.time('Time')
// biome-ignore lint/complexity/useRegexLiterals: bypass Node.js Regex-flags validator
const re = new RegExp('^((?:.*)*).google.com$', 'u'); // 'lu'
re.exec('subdomain.domain.example.com');
console.timeEnd('Time') I get the output (irrelevant lines omitted)
, so even V8's experimental RegEx engine doesn't help, unless one also removes the
In that case, execution time is on par with WebKit. |
Platform: macOS
Architecture:
arm64
Node:
v18.18.0
The double-star syntax is unnecessary, since it also works with a single star, but I still want to report this to hopefully get it fixed.
If you execute the code below:
The text was updated successfully, but these errors were encountered: