https://kotlinlang.org logo
Title
v

Vitali Plagov

06/29/2022, 12:35 PM
Just enabled the new K2 compiler in our project. Not a super big project, just a regular back-end API service. But already see the difference in compilation time. 👍 In the

1.7.0 release video

there’s another flag -
-Xbackend-threads=4
. But it doesn’t affect the compilation time regardless of number of threads I specify. Am I doing something wrong or missing?
compileKotlin {
    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_11
        freeCompilerArgs = ["-Xuse-k2", "-Xbackend-threads=4"]
    }
}
d

dmitriy.novozhilov

06/29/2022, 12:38 PM
cc @udalov
u

udalov

06/29/2022, 1:01 PM
Results might vary for different projects. If it’s an open source project, or at least it can be shared with the JetBrains team, we can investigate what’s happening. Also, parallel mode requires a bit more memory during compiler execution, so increasing it might help (e.g.
kotlin.daemon.jvmargs=-Xmx...
in
gradle.properties
)
v

Vitali Plagov

06/29/2022, 1:06 PM
Thanks for the answer. Sorry, can’t share it, it’s a commercial internal project, so can’t share it outside of the org.
Anyway, it’s fine. Not a super big project