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
base: main
Are you sure you want to change the base?
Conversation
…ErrorMessagePath` for faster error messages
This fails some tests. I need help with dealing with these edge-cases. |
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
|
👍 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 95.66% 85.41% -10.26%
===========================================
Files 78 79 +1
Lines 3275 3325 +50
Branches 1150 1159 +9
===========================================
- Hits 3133 2840 -293
- Misses 142 485 +343 ☔ View full report in Codecov by Sentry. |
@@ -62,6 +68,8 @@ module.exports = { | |||
context, | |||
); | |||
|
|||
const scc = StronglyConnectedComponentsBuilder.get(myPath, context); |
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.
Can this row and line 114-117 move after line 119?
when skipErrorMessagePath is false, there is no need to do scc check.
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.
the scc check is how we know if there's cycles or not.
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
|
||
export default class StronglyConnectedComponentsBuilder { | ||
static clearCache() { | ||
cache = new Map(); |
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.
cache = new Map(); | |
cache.clear(); |
this might be less GC intensive? i don't feel strongly tho
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.
Maybe. clearCache
is currently used only by tests, so I think it doesn't matter.
f64a123
to
a47b5b9
Compare
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