From fcdb08fe249ac7e4dd1849707461fd448c9b37ab Mon Sep 17 00:00:00 2001 From: David Allison <62114487+david-allison@users.noreply.github.com> Date: Fri, 13 May 2022 18:35:46 +0100 Subject: [PATCH] feat: Speed up tests on M1 Macs M1 Macs don't have SMT, so there's no need to halve the processors when running tests Before: BUILD SUCCESSFUL in 3m 1s BUILD SUCCESSFUL in 2m 57s After: BUILD SUCCESSFUL in 2m 08s BUILD SUCCESSFUL in 1m 53s --- build.gradle | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index bc8ad51e24..dbeb8034ff 100644 --- a/build.gradle +++ b/build.gradle @@ -121,7 +121,11 @@ ext { // Virtualized Environment like CI may report host CPU counts vs guest, but runs 2 cores // everyone else gets 50% of cores to account for SMT which doesn't help this workload gradleTestMaxParallelForks = 1 - if (!ciBuild) { + if (System.getProperty("os.name") == "Mac OS X") { + // macOS reports hardware cores. This is accurate for CI, Intel (halved due to SMT) and Apple Silicon + gradleTestMaxParallelForks = "sysctl -n hw.physicalcpu".execute().text.toInteger() + } else if (!ciBuild) { + // Use 50% of cores to account for SMT which doesn't help this workload gradleTestMaxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1 } }