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
[@nx/eslint] ESLint project initialization is ~6x slower (Nx 17 --> 18) #23004
Comments
We've added features in Nx 18 that require generators to read the project graph, which is a bit computationally expensive. You can mock |
@AgentEnder What features do justify such multifold performance degradation? The commit I've linked above that adds changes responsible for this degradation doesn't have any description (apart from a linked GH issue that just describes desired outcome, but not how it was achieved) while changing thousands lines across hundreds of files. That fact by itself is disturbing to me. If those added features, whatever they are, are really important for some reason, have you thought implementing them as opt-in instead of using them automatically for all users?
Alternatively, if they are really required, you already provide The problem is the test are creating a virtual workspace with Thank you |
Current Behavior
Context
We have a local generator for libs, that uses Nx generators to generate 3 types of libraries:
libraryGenerator
from@nx/angular/generators
,@nx/react
and@nx/js
.We are running Jest unit tests on this generator that use
Tree
created bycreateTreeWithEmptyWorkspace
from@nx/devkit/testing
.Recently we've upgraded Nx from 17.3.2 to 18.3.3 and performance of our tests degraded - now each tests runs 6x slower.
Upgrade to Nx 18
With Nx 17.3.2 each local generator test took 30-40 ms.
After upgrade to 18.0.0 and then to 18.3.3 each test takes 190-250ms.
It doesn't matter which of the 3 types of generators (js, react, angular) we use - all are now slower by approximately same margin.
Finding the root cause
I've started digging into why they are slower, so I've started sprinkling my test code and then source code of Nx library generators with
console.time
andconsole.timeEnd
statements to find the code that is now slower.It eventually led me to ESLint project initialization during generation of a lib of any type.
To be specific, this statement added here consumes around 160ms (80%) of whole run time of a library generator:
Expected Behavior
Lib generator should not become suddenly 6x slower. And if it is really necessary to have such performance degradation in sake of adding features, it should be possible to avoid doing such expensive computation within unit tests.
GitHub Repo
No response
Steps to Reproduce
17.3.2
)Below in the Failure logs section I provide logs of the run times of specific methods within the slowest code branch for multiple test runs.
Nx Report
Failure Logs
Package Manager Version
Yarn 1.22.19
Operating System
Additional Information
No response
The text was updated successfully, but these errors were encountered: