RFR: JDK-8147933: Configure check for number of cpus ignores HT on Macosx

Erik Joelsson erik.joelsson at oracle.com
Thu Jan 21 11:11:22 UTC 2016


Oops, too fast.

diff -r f36cf7e8ba68 common/autoconf/build-performance.m4
--- a/common/autoconf/build-performance.m4
+++ b/common/autoconf/build-performance.m4
@@ -37,9 +37,9 @@
      # Looks like a Solaris system
      NUM_CORES=`LC_MESSAGES=C /usr/sbin/psrinfo -v | grep -c on-line`
      FOUND_CORES=yes
-  elif test -x /usr/sbin/system_profiler; then
+  elif test -x /usr/sbin/sysctl; then
      # Looks like a MacOSX system
-    NUM_CORES=`/usr/sbin/system_profiler -detailLevel full 
SPHardwareDataType | grep 'Cores' | awk  '{print [$]5}'`
+    NUM_CORES=`/usr/sbin/sysctl -n hw.ncpu`
      FOUND_CORES=yes
    elif test "x$OPENJDK_BUILD_OS" = xaix ; then
      NUM_CORES=`/usr/sbin/prtconf | grep "^Number Of Processors" | awk 
'{ print [$]4 }'`
@@ -74,10 +74,10 @@
      # Looks like a Solaris or AIX system
      MEMORY_SIZE=`/usr/sbin/prtconf | grep "^Memory [[Ss]]ize" | awk '{ 
print [$]3 }'`
      FOUND_MEM=yes
-  elif test -x /usr/sbin/system_profiler; then
+  elif test -x /usr/sbin/sysctl; then
      # Looks like a MacOSX system
-    MEMORY_SIZE=`/usr/sbin/system_profiler -detailLevel full 
SPHardwareDataType | grep 'Memory' | awk  '{print [$]2}'`
-    MEMORY_SIZE=`expr $MEMORY_SIZE \* 1024`
+    MEMORY_SIZE=`/usr/sbin/sysctl -n hw.memsize`
+    MEMORY_SIZE=`expr $MEMORY_SIZE / 1024 / 1024`
      FOUND_MEM=yes
    elif test "x$OPENJDK_BUILD_OS" = xwindows; then
      # Windows, but without cygwin

/Erik

On 2016-01-21 12:06, Magnus Ihse Bursie wrote:
> On 2016-01-21 11:45, Erik Joelsson wrote:
>> On all other platforms except Macosx, the logic for detecting number 
>> of cpus includes hyperthreading in their count. We do see some 
>> speedup from setting the make -j flag to a number that includes HT so 
>> we should do the same on macosx.
>>
>> I chose to fix this by querying sysctl for hardware information. It 
>> also seems to much simpler so I changed the memory detecting logic to 
>> use the same technique.
>>
>> Bug: https://bugs.openjdk.java.net/browse/JDK-8147933
>> Patch:
>> diff -r f36cf7e8ba68 common/autoconf/build-performance.m4
>> --- a/common/autoconf/build-performance.m4
>> +++ b/common/autoconf/build-performance.m4
>> @@ -39,7 +39,7 @@
>>      FOUND_CORES=yes
>>    elif test -x /usr/sbin/system_profiler; then
>>      # Looks like a MacOSX system
>> -    NUM_CORES=`/usr/sbin/system_profiler -detailLevel full 
>> SPHardwareDataType | grep 'Cores' | awk  '{print [$]5}'`
>> +    NUM_CORES=`/usr/sbin/sysctl -n hw.ncpu`
>>      FOUND_CORES=yes
>>    elif test "x$OPENJDK_BUILD_OS" = xaix ; then
>>      NUM_CORES=`/usr/sbin/prtconf | grep "^Number Of Processors" | 
>> awk '{ print [$]4 }'`
>> @@ -76,8 +76,8 @@
>>      FOUND_MEM=yes
>>    elif test -x /usr/sbin/system_profiler; then
>>      # Looks like a MacOSX system
>> -    MEMORY_SIZE=`/usr/sbin/system_profiler -detailLevel full 
>> SPHardwareDataType | grep 'Memory' | awk  '{print [$]2}'`
>> -    MEMORY_SIZE=`expr $MEMORY_SIZE \* 1024`
>> +    MEMORY_SIZE=`/usr/sbin/sysctl -n hw.memsize`
>> +    MEMORY_SIZE=`expr $MEMORY_SIZE / 1024 / 1024`
>>      FOUND_MEM=yes
>>    elif test "x$OPENJDK_BUILD_OS" = xwindows; then
>>      # Windows, but without cygwin
>>
> Nice try but you also need to change theif test -x to /usr/sbin/sysctl 
> instead of /usr/sbin/system_profiler ;-)
>
> /Magnus
>




More information about the build-dev mailing list