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
[new config system] Performance issue #16302
Comments
Timing with old-style config:
Timing with new-style config:
However, it's not 5x difference. |
@zloirock thanks for the issue! I can reproduce a significant difference in performance on my computer. With One thing I noticed is that Differences in rule timings are surprising as that part of the process is basically the same as with the old config. This will require further analysis. |
This takes more than 2 minutes when linting Lines 1604 to 1609 in 8cc0bbe
It's merging ~800 custom globals over ~70 builtin globals for each of ~7000 files. To double-check, I ran this and it's indeed very slow: const globals = require("globals");
console.log(Object.keys(globals.builtin).length); // 66
console.log(Object.keys(globals.browser).length); // 723
const t = process.hrtime();
for (let i = 0; i < 7000; i++) {
const obj = {
...globals.builtin,
...globals.browser
};
}
console.log(`${process.hrtime(t)[0]}s`); // 152s This seems to be a problem in v8: https://bugs.chromium.org/p/v8/issues/detail?id=11536 When we replace object spread with |
There is a caching mechanism built into ConfigArray#getConfig. It's cached based on the filename. I don't completely understand the eslintrc caching mechanism, but it looks like it's caching the indices of the elements in the array that match so that it can avoid doing a lot of merges if multiple files match the same elements. That's certainly something that ConfigArray can be made to do. |
Latest version of the package includes more aggressive caching. Refs #16302
With fixes from above, it takes about 36 seconds - almost the same as with old-style (32 seconds) -) |
With the performance fixes, I'm getting 89 seconds with |
🎉 Awesome! |
Latest version of the package includes more aggressive caching. Refs #16302
Environment
Node version: 18.8.0
npm version: 8.19.1 (local and 8.18.0 global)
Local ESLint version: 8.23.1
Global ESLint version: -
Operating System: macOS 12.6
CPU: M1
What parser are you using?
Default (Espree) +
jsonc-eslint-parser
What did you do?
I'm trying to migrate to the flat config.
Old config: https://github.com/zloirock/core-js/blob/master/.eslintrc.js
New config: https://github.com/zloirock/core-js/blob/eslint-flat/eslint.config.js
Just run
npm i && npm run lint
.With the old-style config, lining (directly
eslint
) takes 32 seconds.With the new-style config, lining (directly
eslint
) takes 2 minutes and 34 seconds.What did you expect to happen?
The same (or better) performance.
What actually happened?
5x performance degradation.
Participation
The text was updated successfully, but these errors were encountered: