microsoft / microsoft/TypeScript
Performance degrades the more wildcards that are contained in TSConfig include or exclude patterns
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
🔎 Search Terms
wildcard pattern include exclude tsconfig regex regexp regular expression glob performance slow node
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
No response
💻 Code
Create a TS project with any empty TS file and the following TSConfig.
{
"compilerOptions": {
"noCheck": true,
"noEmit": true,
"noResolve": true,
},
"exclude": [
"alpha/beta/gamma/delta/epsilon/zeta/eta/theta/iota/kappa/lambda/**/*.ts",
"alpha/beta/gamma/delta/epsilon/zeta/eta/theta/iota/kappa/lambda/**/*.ts",
"alpha/beta/gamma/delta/epsilon/zeta/eta/theta/iota/kappa/lambda/**/*.ts",
...repeat a couple hundred or more times
]
}
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 the exclude patterns against. In fact, running tsc with node --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.
https://github.com/microsoft/TypeScript/blob/739d729ecce60771c23723aad932ab35a34df82d/src/compiler/utilities.ts#L9556-L9566
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: https://github.com/microsoft/TypeScript/pull/61104
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia in src/compiler/utilities.ts alle righe 9556-9566, quindi esegui il progetto collegato typescript_slow_wildcards_repro con i pattern exclude ripetuti di tsconfig. Confronta il tempo di esecuzione del compilatore per insiemi di pattern grandi e piccoli e considera il PR 61104 esistente quando verifichi il miglioramento delle prestazioni previsto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers, performance
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 25/100