Is there any way how I can setup my Android gradle project to be build using all (more) cores of my CPU?
I have MBP M1 Pro and as you can see on attached image bewow when performing Rebuild Project
it is not using all my cores in the same way.
My M1 Pro has 10 CPU cores and 2 of them are low performance and 8 performance. I would like to AS use all 8 performance cores to build my project.
There is my gradle.properties
setup:
org.gradle.caching=true
android.useAndroidX=true
android.enableR8.fullMode=true
org.gradle.parallel=true
org.gradle.daemon=true
org.gradle.configureondemand=true
I was little bit playing also with org.gradle.workers.max
and org.gradle.parallel.threads
but I didn't see any change in CPU usage at all. But maybe I just misunderstood how it works and set incorrect values.
Rebuild Project
stands for many Gradle tasks and a few IDE jobs like file indexing, I think your screenshot was captured in the middle stage, thus I consider the factor that impacts CPU loads balance is Gradle.
However, Gradle can not guarantee full usage of your CPU due to some restrictions:
--parallel
is used for tasks from different modules to run in parallel, the effect depends on " Decoupled Projects " prerequisite, you may want to check the project states / dependencies. worker
is used to separate a task into several sub "works", AGP adopted it since 4.x and used it aggressively(divide tasks into tiny works), if the project has quite a lot of modules(let say >50) and resources, 8 cores maybe even slower than 4 cores due to too many workers
(eg. a work can be finished in 0.1ms, but Lock Contention wastes more time). Using the latest AGP may resolve the problem, you can check the AGP version and try to reduce core numbers.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.