Skip to content
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

Dramatic performance regression in import/no-cycle #1943

Closed
Blasz opened this issue Nov 12, 2020 · 2 comments · Fixed by #1944
Closed

Dramatic performance regression in import/no-cycle #1943

Blasz opened this issue Nov 12, 2020 · 2 comments · Fixed by #1944

Comments

@Blasz
Copy link
Contributor

Blasz commented Nov 12, 2020

We experienced a large performance regression in our linting after upgrading to 2.22.0 from 2.20.1.

Running linting on a single file.

Before upgrade:

Rule                                | Time (ms) | Relative
:-----------------------------------|----------:|--------:
import/no-cycle                     |  3382.383 |    91.2%
...

After upgrade:

Rule                                     | Time (ms) | Relative
:----------------------------------------|----------:|--------:
import/no-cycle                          | 73731.106 |    99.3%
...

I narrowed the problem down to this PR #1689. The isEsModuleInterop function tries to load a tsconfig file from disk and doesn't cache the result. The function is called for each file that is parsed by the plugin and is called multiple times in the same file. This is particularly bad when running import/no-cycle over a file with a large dependency graph as lots of files end up being parsed.

The fix would be to only lookup tsconfig once and cache the result.

@Blasz
Copy link
Contributor Author

Blasz commented Nov 12, 2020 via email

ljharb pushed a commit to Blasz/eslint-plugin-import that referenced this issue Jan 21, 2021
ljharb pushed a commit to Blasz/eslint-plugin-import that referenced this issue Jan 21, 2021
ljharb pushed a commit to Blasz/eslint-plugin-import that referenced this issue Jan 21, 2021
@ljharb ljharb closed this as completed in 2ae68c1 Jan 22, 2021
@soryy708
Copy link
Contributor

Here's an idea for how to make import/no-cycle faster:
#2937

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants