We’re sometimes having 3 KotlinCompileDaemons at o...
# compiler
m
We’re sometimes having 3 KotlinCompileDaemons at once. One we could remove by removing the manual
kotlin.daemon.jvmargs
property, but we still got two that even have the same heap size and Kotlin version. Is there a way to debug why a new KotlinCompileDaemon has been launched when another one is already running? OT: The new Gradle 9.5 feature for daemon JVM compatibility could be really helpful for Kotlin daemons as well!
d
cc @Alexander.Likhachev
a
Hey, could you please share a bit more details about your project, Kotlin version? Ideally, a reproducer project would be helpful
m
Kotlin 2.3.20
I don't know if it will be feasible for me to create a reproducer project. I might try, but this will take me a long time to get to (probably in 2 weeks at the earliest)
Is there a way to log the reason why a Kotlin compile daemon has been started?
a
Is there a way to log the reason why a Kotlin compile daemon has been started?
Currently, no. Feel free to submit a feature request at kotl.in/issue Is that a KMP project? Could you check the classpath of both running daemons?
⏳ 1
d
It could be possible that there are two daemons started if you run gradle both from the terminal and IDE. In the terminal it uses JDK from
JAVA_HOME
, and in IDE it takes the JDK from project settings, which might be different.
m
Ah, I think I see the problem now. One is actually using Kotlin 2.3.0, and is launched during the Gradle configuration phase (Gradle 9.4.1) to compile the kts files. The other is using 2.3.20 because that's what we use in our project, and that's only started in the Gradle execution phase.
kotlin_daemons.txt
@dmitriy.novozhilov nah, I'm pretty much watching those, as I know those are definitely problematic. But it is a real concern - just not mine at this point 🙂
👌 1
a
You can try switching one or both to the in-process strategy via the Gradle property
Copy code
kotlin.compiler.execution.strategy=in-process
This way, Kotlin compiler will run inside the Gradle daemon. Though if you do it for the 2.3.0 daemon (presumably from buildSrc or a similar module), I’d also recommend setting up
Copy code
kotlin.compiler.runViaBuildToolsApi=true
there to keep the benefits of IC and some other stuff. Since 2.3.20, kotlin.compiler.runViaBuildToolsApi=true is the default
👍 1
m
Yay, that worked! Thanks a lot! 🎉
Only one KotlinCompileDaemon now 🙂
a
Just to clarify, have you set the in-process strategy for 2.3.0 only?
👍 1
m
just for the build-logic folder
a
Ok, thanks! Cool that it helped you
m
Thanks a lot 🙂