Is there any way to tell Gradle to pin worker thre...
# community-support
e
Is there any way to tell Gradle to pin worker threads to only use CPU performance cores (I'm using an i9 12900k)? I'm curious if the faster throughput will offset the lower parallelism enough to make it worth it. I have some tasks that use 100% of all CPU cores, and I sometimes like to do other things while building (which should be fine using the efficiency cores).
👀 1
l
Not to my knowledge. no.
Could be an interesting feature request.
m
FWIW, I'm setting
org.gradle.workers.max=8
on a similar CPU with 8P/8E cores (24 threads), to be able to do some work on the side. Most tasks nowadays use more than one core already, so the default of 24 workers is too high for local development. If it's really a single task that uses all of your CPU, this won't help. You could set the CPU affinity when starting the Gradle Daemon or your particular task, e.g. using
start /affinity n <command>
on windows
e
I usually saturate all of the cores because my build has a hundred or so projects with tasks running in parallel. The problem with just setting it on the daemon is that I think workers aren't pinned.
m
Do you really need workers? You could have a single worker and then manage parallelism inside that single worker the way you want
e
I have several 3rd party plugins using workers, but even Gradle's parallelism has this issue (i.e. I can constrain how many workers there are, but not what cores they're pinned to).
👍 1
m
Yea makes sense 👍. That would actually be a good reason to use workers and not some custom solution.
e
cpu affinity propagates to forked processes, at least on Linux, and even if it didn't, you could use the cpuset cgroup
still seems like an OS issue if it is scheduling long-running CPU-bound processes on the E cores, and if it's not long-running or CPU-bound, then it shouldn't matter
e
I didn't see that propagation in my testing, but it wasn't much of a rigorous test so I might've missed something.
It's less about OS scheduling and more about keeping all gradle work off the E core regardless of whether they're long running or CPU-bound