Slow Java / Kotlin compile times on OSX Sierra ?

When you create your first Kotlin "Hello World" and it takes 20+ seconds to run, I can imagine plenty of negative first impressions.

fun main(args: Array<String>) {
    println("test")
}

This is what I'm getting on Linux on a dual core machine with 8GB of RAM which I think is reasonable:

And this is what it does on OSX Sierra on a quad core machine with 16GB of RAM:

Logged a ticket here: youtrack.jetbrains.com/issue/KT-17523

After some help from the Kotlin guys on Slack, it was resolved and compile times went down from around 20 seconds to around 2 seconds.

Solution:

When you open your terminal, what does it say in front of the dollar sign?

vlad:src grim$

Now open your /etc/hosts file:

127.0.0.1    localhost 
255.255.255.255    broadcasthost 
::1             localhost

Apparently on the new OSX Sierra, compiling Java / Kotlin tries to resolve vlad.local or grim.local which takes very long to resolve.

Let's add it to the hosts file:

127.0.0.1   localhost vlad.local grim.local 
255.255.255.255    broadcasthost 
::1         localhost vlad.local grim.local

Restart your network interface:

sudo ifconfig en0 down 
sudo ifconfig en0 up

... and your compile times should drop to reasonable levels.

Huge thanks to everyone who helped on Slack and to Sébastien Deleuze for sharing this article: thoeni.io/post/macos-sierra-java and that article for mentioning this StackOverflow post: stackoverflow.com/questions/39636792/jvm-ta..

Jan Vladimir Mostert's photo

Jan Vladimir Mostert

Cape Town, South Africa

janvladimirmostert
Write your comment…

MacOS, not OSX.

Reply to this…

Share your programming knowledge and learn from the best developers on Hashnode

Get started

Note that to get the correct name you should write hostname in your terminal as pointed out in this StackOverflow comment!

Yeah, I wasn't sure at the time, so I put both in

Reply to this…