Skip to content

isCircularImport complexity impacting Vite performance #20084

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

Open
7 tasks done
hanford opened this issue May 21, 2025 · 0 comments · May be fixed by #20085
Open
7 tasks done

isCircularImport complexity impacting Vite performance #20084

hanford opened this issue May 21, 2025 · 0 comments · May be fixed by #20085

Comments

@hanford
Copy link

hanford commented May 21, 2025

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

Mac OX 15.1
Vite 6.3.2

Used Package Manager

pnpm

Validations

@hanford hanford changed the title isCircularImport complexity significantly impacting Vite performance isCircularImport complexity impacting Vite performance May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant