Friday, 3 December 2021

Configure build machine memory with kotlin compile daemon, gradle daemons in parallel

Assuming we have the following setup of a build machine:
24 cores.
16 GB ram.
Kotlin version: 1.5.30

I'd like to compile sources and find a stable configuration to avoid OOM errors and keep an optimal speed

For example in android it could be :app:assembleDebug task which performs compilation and builds an apk

Kotlin has own build daemon which runs together with a gradle daemon.
We should use --parallel flag for decoupled projects to speed up a build.

And here the trickiest part is how to split available RAM between parallel gradle workers and kotlin daemons to prevent OOM.

Which value should be used in org.gradle.jvmargs and kotlin.daemon.jvm.options with --max-workers=3 for example?

Like we may give for kotlin daemon 4G with kotlin.daemon.jvm.options=-Xmx4G, should we set gradle workers configuration as org.gradle.jvmargs=-Xmx12G for our build machine or 12G/3: org.gradle.jvmargs=-Xmx4G?

Can multiply kotlin daemons be created and, as a result, exceed memory constraints?



from Configure build machine memory with kotlin compile daemon, gradle daemons in parallel

No comments:

Post a Comment