nxrocks icon indicating copy to clipboard operation
nxrocks copied to clipboard

[Bug] Long dependency graph resolution with nx-rocks/flutter

Open lume-code opened this issue 5 months ago • 5 comments

Plugin Name

@nxrocks/nx-flutter

Nx Report

Adding nx-rocks/flutter to a large monorepo comprising over 10 apps and 15 libraries resulted in a substantial increase in the time required to resolve the dependency graph (exceeding a minute). Deleting nx-rocks/flutter from nx.json restored the time to less than a second for other projects within the monorepo, which have a similar number of apps and libraries.

Expected Behaviour

Less than a minute just like other nx libs.

Actual Behaviour

Over a minute

Steps to reproduce the behaviour

  1. Add nx-rocks to a large monorepo
  2. run any build or make any change in .nx.json, project.json and try to build

lume-code avatar Jun 03 '25 04:06 lume-code

Hi @lume-code

Thanks for reaching out about this issue.

To help me solve it, can you run the following and report back on the output:

$ nx reset 

then 

$ NX_PERF_LOGGING=true nx graph

and share the output of the last command.

Also, can you provide the output of nx report command.

Thanks

tinesoft avatar Jun 03 '25 11:06 tinesoft

Hi, Thanks, graph performance log:

Time for 'loading dotenv files' 0.9471249999999998
Time for 'loading dotenv files' 0.5324999999999989
Time for 'loading dotenv files' 0.5324999999999989
Time for 'create-project-graph-async' 44085.642292
Time for 'total for sendMessageToDaemon()' 44083.192792
Time for 'deserialize daemon response' 7.364249999998719
Time for 'create-project-graph-async' 44085.642292
Time for 'total for sendMessageToDaemon()' 44083.192792
Time for 'deserialize daemon response' 7.364249999998719
Time for 'total for sendMessageToDaemon()' 12.511958000002778
Time for 'deserialize daemon response' 4.414458000006562
Time for 'total for sendMessageToDaemon()' 12.511958000002778
Time for 'deserialize daemon response' 4.414458000006562

 NX   Project graph started at http://127.0.0.1:4211/projects

Time for 'project graph watch calculation' 18.12941700000374
Time for 'create-project-graph-async' 11.430124999998952
Time for 'total for sendMessageToDaemon()' 11.194083000002138
Time for 'deserialize daemon response' 4.45770800000173
Time for 'read cache' 5.725500000000466
Time for 'project graph response generation' 1.2819999999992433
Time for 'project graph watch calculation' 18.12941700000374
Time for 'create-project-graph-async' 11.430124999998952
Time for 'total for sendMessageToDaemon()' 11.194083000002138
Time for 'deserialize daemon response' 4.45770800000173
Time for 'read cache' 5.725500000000466
Time for 'project graph response generation' 1.2819999999992433

Nx report result:

Node           : 22.13.1
OS             : darwin-arm64
Native Target  : aarch64-macos
npm            : 10.9.2

nx (global)            : 21.1.2
nx                     : 21.1.2
@nx/js                 : 21.1.2
@nx/jest               : 21.1.2
@nx/eslint             : 21.1.2
@nx/workspace          : 21.1.2
@nx/angular            : 21.1.2
@nx/devkit             : 21.1.2
@nx/eslint-plugin      : 21.1.2
@nx/module-federation  : 21.1.2
@nx/nest               : 21.1.2
@nx/node               : 21.1.2
@nx/rspack             : 21.1.2
@nx/web                : 21.1.2
@nx/webpack            : 21.1.2
typescript             : 5.7.3
---------------------------------------
Registered Plugins:
@nx/js/typescript
@nx/webpack/plugin
@nx/angular/plugin
@nxrocks/nx-flutter
---------------------------------------
Community plugins:
@nxrocks/nx-flutter : 10.0.1
apollo-angular      : 10.0.3
ng-zorro-antd       : 19.3.1
---------------------------------------
Cache Usage: 0.00 B / 92.64 GB

lume-code avatar Jun 03 '25 14:06 lume-code

Thanks for the detailled feedback.

Can you run these 2 additional commands ?

NX_PERF_LOGGING=true NX_DAEMON=false npx nx build <your_project_here> (please share the command output)

NX_PROFILE=profile.json nx build <your_project_here> (please share the generate profile.json)

tinesoft avatar Jun 03 '25 14:06 tinesoft

Sure thing, here they are:

