Uh oh!
There was an error while loading. Please reload this page.
RegExp syntax checking performance - #58339
Conversation
Ron Buckton (rbuckton)
commented
Apr 27, 2024
TypeScript Bot (@typescript-bot) perf test |
TypeScript Bot (typescript-bot)
commented
Apr 27, 2024
Ron Buckton (@rbuckton), the perf run you requested failed. You can check the log here. |
TypeScript Bot (typescript-bot)
commented
Apr 27, 2024
Ron Buckton (@rbuckton) Here they are:tscComparison Report - baseline..pr
System info unknown Hosts
Scenarios
tsserverComparison Report - baseline..pr
System info unknown Hosts
Scenarios
startupComparison Report - baseline..pr
System info unknown Hosts
Scenarios
Developer Information: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Ron Buckton (rbuckton)
commented
Apr 27, 2024
TypeScript Bot (@typescript-bot) run dt |
TypeScript Bot (typescript-bot)
commented
Apr 27, 2024
Ron Buckton (@rbuckton) Here are the results of running the user tests comparing Everything looks good! |
TypeScript Bot (typescript-bot)
commented
Apr 27, 2024
Hey Ron Buckton (@rbuckton), the results of running the DT tests are ready. Everything looks the same! |
TypeScript Bot (typescript-bot)
commented
Apr 27, 2024
Ron Buckton (@rbuckton) Here are the results of running the user tests comparing Everything looks good! |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
TypeScript Bot (typescript-bot)
commented
Apr 27, 2024
Ron Buckton (@rbuckton) Here are the results of running the top 400 repos comparing Everything looks good! |
Jake Bailey (jakebailey)
commented
Apr 27, 2024
The perf seels really good. Is that all from avoiding out of bounds? |
Ron Buckton (rbuckton)
commented
Apr 27, 2024
Yeah, if |
Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Might be worth mentioning in the PR description that you also |
Also other specific optimizations - like hoisting out helper functions and lazily initializing state for captures. |
Jake Bailey (jakebailey)
left a comment
There was a problem hiding this comment.
Oops, forgot my green check.
Ron Buckton (rbuckton)
commented
Apr 29, 2024
I've been working on expanding this throughout scanner.ts and writing up a lint rule to ensure enforcement, so I'll probably need another review shortly. |
Ron Buckton (rbuckton)
commented
Apr 29, 2024
Since I have some additional testing to do, I think I'll put those changes up as a separate PR following this one. |
This makes a few changes to the RegExp syntax checking algorithm for possible performance improvements. This also fixes a small typo in one of the RegExp diagnostic messages.
One of the changes is to ensure we perform proper bounds checks when
posmight advance pastend. To accomplish this, I added thecharCodeCheckedandcharCodeUncheckedfunctions.charCodeCheckedperforms boundary tests which both improves reliability and avoids potential deoptimizations due to reading past the end of a string.charCodeUncheckedis simply a wrapper fortext.charCodeAtand exists primarily to make it easier to readily identify unchecked vs checked reads fromtext.charCodeUncheckedshould only be used when we've already performed a bounds check before reading a character, such as in awhile (pos < end)loop. I've also done the same for code points withcodePointCheckedandcodePointUnchecked. Each of these functions is small, so ideally will be inlined by an optimizing compiler like the one used by V8.I've primarily focused on optimizing
scanRegularExpressionWorkerfor now. If this seems effective, I will investigate adoptingcharCodeCheckedin more places in the scanner in a later PR.I've also made a few other small perf improvements:
scanRegularExpressionWorkerhas been moved out ofreScanSlashTokenand updated to use the existingtextandendvalues from the outer scope.varto avoid TDZ check overhead.