Remove hyperthreading multiplier to improve performance. Tests on my local machine show that the Hyperthreading multiplier is significantly hurting our builds times. Running with 8 logical cores is 11% faster than running with 4.8 cores when doing builds on my Mac. macOS 10.12 MacBookPro 2017 (1 CPU, 4 core, 8 hyperthreaded) 1434.259 with --jobs = 5 1274.459 with --jobs = 8 I'll do some similar tests on Linux to see if it makes sense there. PiperOrigin-RevId: 178654477
diff --git a/src/main/java/com/google/devtools/build/lib/actions/LocalHostResourceManagerDarwin.java b/src/main/java/com/google/devtools/build/lib/actions/LocalHostResourceManagerDarwin.java index 3cde7f2..abaa7f9 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/LocalHostResourceManagerDarwin.java +++ b/src/main/java/com/google/devtools/build/lib/actions/LocalHostResourceManagerDarwin.java
@@ -24,16 +24,11 @@ public class LocalHostResourceManagerDarwin { private static final Boolean JNI_UNAVAILABLE = "0".equals(System.getProperty("io.bazel.EnableJni")); - private static final double EFFECTIVE_CPUS_PER_HYPERTHREADED_CPU = 0.6; private static int getLogicalCpuCount() throws IOException { return (int) NativePosixSystem.sysctlbynameGetLong("hw.logicalcpu"); } - private static int getPhysicalCpuCount() throws IOException { - return (int) NativePosixSystem.sysctlbynameGetLong("hw.physicalcpu"); - } - private static double getMemoryInMb() throws IOException { return NativePosixSystem.sysctlbynameGetLong("hw.memsize") / 1E6; } @@ -44,13 +39,11 @@ } try { int logicalCpuCount = getLogicalCpuCount(); - int physicalCpuCount = getPhysicalCpuCount(); double ramMb = getMemoryInMb(); - boolean hyperthreading = (logicalCpuCount != physicalCpuCount); return ResourceSet.create( ramMb, - logicalCpuCount * (hyperthreading ? EFFECTIVE_CPUS_PER_HYPERTHREADED_CPU : 1.0), + logicalCpuCount, 1.0, Integer.MAX_VALUE); } catch (IOException e) {