question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@nrwl/linter: builder execution is almost 2 times slower than raw eslint

See original GitHub issue

Current Behavior

nrwl linter builder is almost 2 times (sometimes even more) slower in comparison with raw eslint execution

demonstration on project that contains 2 files only:

nrwl linter image

eslint image

Expected Behavior

Execute linting with same speed like raw eslint

Steps to Reproduce

Failure Logs

Environment

  @nrwl/angular : Not Found
  @nrwl/cli : 9.5.1
  @nrwl/cypress : 9.5.1
  @nrwl/eslint-plugin-nx : 9.5.1
  @nrwl/express : Not Found
  @nrwl/jest : 9.5.1
  @nrwl/linter : 9.5.1
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : 9.5.1
  @nrwl/react : 9.5.1
  @nrwl/schematics : Not Found
  @nrwl/tao : 9.5.1
  @nrwl/web : 9.5.1
  @nrwl/workspace : 9.5.1
  typescript : 3.8.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
vsavkincommented, Jul 22, 2020

I ran into @nrwl/nx/enforce-module-boundaries being slow the other day. I think there are two parts that contribute to it:

  • Circular dep check is written very naively. We should probably use dynamic programming to avoid walking the same paths over and over again.
  • TypeScript resolution can be slow. We should experiment with bypassing it for some imports.
2reactions
Hotellcommented, Jul 13, 2020

Are you able to share the repo?

Unfortunately no…


measurements

I did additional measurements this morning on different library. those time deltas are much smaller, so maybe it was my system overloaded or something (up time was 42 days previously - I rebooted this morning)

Files linted: 7

3 types of execution:

1. raw eslint

TIMING=1 yarn eslint --ext .ts,.tsx,.js libs/analytics

measurement:

⏱ 28.64s

Rule                                          | Time (ms) | Relative
:---------------------------------------------|----------:|--------:
@typescript-eslint/no-misused-promises        |   172.145 |    27.0%
@nrwl/nx/enforce-module-boundaries            |   154.725 |    24.2%
etc/deprecation                               |    84.871 |    13.3%
jsdoc/require-hyphen-before-param-description |    37.029 |     5.8%
jsdoc/check-alignment                         |    28.955 |     4.5%
import/no-duplicates                          |    20.665 |     3.2%
tsdoc/syntax                                  |    17.874 |     2.8%
jsdoc/check-indentation                       |    16.725 |     2.6%
@typescript-eslint/no-unused-vars             |     6.990 |     1.1%
react/prefer-es6-class                        |     6.845 |     1.1%
✨  Done in 28.64s.

2. run-command builder

TIMING=1 yarn nx run analytics:lint-manual --skip-nx-cache

architect:

"lint-manual": {
          "builder": "@nrwl/workspace:run-commands",
          "options": {
            "command": "eslint --ext=.ts,.tsx,.js libs/analytics"
          }
        }

measurement:

⏱ 41.79s

Rule                                          | Time (ms) | Relative
:---------------------------------------------|----------:|--------:
@nrwl/nx/enforce-module-boundaries            |   188.481 |    28.0%
@typescript-eslint/no-misused-promises        |   170.529 |    25.3%
etc/deprecation                               |    80.029 |    11.9%
jsdoc/require-hyphen-before-param-description |    33.656 |     5.0%
jsdoc/check-alignment                         |    28.095 |     4.2%
import/no-duplicates                          |    20.434 |     3.0%
tsdoc/syntax                                  |    18.123 |     2.7%
jsdoc/check-indentation                       |    15.655 |     2.3%
react/prefer-es6-class                        |    10.229 |     1.5%
@typescript-eslint/no-unused-vars             |     7.209 |     1.1%
✨  Done in 41.79s.

3. lint builder

TIMING=1 yarn nx run analytics:lint --skip-nx-cache

architect:

"lint": {
          "builder": "@nrwl/linter:lint",
          "options": {
            "linter": "eslint",
            "tsConfig": [
              "libs/analytics/tsconfig.lib.json",
              "libs/analytics/tsconfig.spec.json"
            ],
            "exclude": ["**/node_modules/**", "!libs/analytics/**/*"]
          }
        }

measurement:

⏱ 33.53s

Rule                                          | Time (ms) | Relative
:---------------------------------------------|----------:|--------:
@nrwl/nx/enforce-module-boundaries            |   193.577 |    30.3%
@typescript-eslint/no-misused-promises        |   169.615 |    26.6%
etc/deprecation                               |    78.180 |    12.2%
jsdoc/check-alignment                         |    26.005 |     4.1%
jsdoc/require-hyphen-before-param-description |    22.307 |     3.5%
tsdoc/syntax                                  |    16.091 |     2.5%
jsdoc/check-indentation                       |    16.072 |     2.5%
import/no-duplicates                          |    12.716 |     2.0%
@typescript-eslint/no-unused-vars             |    11.469 |     1.8%
react/prefer-es6-class                        |     6.509 |     1.0%
✨  Done in 33.53s.

observations

  • @nrwl/workspace:run-commands is the slowest even though just executing underlying raw binary. I think this should be investigated a bit more as I’d expect similar number to raw binary execution (eslint)
  • @nrwl/nx/enforce-module-boundaries is the main slow down of linting process ( I’d investigate this further and add some perf tweaks to that package. Maybe just TS bump to 3.9 will improve the situation on it’s own)
  • I’d would be great to reduce that delta between native vs lint builder to less than 5 second ( I assume the number will increase with adding more files)

Lemme know if you need anything more from my side.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Which eslint rules in my config are slow? - Stack Overflow
eslint shows the spent times of rules if the environment variable TIMING is set. For example: $ TIMING=1 eslint lib Rule | Time...
Read more >
@nrwl/linter:eslint | Nx
Read more about how to configure targets and executors here: ... The basic way is to provide only lintFilePatterns , which is a...
Read more >
The ultimate migration guide to angular-eslint, ESLint and Nx 11
How to set up a new Nx workspace using angular-eslint or migrate an ... This guide assumes that Nx CLI version 11.x is...
Read more >
Speeding Up ESLint - Medium
Today, I happened to notice that on my project of 8 files, it's equally slow with the whole project as it is with...
Read more >
Adding ESLint and Cypress to a New Angular Project
(I pointed out only the changes here). The angular.json has changes as well. A lint property was added with the appropriate builders. {...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found