eslint-plugin-react: [Bug]: Performance Regression
Is there an existing issue for this?
- I have searched the existing issues and my issue is unique
- My issue appears in the command-line and not only in the text editor
Description Overview
Upgrading from 7.33.1 to 7.33.2 causes a few rules to slow down significantly.
A few rules that appear to have gotten significantly slower are:
react/no-array-index-keyreact/no-unstable-nested-componentsreact/no-danger-with-children
Our overall linting time goes from ~60s to ~90s only changing this one package.
Using eslint timing settings you can see here that these two rules are occupying a good amount of time relative to before the upgrade.
7.33.2:
react/no-array-index-key | 21522.183 | 30.7%
react/no-unstable-nested-components | 7283.991 | 10.4%
react/no-danger-with-children | 2138.971 | 3.0%
7.33.1:
react/no-array-index-key | 718.943 | 1.8%
react/no-unstable-nested-components | 1208.373 | 3.0%
react/no-danger-with-children | Not slow enough to be in top 10
Pertinent package versions:
- eslint: 8.46.0 & 8.47.0
- eslint-plugin-react: 7.33.2
- @typescript-eslint/eslint-plugin: 6.2.1 & 6.4.1
- @typescript-eslint/parser: 6.2.1 & 6.4.1
- Node.js: 18.16.1
- Mac OS 13.5 - M1 MBP
Unfortunately I can’t share our codebase and I don’t have a reproduction. Hopefully the code diff between .1 and .2 are small enough to be able to track down this regression.
Expected Behavior
I expect the two versions to be similar in speed.
eslint-plugin-react version
7.33.2
eslint version
8.47.0
node version
18.16.1
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Reactions: 1
- Comments: 20 (12 by maintainers)
@ljharb the update in https://github.com/ljharb/safe-array-concat/issues/2 fixes the issue.
The change to
iterator.prototypeeither has very little effect but is probably a good change anyway.Using 7.33.2 and iterator.prototype 1.1.1 it helps a little. Down from ~89s to ~78-80s but still not back down to the ~55-59s range as 7.33.1.
Awesome 😃 I’ll close this then. Thanks for helping me debug!
Thanks, I’ll keep looking for more root causes.
Starting with
7.33.1const i = require("iterator.prototype");in Components.js exhibits no change in run time.const map = require('es-iterator-helpers/Iterator.prototype.map');in Components.js causes the slowdown.In each case, I only imported, the import was never referenced.
This has been filed on v8 as https://bugs.chromium.org/p/chromium/issues/detail?id=1477372.
Turns out this is caused by https://npmjs.com/iterator.prototype (which is my own package) - specifically, v8 seems to have a huge deopt when
Symbol.toStringTagis added onto%Iterator%.prototype.I’ll publish a fix to that package, and potentially to es-iterator-helpers as well, at which point I’ll close this.
This is the commit causing the slowdowns: https://github.com/jsx-eslint/eslint-plugin-react/commit/e1dd37f743649bf43726fe102a16bc71062d8687
The es iterator shims clearly aren’t as performant as the built-in array functions.