eslint-plugin-etc icon indicating copy to clipboard operation
eslint-plugin-etc copied to clipboard

deprecations rule extremely slow

Open eseliger opened this issue 5 years ago • 9 comments

Over two different projects in https://github.com/sourcegraph/sourcegraph etc/deprecation took by far the most of the time, it feels likely there might be potential for a speed-up.

cd ./shared && yarn -s run eslint

Rule                                    | Time (ms) | Relative
:---------------------------------------|----------:|--------:
etc/deprecation                         |  4957.662 |    31.7%
@typescript-eslint/no-misused-promises  |  2000.343 |    12.8%
@typescript-eslint/no-floating-promises |  1864.392 |    11.9%
import/extensions                       |   841.693 |     5.4%
react/prefer-stateless-function         |   757.892 |     4.8%
react/no-deprecated                     |   454.456 |     2.9%
react/void-dom-elements-no-children     |   365.701 |     2.3%
react/jsx-no-bind                       |   309.506 |     2.0%
import/no-self-import                   |   241.475 |     1.5%
react/no-string-refs                    |   224.624 |     1.4%

cd ./web && yarn -s run eslint

Rule                                    | Time (ms) | Relative
:---------------------------------------|----------:|--------:
etc/deprecation                         | 11145.833 |    38.0%
@typescript-eslint/no-misused-promises  |  3269.386 |    11.2%
import/extensions                       |  1803.290 |     6.2%
@typescript-eslint/no-floating-promises |  1746.615 |     6.0%
react/prefer-stateless-function         |  1361.724 |     4.6%
react/no-deprecated                     |   881.264 |     3.0%
react/jsx-no-bind                       |   757.441 |     2.6%
react/void-dom-elements-no-children     |   636.453 |     2.2%
@typescript-eslint/unbound-method       |   549.754 |     1.9%
react/no-string-refs                    |   491.509 |     1.7%

eseliger avatar Nov 14 '19 17:11 eseliger

Yeah, I can think of a few ways to make it more performant. Thanks for raising this.

cartant avatar Nov 14 '19 19:11 cartant

This should be a little quicker in 0.0.1-beta.19 - which has just been published.

cartant avatar Nov 14 '19 20:11 cartant

Confirmed!

From 31.7% && 38.0% down to 23.4% && 26.7%

Rule                                    | Time (ms) | Relative
:---------------------------------------|----------:|--------:
etc/deprecation                         |  2339.867 |    23.4%
@typescript-eslint/no-misused-promises  |  1112.053 |    11.1%
@typescript-eslint/no-floating-promises |  1095.841 |    11.0%
react/prefer-stateless-function         |   655.819 |     6.6%
import/extensions                       |   594.468 |     5.9%
react/no-deprecated                     |   371.769 |     3.7%
react/void-dom-elements-no-children     |   319.616 |     3.2%
react/jsx-no-bind                       |   239.463 |     2.4%
import/no-self-import                   |   222.715 |     2.2%
react/no-typos                          |   188.193 |     1.9%

Rule                                    | Time (ms) | Relative
:---------------------------------------|----------:|--------:
etc/deprecation                         |  5012.399 |    26.7%
@typescript-eslint/no-misused-promises  |  1573.824 |     8.4%
import/extensions                       |  1542.515 |     8.2%
react/prefer-stateless-function         |  1205.946 |     6.4%
@typescript-eslint/no-floating-promises |  1114.325 |     5.9%
react/no-deprecated                     |   739.743 |     3.9%
react/jsx-no-bind                       |   664.616 |     3.5%
react/void-dom-elements-no-children     |   558.648 |     3.0%
react/no-string-refs                    |   402.614 |     2.1%
react/no-typos                          |   393.122 |     2.1%

eseliger avatar Nov 14 '19 20:11 eseliger

Hmm. Still pretty shitty. Hopefully, this can be made faster still using ESLint's variables thingy, but that's a little more complicated. I'll have a look a little later.

cartant avatar Nov 14 '19 20:11 cartant

I've had some time to play around with this a bit. Try 0.0.1-beta.20. It should be quicker.

cartant avatar Nov 15 '19 01:11 cartant

Looking good:

only 9.7% && 6.7%!

Rule                                    | Time (ms) | Relative
:---------------------------------------|----------:|--------:
@typescript-eslint/no-misused-promises  |  3327.775 |    26.8%
@typescript-eslint/no-floating-promises |  1862.377 |    15.0%
etc/deprecation                         |  1202.930 |     9.7%
react/prefer-stateless-function         |   694.252 |     5.6%
import/extensions                       |   613.231 |     4.9%
@typescript-eslint/unbound-method       |   489.783 |     4.0%
react/no-deprecated                     |   374.281 |     3.0%
react/void-dom-elements-no-children     |   270.650 |     2.2%
react/jsx-no-bind                       |   231.381 |     1.9%
import/no-self-import                   |   193.985 |     1.6%

Rule                                    | Time (ms) | Relative
:---------------------------------------|----------:|--------:
@typescript-eslint/no-misused-promises  |  7968.406 |    28.2%
@typescript-eslint/unbound-method       |  2493.286 |     8.8%
@typescript-eslint/no-floating-promises |  2093.141 |     7.4%
import/extensions                       |  2050.360 |     7.3%
etc/deprecation                         |  1888.401 |     6.7%
react/prefer-stateless-function         |  1402.873 |     5.0%
react/no-deprecated                     |   919.743 |     3.3%
react/jsx-no-bind                       |   780.526 |     2.8%
react/void-dom-elements-no-children     |   663.284 |     2.3%
react/no-string-refs                    |   526.400 |     1.9%

eseliger avatar Nov 15 '19 02:11 eseliger

Nice. Now that some other rule is at the top of the list, I'm going to deem this no-longer-a-bug. There are some other things I might play with, at some later stage, so I'll leave this open, but labelled as an enhancement.

cartant avatar Nov 15 '19 02:11 cartant

yes, agree!

eseliger avatar Nov 15 '19 02:11 eseliger

FWIW, etc/no-deprecated and etc/no-internal are currently at the top slowest rules in a project where ESLint is noticeably slow. Not sure if related or if I should open a new issue for performance.

Rule                                      | Time (ms) | Relative
:-----------------------------------------|----------:|--------:
etc/no-deprecated                         |  2515.552 |    20.5%
import/no-duplicates                      |  1993.658 |    16.3%
etc/no-internal                           |  1440.442 |    11.7%
import/export                             |  1396.381 |    11.4%
total-functions/no-unsafe-enum-assignment |   554.410 |     4.5%
@typescript-eslint/no-floating-promises   |   395.713 |     3.2%
@typescript-eslint/no-unsafe-assignment   |   215.030 |     1.8%
@typescript-eslint/no-redeclare           |   195.273 |     1.6%
camelcase                                 |   188.976 |     1.5%
unicorn/prevent-abbreviations             |   175.437 |     1.4%

(on certain uncached runs, etc/no-deprecated can get up to 10s)

And this was on a recent --fix run that affected lots of files:

Rule                                      |  Time (ms) | Relative
:-----------------------------------------|-----------:|--------:
etc/no-deprecated                         | 646137.513 |    60.8%
etc/no-internal                           | 390563.923 |    36.8%
@nrwl/nx/enforce-module-boundaries        |   6730.989 |     0.6%
import/no-duplicates                      |   5080.625 |     0.5%
@typescript-eslint/no-floating-promises   |   1931.164 |     0.2%
import/export                             |   1879.495 |     0.2%
total-functions/no-unsafe-enum-assignment |   1532.563 |     0.1%
@typescript-eslint/no-unsafe-assignment   |    596.325 |     0.1%
@typescript-eslint/no-redeclare           |    412.016 |     0.0%
rxjs/no-exposed-subjects                  |    402.550 |     0.0%