isCircularImport
complexity impacting Vite performance
#20084
Labels
isCircularImport
complexity impacting Vite performance
#20084
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
I have a multimillion LOC codebase that includes >25,000 TypeScript modules.
Our development server currently takes around 3 minutes to start.
We discovered that disabling the isCircularImport check, (or simply returning false), cuts startup time by ~60 to 90 seconds. That check performs a DFS, which runs in O(V + E) time, so its cost becomes significant in a very large codebase with deep dependency chains.
ChatGPT suggested implementing a disjoint set, aka union find which could remove the need for recursion and reduce the check to
O(1)
complexity.But I think some small tweaks to the current DFS could get us pretty far, so I've started there!
refs: #20085
System Info
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: