khalilou88 / jnxplus

Nx plugins that adds Java/Kotlin monorepo support to Nx workspace using Gradle and Maven
MIT License
55 stars 13 forks source link

Performance and mvnd #1121

Open shanon84 opened 6 days ago

shanon84 commented 6 days ago

Hey there, I am looking into performance currently. For example: a simple 5 modules maven project build and install with maven finishs in 1.5s with jnxplus "nx run-many -t build" needs 9s

In productive usage I have a repository with more than 150 maven projects (most are very small) and the build time is 10 minutes. Tried to split up compile (is cached now) and install of jar, but it did not realy improve performance. For me it looks like the hole startup process for each nx run needs too much time? Because of this I looked into mvnd and played around abit to maybe use it as a mvn alternative. It looked like to be faster. Maybe you could introduce some kind of environment variable to be able to change mvn with mvnd more easily?

Best regards

khalilou88 commented 4 days ago

Hi @shanon84

I never heard about mvnd. Yes we can add an environment variable (or / and) option to the plugin (nx.json). Since you know better than me. Can you explain the installation and the change to be made?

shanon84 commented 4 days ago

well, mvnd acts like a normal mvn cli. Only difference is the name. The installation is the same as for maven. windows: download zip and add to PATH variable. Linux/Mac: use sdkman. Internally it starts a maven daemon to reduce rerun costs, if you run multiple maven commands after each other. This should (hopefully) reduce the costs for running multiple nx tasks depending on mvn commands. Only bummer is, that there is no mvnd-wrapper currently.

khalilou88 commented 4 days ago

So we need to deprecate NX_SKIP_MAVEN_WRAPPER and create a new environment variable with values mvn and mvnd ?

khalilou88 commented 4 days ago

Here the change I am suggesting https://github.com/khalilou88/jnxplus/pull/1127

shanon84 commented 4 days ago

This is looking good. Thanks!

khalilou88 commented 4 days ago

NX_MAVEN_CLI is published in v1.4.0

shanon84 commented 1 day ago

hey, I have tested it out (on different hardware. a slow laptop). Works like a charm. Here are the stats: same 5 lib project as before. 3 parallel runs. mvn: 27sec mvnd: 17sec native mvn directly: 5.3sec So for everyone out there with performance problems: mvnd could be an alternative for you. Especially on a build server it could have a huge impact.