Performance degrades the more wildcards that are contained in TSConfig include or exclude patterns #61103
Labels
Experimentation Needed
Someone needs to try this out to see what happens
Possible Improvement
The current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
π Search Terms
wildcard pattern include exclude tsconfig regex regexp regular expression glob performance slow node
π Version & Regression Information
β― Playground Link
No response
π» Code
Create a TS project with any empty TS file and the following TSConfig.
I've created a repo to more easily reproduce the behavior: https://github.com/MichaelMitchell-at/typescript_slow_wildcards_repro
π Actual behavior
tsc
takes several seconds to run on the project, even though there is no work to do and there are no files to compare theexclude
patterns against. In fact, runningtsc
withnode --jitless
is much faster than without.π Expected behavior
tsc
should complete quickly.Additional information about the issue
I've determined through profiling that the issue is that a giant
RegExp
combining all the patterns gets created which is very slow to evaluate.TypeScript/src/compiler/utilities.ts
Lines 9556 to 9566 in 739d729
From my testing, it's much faster to build a separate
RegExp
for each pattern and test them one by one for large number of patterns and for a small number of patterns there is no perceivable difference in speed. I've created a PR implementing this change which greatly improves the performance: #61104The text was updated successfully, but these errors were encountered: