-
-
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
optimize no-cycle rule using strongly connected components #2998
Conversation
…ErrorMessagePath` for faster error messages
This comment was marked as resolved.
This comment was marked as resolved.
👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎ This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. |
Why is |
Good question. I think it's that this is the first new PR it's been run on since i installed it? |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2998 +/- ##
===========================================
+ Coverage 85.33% 95.91% +10.57%
===========================================
Files 78 79 +1
Lines 3300 3352 +52
Branches 1160 1171 +11
===========================================
+ Hits 2816 3215 +399
+ Misses 484 137 -347 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! I'll look at failing tests next
f64a123
to
a47b5b9
Compare
would love to see that optimization! |
Can't wait for this to be merged! |
@ljharb any news on this bro? |
a47b5b9
to
580c241
Compare
This comment was marked as resolved.
This comment was marked as resolved.
There's a pathology with SCC right now:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see two uncovered lines - can we add test cases to cover them?
Otherwise, this LGTM assuming all existing tests pass!
About the uncovered lines, I see them in codecov. The 1st is early return marked "no-self-import territory", so unrelated to my changes. The other is early return when files don't have the same SCC. |
After all these changes, I decided to measure performance impact. Without SCC (disableScc: true): 367 seconds (6:07 minutes) With SCC: 133 seconds (2:13 minutes) (I made sure it isn't using eslint cache) So we're talking about a 63% decrease in run time. |
Thanks, I have already seen this. What I did about it from when it was ported to the community fork:
In summary, this PR diverged significantly from the port discussed, in a way which should improve performance, invalidating prior benchmarks. A workaround has been built in to fall-back on in case of performance regression, without rolling-back. |
It was only after backporting the PR that I realized this was still an early experiment and a PoC. I'm considering using |
Lets make the
no-cycle
rule faster by not running many unnecessary BFSes.For each dependency graph (aka
ExportMap
) we can run Tarjan's SCC once (which is a derivative of DFS = O(n))That saves us a lot of work because we run a linear-complexity algorithm once, as opposed to for each linted file (which turned us O(n^2))
#2937