Reputation: 750
I'm looking for a parameter or configuration in Android Studio / Gradle, that can set the build so it will use all of my CPU cores during build time. i.e. If I have a quad-core CPU and each core is running 8 threads, how can I optimize the build so it will use every resource it could get (parallel of course)?
Thank you!
Upvotes: 36
Views: 30137
Reputation: 5742
According to Gradle Build Environment Documentation:
org.gradle.configureondemand=true
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.workers.max=4
By default org.gradle.workers.max
is set to the number of CPU processors (in my case 8
).
Since my Android Studio was freezing my Ubuntu workstation (sometimes forcing me to hard reset the computer), I have set it to 4
, ensuring my workstation will not starve on CPU and memory.
Upvotes: 16
Reputation: 186
Update for accepted answer:
Since gradle uses Worker API you need to use
org.gradle.workers.max
instead of
org.gradle.parallel.threads
Link to the doc
Upvotes: 11
Reputation: 157467
in the local.properties
file in my project I have
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureondemand=true
additionally you can specify
org.gradle.parallel.threads
which specifies the maximum number of threads to use for parallel execution. it needs org.gradle.parallel=true
. Here you can find more information about it
Upvotes: 40