Time for 'loading dotenv files' 0.7389170000000007
Time for 'workspace context init' 0.725958999999996
Time for 'code-loading' 31.045207999999995
Time for 'plugin worker 88819 code loading' 1.9779999999999998
Time for 'plugin worker 88822 code loading' 1.9036670000000004
Time for 'plugin worker 88820 code loading' 1.9007919999999991
Time for 'plugin worker 88821 code loading' 1.8971659999999986
Time for 'plugin worker 88823 code loading' 1.8822919999999996
Time for 'plugin worker 88824 code loading' 1.8312090000000003
Time for 'plugin worker 88825 code loading' 1.8023330000000009
Time for 'Load Nx Plugin: /Users/xxxx/xxxxxx-monorepo/node_modules/nx/src/plugins/project-json/build-nodes/project-json' 117.264583
Time for 'Load Nx Plugin: /Users/xxxx/xxxxxx-monorepo/node_modules/nx/src/plugins/package-json' 117.589125
Time for 'loadDefaultNxPlugins' 125.255583
Time for 'Load Nx Plugin: /Users/xxxx/xxxxxx-monorepo/node_modules/nx/src/plugins/js' 125.194375
Time for 'Load Nx Plugin: @nx/js/typescript' 141.852
Time for 'Load Nx Plugin: @nx/angular/plugin' 162.95729199999997
Time for 'Load Nx Plugin: @nx/webpack/plugin' 163.954417
Time for '@nx/angular/plugin:createNodes' 0.5495420000000024
Time for 'loadSpecifiedNxPlugins' 172.572042
Time for 'Load Nx Plugin: @nxrocks/nx-flutter' 171.910375
Time for 'nx/core/project-json:createNodes' 0.8935000000000173
Time for 'nx/core/package-json:createNodes' 5.168416000000008
Time for 'nx/js/dependencies-and-lockfile:createNodes' 6.511624999999981
Time for '@nx/js/typescript:createNodes' 11.422249999999991
Time for '@nx/webpack/plugin:createNodes' 96.74354199999999
Time for 'workspace context init' 0.936458999999985
⠸ Creating project graph nodes with 7 pluginsTime for '@nxrocks/nx-flutter:createNodes' 12157.442041999999
Time for 'build-project-configs' 12181.161334
Time for 'createNodes:merge' 10.907207999998718
Time for 'native-file-deps' 0.00279200000113633
Time for 'get-workspace-files' 18.994249999999738
Time for 'get-all-workspace-files' 9.931666000000405
Time for 'read cache' 5.528374999999869
Time for '@nxrocks/nx-flutter:createDependencies' 21.45612500000061
Time for '@nx/js/typescript:createDependencies' 28.019624999998996
Time for 'build typescript dependencies' 0.0825829999994312
Time for '@nx/angular/plugin:createNodes' 0.4743749999997817
Time for 'create-project-graph-async' 12469.37625
Time for 'create-project-graph-async >> retrieve-project-configurations' 12362.912667
Time for 'create-project-graph-async >> retrieve-workspace-files' 29.084625000001324
Time for 'create-project-graph-async >> build-project-graph-using-project-file-map' 65.3640409999989
Time for 'createDependencies' 38.05108399999881
Time for 'nx/js/dependencies-and-lockfile:createDependencies' 29.7567080000008
Time for 'createMetadata' 0.04108300000007148
Time for 'write cache' 11.603250000000116
Time for 'preTasksExecution' 0.15324999999938882
Time for 'nx/core/project-json:createNodes' 0.6102080000000569
Time for 'nx/core/package-json:createNodes' 1.8827909999999974
Time for 'nx/js/dependencies-and-lockfile:createNodes' 5.032750000000306
Time for '@nx/js/typescript:createNodes' 6.815292000001136
Time for '@nx/webpack/plugin:createNodes' 38.92212499999914
⠼ Creating project graph nodes with 7 pluginsTime for '@nxrocks/nx-flutter:createNodes' 12152.136166999999
Time for 'build-project-configs' 12165.533292000002
Time for 'createNodes:merge' 8.130165999999008
Time for 'native-file-deps' 0.0011249999988649506
Time for 'get-workspace-files' 20.680208999998285
Time for 'get-all-workspace-files' 2.727499999997235
Time for 'read cache' 6.0587500000001455
Time for '@nx/js/typescript:createDependencies' 28.42712499999834
Time for '@nxrocks/nx-flutter:createDependencies' 25.532916000000114
Time for 'build typescript dependencies' 0.11354099999880418
Time for '@nx/angular/plugin:createNodes' 0.41841700000077253
Time for 'create-project-graph-async' 12279.305958
Time for 'create-project-graph-async >> retrieve-project-configurations' 12174.041917
Time for 'create-project-graph-async >> retrieve-workspace-files' 23.44787500000166
Time for 'create-project-graph-async >> build-project-graph-using-project-file-map' 65.90824999999677
Time for 'createDependencies' 45.88029100000131
Time for 'nx/js/dependencies-and-lockfile:createDependencies' 36.77224999999817
Time for 'createMetadata' 0.08433299999887822
Time for 'write cache' 15.77245799999946
Time for 'nx/core/project-json:createNodes' 0.4675410000018019
Time for 'nx/core/package-json:createNodes' 2.4585000000006403
Time for '@nx/js/typescript:createNodes' 6.468000000000757
Time for 'nx/js/dependencies-and-lockfile:createNodes' 5.584917000000132
Time for '@nx/webpack/plugin:createNodes' 51.346292000001995
⠸ Creating project graph nodes with 7 pluginsTime for '@nxrocks/nx-flutter:createNodes' 12143.245457999998
Time for 'build-project-configs' 12154.709374999999
Time for 'createNodes:merge' 7.485583000001498
Time for 'native-file-deps' 0.0010409999958937988
Time for 'get-workspace-files' 21.807999999997264
Time for 'get-all-workspace-files' 3.180958000004466
Time for 'read cache' 5.985791999999492
Time for '@nxrocks/nx-flutter:createDependencies' 24.565374999998312
Time for '@nx/js/typescript:createDependencies' 29.87512499999866
Time for 'build typescript dependencies' 0.018083999995724298

And the profile.json is attached:

profile.json

lume-code avatar Jun 04 '25 03:06 lume-code

Thanks,

I will analyse those and get back to you

tinesoft avatar Jun 04 '25 04:06 tinesoft

Hi @lume-code ,

Just a reminder that I haven't forgotten about this issue. I'm currently rewriting the plugin in a way that should fix perf issue, through usage of caching. It's taking a bit more time, but I should be able to release something soon.

So stay tuned!

tinesoft avatar Jul 15 '25 08:07 tinesoft

@tinesoft Great to hear that. I appreciate the update :)

lume-code avatar Jul 15 '25 14:07 lume-code