Slow startup 3 min compared to ~30 sec in CUBA

Hi all,

starting the Jmix application takes a very long time (> 3 min to be able to respond to the first request) whereas the same application in CUBA took only ~30 seconds.

Jmix seems to compile everything from scratch and also runs the compileWidgets task everytime.

Any idea on how to improve this?

Removing the custom widgetset helps.

Since a Jmix app is a single module app, SkipUpToDateStep checks every source file in a project even if it’s not related to Widgetset.

In Haulmont/jmix-gradle-plugin#8 the excludePaths param for the compileWidgets task has been introduced. So, in the simple case, when you only need to use some add-on with widgetset, the compileWidgetstask may look as follows:

compileWidgets {
    generate 'com.company.demo.widgets.CustomWidgetSet'
    excludePaths('**/com/company/demo/**')
}

In the next Jmix Gradle plugin release, the includePaths param will be introduced (see Haulmont/jmix-gradle-plugin#30).

Ok, well, I completely disabled the compileWidgets task. It’s ok for me. But the startup time is still a PITA. I’m down to 1 min 30 sec, but that’s still significantly slower than the 30 sec with CUBA.

A lot of times, hot reload won’t work. So I’m stuck with restarting the application a lot of times during development.

Try to execute ./gradlew assemble --info and check what time each task takes to complete. For now, the reason for a slow startup is unclear.

Gleb

Thanks, but that didn’t provide a lot more insight I fear:

:bootBuildInfo (Thread[Execution worker for ':',5,main]) completed. Took 0.011 secs.
:compileKotlin (Thread[Execution worker for ':',5,main]) completed. Took 0.324 secs.
:compileJava (Thread[Execution worker for ':',5,main]) completed. Took 5.945 secs.
:processResources (Thread[Execution worker for ':',5,main]) completed. Took 0.01 secs.
:classes (Thread[Execution worker for ':',5,main]) completed. Took 0.003 secs.
:bootJarMainClassName (Thread[Execution worker for ':',5,main]) completed. Took 0.247 secs.
:bootJar (Thread[Execution worker for ':',5,main]) completed. Took 1.625 secs.
:inspectClassesForKotlinIC (Thread[Execution worker for ':',5,main]) completed. Took 0.004 secs.
:jar (Thread[Execution worker for ':',5,main]) completed. Took 0.234 secs.
:assemble (Thread[Execution worker for ':',5,main]) completed. Took 0.0 secs.

So perhaps it’s not building but the app startup is slow.
Try to add logging.level.root = debug to your application.properties and watch the startup log for what operations take much time.

Ok, I run another ./gradlew assemble --info - this time, I changed one line in the code - that’s the actual problem. Of course, during development you change code and start again. The output now is more accurate:

:bootBuildInfo (Thread[Execution worker for ':',5,main]) completed. Took 0.007 secs.
:compileKotlin (Thread[Execution worker for ':',5,main]) completed. Took 30.098 secs.
:compileJava (Thread[Execution worker for ':',5,main]) completed. Took 10.273 secs.
:processResources (Thread[Execution worker for ':',5,main]) completed. Took 0.042 secs.
:classes (Thread[Execution worker for ':',5,main]) completed. Took 0.009 secs.
:bootJarMainClassName (Thread[Execution worker for ':',5,main]) completed. Took 0.324 secs.
:bootJar (Thread[Execution worker for ':',5,main]) completed. Took 2.134 secs.
:inspectClassesForKotlinIC (Thread[Execution worker for ':',5,main]) completed. Took 0.04 secs.
:jar (Thread[Execution worker for ':',5,main]) completed. Took 0.284 secs.
:assemble (Thread[Execution worker for ':',5,main]) completed. Took 0.001 secs.

That’s still not more than ~43 seconds with the assemble task.

If I run bootRun though, the gradle tasks take ~1 minute.

12:06:25: Executing task ' bootRun'...
...
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.5.5)
2021-11-19 12:07:24.009  INFO 291561 --- [           main] c.i.MyApplication$Companion       : Starting MyApplication.Companion using Java 11.0.11 on ... with PID ...
...
2021-11-19 12:07:39.561  INFO 291561 --- [           main] com.i.MyApplication       : Application started at http://localhost:8080

That says it’s ~ 1min 15sec for serving the first request.

My best bet is probably to try to optimize the kotlin compilation process. Any ideas?