Compiling/debugging HelloWorld really slow


#1

I’m just getting started with Kotlin and created the HelloWorld app sample listed on this site. When I run the app (not in debug mode), it runs fairly fast. But when I use Debug and run it, it takes several seconds before it hits the first breakpoint in the Intellij IDE, probably on the order of 10 seconds. If this is the kind of performance I am getting with just a simple HelloWorld app, I shudder to think what I am up against with a real app. So if in the end the amount of code is reduced by 20% but I end up taking 10 seconds to debug each time (and far worse for a real app), then clearly Kotlin hasn’t done anything of any value.

The sample doc is listed here:

https://kotlinlang.org/docs/tutorials/getting-started.html

This is a Kotlin/Java app.

I am running Intellij 2016.2 on a 2016 MacBook Pro. There are no plugins installed or anything else for that matter.

I also downloaded the latest verison of Kotlin (1.2) and compiled the helloworld app on the command line. It only took 3 seconds to compile. I even disabled the Make command in the project’s configuration settings so that there would be no need to compile. It would only need to run the existing compiled code in the debugger without compiling it. But that didn’t do anything. It still took 10 seconds for the app to run.

Is this 10 second startup time normal? If not, what can I do to speed it up?


#2

@BigStar
10 seconds time is not normal. There might be a problem with DNS, which can be resolved by adding local host to hosts (please see https://stackoverflow.com/questions/44680463/intellij-idea-debugger-is-too-slow-to-start-on-macos). Also please try newer Intellij with newer Kotlin plugin (1.2.20 was released just yesterday).

If this is the kind of performance I am getting with just a simple HelloWorld app, I shudder to think what I am up against with a real app.

Extrapolating HelloWorld compile times on a real app is not quite correct:

  • Starting a new build usually has some constant overhead. A build system might need to load project model, analyze what files were changed, etc. When using a CLI compiler the overhead is even larger since a new kotlinc JVM process is started every time.
  • The compiler is a large JVM program which cannot be optimized well by the JIT in relatively short amount of time. When using Intellij build system (compiling simple IDEA based projects) or Gradle, this is mitigated by persisting a compiler process between builds.
  • Real apps usually benefit a lot from incremental compilation where only modified and affected files are recompiled. From my experience with the Kotlin project itself the clean build is about 4 minutes on my machine, but that rarely happens and most compilations are within a few seconds.

#3

If you take a HelloWorld app, run it and add a single line of code, the
time from when you hit Debug until the breakpoint is reached is still 10
seconds. So as for your “few seconds”, there is no truth in that.


#4

I’ve explicitly said, that 10 seconds pauses are not normal, and should be investigated.
You’ve noted yourself, that compiling the same app with command line compiler takes 3s, not 10. There is clearly an issue.
Have you tried to add localhost to hosts (stackoverflow link in my previous message)? Have you tried updating Intellij and Kotlin plugin?