Skip to content

ESLint multi-thread linting creates new chanllenge to eslint-plugin-import and eslint-plugin-import-x #418

@SukkaW

Description

@SukkaW

cc @nzakas @mdjermanovic @ljharb @JounQin

Context: eslint/eslint#19794

TL; DR With multi-thread ESLint workers, the existing cache mechanism for one of the biggest performance overheads of both eslint-plugin-import and eslint-plugin-import-x will now be isolated, which will result in those slow jobs being done repeatedly in different workers.


One of the biggest performance overheads of both eslint-plugin-import and eslint-plugin-import-x is that they will look for the ImportDeclaration (and ImportExpression), using user-specified eslint-import-resolver-* packages to resolve the real location of the importee, read and parse (grabbing a parser from the rule context, or use the user-specified one) it, then walk through that AST to get its ImportDeclaration, ImportExpression, Export*Specifier, etc.. These all happen in a utility class called ExportMap (eslint-plugin-import's implementation, eslint-plugin-import-x's forked implementation). The results (which are ExportMap instance objects) are cached by a Map object at the module scope.

In the worst-case scenario, let's say a.js and b.js, picked up by different ESLint workers, both import the same node_modules/huge-barrel-library/entrypoint.js, the node_modules/huge-barrel-library/entrypoint.js will be parsed and processed twice in different workers (previously, with only one thread, it would be cached and reused).

We would all agree that ESLint should continue to be multi-threaded; however, this is not something we should overlook.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions