My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more
Slow Java / Kotlin compile times on OSX Sierra ?

Slow Java / Kotlin compile times on OSX Sierra ?

Jan Vladimir Mostert's photo
Jan Vladimir Mostert
·Apr 21, 2017

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..