-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
improve no-cycle rule performance by leveraging strongly connected components #2937
Comments
This was referenced Dec 11, 2023
I have no attachment to any particular algorithm; as long as it passes tests and is robust and correct, whatever will perform best is great. I'd be happy to review a PR. |
Sounds interesting, let's try it! |
@benmosher I think you were the original contributor of the |
The SCC optimization has been released, try v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I see that the
no-cycle
usesExportMap
to get a cached dependency graph, and then run BFS to find cycles.... Are we running BFS, on the entire dependency graph, for every file we lint?
I think we can improve performance in this way:
An SCC means that every node that belongs to it has a path to all other nodes that belong to it. Therefore if two nodes belong to the same SCC, they have a path to each other, therefore there is a directed cycle = circular dependency between them.
(The difference between an SCC and a directed cycle is that an SCC may contain at least one directed cycle)
By the way, I'm not sure that BFS is the right algorithm for cycle detection, consider DFS instead.
Stackoverflow: Why DFS and not BFS for finding cycle in graphs
The text was updated successfully, but these errors were encountered: