Hello. We have a project with 250 KMP gradle modul...
# gradle
k
Hello. We have a project with 250 KMP gradle modules and it's quite challenging to work with it according to high memory consumption. Android + desktop + iosArm64 + iosSimulatorArm64. So I'm looking for places what we can optimize. We have flag
kotlin.mpp.enableCInteropCommonization=true
in
gradle.properties
, because one of our library applied for only one module requires it. This flag adds a lot of tasks to graph and I wonder if it can be one of paces to change. Is it possible to limit this flag to only one module, or maybe it works as desgined?
đź‘€ 1
a
Hey! Do you use Configuration Cache?
k
gradle.properties:
Copy code
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.configureondemand=true
org.gradle.configuration-cache=true
org.gradle.configuration-cache.parallel=true
org.gradle.daemon.idletimeout=300000
org.gradle.jvmargs=-Xmx10g -Dfile.encoding=UTF-8 -XX:+UseParallelGC
org.gradle.unsafe.isolated-projects=true
org.gradle.vfs.watch=true
android.enableR8.fullMode=false
android.useAndroidX=true
android.uniquePackageNames=false
android.defaults.buildfeatures.resvalues=false
android.defaults.buildfeatures.shaders=false
android.experimental.androidTest.numManagedDeviceShards=5
android.experimental.testOptions.managedDevices.maxConcurrentDevices=5
kotlin.mpp.enableCInteropCommonization=true
kotlin.mpp.enableIntransitiveMetadataConfiguration=true
kotlin.native.ignoreDisabledTargets=true
we have parallel, cache, configuration-cache, convention-plugins, isolated-proejcts, etc.
from my observations and profiling gradle sync takes around 2,:30 min, but IDE configration phase up to 13 min
so we have huge model handled by Android Studio
a
Tl:dr this flag can be applied per gradle project. But I assume it will not help too much with memory. You can try disabling config cache and see the memory usage. If it reduces, then youre hitting a known problem
k
could you say a bit more about this known configuration cache problem? I would like to read more
b
Something I did in my project is I have a Gradle plugin that configures everything and then it checks a field in my local.properties that looks like this
include.ios=false
so basically whenever it syncs, the plugin is applied, and it doesn’t add the iOS source set which significantly decreases the configuration time. It might not be the most optimal solution, but it’s what I used for quite a while since the majority of my development time was running on Android.
plus one 1
k
yes, I have similar solution. I did even one more step - dedicated flags for iosArm64 and iosSimulatorArm64. From my observations adding any ios target make a lot memory press, but adding any next increases this pression.