Slow compilation to JS


#1

I have created a prototype of web application in Kotlin. It has json services on the backend, shared classes for jvm and javascript part and gui which is single page application running in the browser. All is going well, I love writing in Kotlin, but I am afraid of slow compilation time.
Task compileKotlin2Js takes 25-30s and generated javascript has 2000lines and 83kB. But I want to write application which is may be 50times bigger. So I will wait 20min after every change?
I have found some issues KT-6168, KT-12265,KT-15957 but nobody is working on them. Do you have any plan, when KT-12265 incremental compilation,will be solved? I am afraid to continue without it.


#2

Task compileKotlin2Js takes 25-30s and generated javascript has 2000lines and 83kB

That’s suspiciously slow. Can you provide your project so that we could try to reproduce this performance issue?

So I will wait 20min after every change?

Not necessarily. Compilation time won’t grow linearly. Remember, compiler spends some time to warm-up, read stdlib descriptors, etc. Do you use Gradle or Maven?

I have found some issues KT-6168, KT-12265,KT-15957 but nobody is working on them.

That’s not true. We are working on KT-12265.

Do you have any plan, when KT-12265 incremental compilation,will be solved?

I can’t promise anything here. The only thing I can say is: it will be available ASAP.


#3

hardware might be reason
my old laptop with core2 duo 3GHz compiles about 10 times slower then i7 6700k@4Ghz both with plenty memory and ssd’s


#4

I have laptop, procesor i5, 8GBRAM, normal (no SSD) disc,

compileKotlin2JS of ksafe-gui module takes 20s now.


#5

just tried compileKotlin2JS for ksafe. hardware matters a lot :slight_smile:

[~ ~/tmp/ksafe]$ ./gradlew clean compileKotlin2JS
:ksafe-gui:cleanSourceMap
:ksafe-gui:cleanTestSourceMap SKIPPED
:ksafe-gui:clean
:ksafe-shared:clean UP-TO-DATE
:ksafe-www:clean UP-TO-DATE
:ksafe-gui:copySharedSources UP-TO-DATE
:ksafe-gui:compileKotlin2Js

BUILD SUCCESSFUL

Total time: 4.562 secs
[~ ~/tmp/ksafe]$ killall java
[~ ~/tmp/ksafe]$ ./gradlew clean compileKotlin2JS
Starting a Gradle Daemon (subsequent builds will be faster)
:ksafe-gui:cleanSourceMap
:ksafe-gui:cleanTestSourceMap SKIPPED
:ksafe-gui:clean
:ksafe-shared:clean UP-TO-DATE
:ksafe-www:clean UP-TO-DATE
:ksafe-gui:copySharedSources UP-TO-DATE
:ksafe-gui:compileKotlin2Js

BUILD SUCCESSFUL

Total time: 6.644 secs

#6

On my machine the following command ./gradlew :ksafe-gui:clean :ksafe-gui:build takes only 2 seconds to complete. However, I could not build the project until I altered build.gradle manually. There, some paths are absolute (like /build/generated-src) and looks like Gradle tries to create something in root directory, which it is prohibited to do under my account. So I had to remove starting / from paths. Can it be the cause of slowness in you machine?


#7

Thank you for your answers. I will try to get better computer. I also vote for work on incremental compilation.

Absolute paths is my mistake. On windows it is same as relative path.


#8

Also, double check whether Gradle runs daemon and whether Kotlin compiler runs in daemon mode (you can try ./gradlew --info of ./gradlew --debug)