Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6611629

Avoid hardcoded cygwin paths for memory detection

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 7
    • Fix Version/s: 7
    • Component/s: infrastructure
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b25
    • CPU:
      generic
    • OS:
      generic, windows
    • Verification:
      Not verified

      Backports

        Description

        JDK build process relies on information about size of RAM to enable batch processing on Windows.
        However, autodetection process assumes cygwin is present in the c:\cygwin and has free utility installed.
        This is not the case rather often and compilation is performed assuming 512MB RAM size.

        Autodetection logic should support MKS (which has sysinf tool to get memory size) and
        cygwin installations to other directories.
        Perhaps autodetection logic can even use windows utilities (such as mem or systeminfo).
        mem tool is not very accurate and splits available memory into chunks according to DOS rules
        but from further usage of RAM estimate it seems that very accurate measurement is not required.
        The message comes from make/common/shared/Platform.gmk:
          # How much RAM does this machine have:
          MB_OF_MEMORY := $(shell \
            if [ -f "C:/cygwin/bin/free.exe" ] ; then \
              ( C:/cygwin/bin/bash.exe -c "C:/cygwin/bin/free.exe -m" ) | \
        grep Mem: | \
        sed -e 's@\ \ *@ @g' | cut -d' ' -f2 ; \
            else \
              echo "512"; \
            fi)

        The call to free.exe causes a message such as this on some windows machines
        but not others:
           Unknown HZ value! (500) Assume 100.

        The '500' varies depending on if the make is done under cygwin or MKS.

          Issue Links

            Activity

            Hide
            ohair Kelly Ohair (Inactive) added a comment -
            BT2:EVALUATION

            Windows 2003:

            systeminfo 2> /dev/null | grep 'Total Physical Memory:'
            Total Physical Memopry: 1.023 MB

            Windows 2000:

            mem | grep 'total contiguous extended memory'
               1048576 bytes total contiguous extended memory
            Show
            ohair Kelly Ohair (Inactive) added a comment - BT2:EVALUATION Windows 2003: systeminfo 2> /dev/null | grep 'Total Physical Memory:' Total Physical Memopry: 1.023 MB Windows 2000: mem | grep 'total contiguous extended memory'    1048576 bytes total contiguous extended memory
            Hide
            ohair Kelly Ohair (Inactive) added a comment -
            BT2:EVALUATION

            --- old/make/common/shared/Platform.gmk Tue Mar 18 12:11:30 2008
            +++ new/make/common/shared/Platform.gmk Tue Mar 18 12:11:30 2008
            @@ -270,7 +270,7 @@
                 REQUIRED_ALSA_VERSION = ^((0[.]9[.][1-9])|(1[.]0[.][0-9]))[0-9]*
               endif
               # How much RAM does this machine have:
            - MB_OF_MEMORY := $(shell free -m | fgrep Mem: | sed -e 's@\ \ *@ @g' | cut -d' ' -f2)
            + MB_OF_MEMORY := $(shell free -m | fgrep Mem: | awk '{print $$2;}' )
             endif
             
             # Windows with and without CYGWIN will be slightly different
            @@ -374,14 +374,35 @@
               REQUIRED_DXSDK_VER = 0x0700
               OS_VENDOR = Microsoft
               # How much RAM does this machine have:
            - MB_OF_MEMORY := $(shell \
            - if [ -f "C:/cygwin/bin/free.exe" ] ; then \
            - ( C:/cygwin/bin/bash.exe -c "C:/cygwin/bin/free.exe -m" ) | \
            - grep Mem: | \
            - sed -e 's@\ \ *@ @g' | cut -d' ' -f2 ; \
            - else \
            - echo "512"; \
            - fi)
            + ifeq ($(USING_CYGWIN),true)
            + # CYGWIN has the 'free' utility
            + _MB_OF_MEMORY := \
            + $(shell free -m | grep Mem: | awk '{print $$2;}' )
            + else
            + # Windows 2000 has the mem utility, but two memory areas
            + # extended memory is what is beyond 1024M
            + _B_OF_EXT_MEMORY := \
            + $(shell mem 2> $(DEV_NULL) | grep 'total contiguous extended memory' | awk '{print $$1;}')
            + ifeq ($(_B_OF_EXT_MEMORY),)
            + _B_OF_MEMORY := \
            + $(shell mem 2> $(DEV_NULL) | grep 'total conventional memory' | awk '{print $$1;}')
            + else
            + _B_OF_MEMORY := \
            + $(shell expr 1048576 '+' $(_B_OF_EXT_MEMORY) 2> $(DEV_NULL))
            + endif
            + ifeq ($(_B_OF_MEMORY),)
            + # Windows 2003 has the systeminfo utility use it if mem doesn't work
            + _MB_OF_MEMORY := \
            + $(shell systeminfo 2> $(DEV_NULL) | grep 'Total Physical Memory:' | awk '{print $$4;}' | sed -e 's@,@@')
            + else
            + _MB_OF_MEMORY := $(shell expr $(_B_OF_MEMORY) '/' 1024 2> $(DEV_NULL))
            + endif
            + endif
            + ifeq ($(shell expr $(_MB_OF_MEMORY) '+' 0 2> $(DEV_NULL)), $(_MB_OF_MEMORY))
            + MB_OF_MEMORY := $(_MB_OF_MEMORY)
            + else
            + MB_OF_MEMORY := 512
            + endif
             endif
             
             # Machines with 512Mb or less of real memory are considered low memory
            @@ -398,13 +419,13 @@
                 fi)
               MAX_VM_MEMORY := $(shell \
                 if [ $(MB_OF_MEMORY) -le 1024 ] ; then \
            - expr $(MB_OF_MEMORY) '-' 128 ; \
            + expr $(MB_OF_MEMORY) '-' 128 2> $(DEV_NULL) ; \
                 else \
                   echo "896"; \
                 fi)
               MIN_VM_MEMORY := $(shell \
                 if [ $(MAX_VM_MEMORY) -le 128 ] ; then \
            - expr $(MAX_VM_MEMORY) '-' 8 ; \
            + expr $(MAX_VM_MEMORY) '-' 8 2> $(DEV_NULL) ; \
                 else \
                   echo "128"; \
                 fi)
            Show
            ohair Kelly Ohair (Inactive) added a comment - BT2:EVALUATION --- old/make/common/shared/Platform.gmk Tue Mar 18 12:11:30 2008 +++ new/make/common/shared/Platform.gmk Tue Mar 18 12:11:30 2008 @@ -270,7 +270,7 @@      REQUIRED_ALSA_VERSION = ^((0[.]9[.][1-9])|(1[.]0[.][0-9]))[0-9]*    endif    # How much RAM does this machine have: - MB_OF_MEMORY := $(shell free -m | fgrep Mem: | sed -e 's@\ \ *@ @g' | cut -d' ' -f2) + MB_OF_MEMORY := $(shell free -m | fgrep Mem: | awk '{print $$2;}' )  endif    # Windows with and without CYGWIN will be slightly different @@ -374,14 +374,35 @@    REQUIRED_DXSDK_VER = 0x0700    OS_VENDOR = Microsoft    # How much RAM does this machine have: - MB_OF_MEMORY := $(shell \ - if [ -f "C:/cygwin/bin/free.exe" ] ; then \ - ( C:/cygwin/bin/bash.exe -c "C:/cygwin/bin/free.exe -m" ) | \ - grep Mem: | \ - sed -e 's@\ \ *@ @g' | cut -d' ' -f2 ; \ - else \ - echo "512"; \ - fi) + ifeq ($(USING_CYGWIN),true) + # CYGWIN has the 'free' utility + _MB_OF_MEMORY := \ + $(shell free -m | grep Mem: | awk '{print $$2;}' ) + else + # Windows 2000 has the mem utility, but two memory areas + # extended memory is what is beyond 1024M + _B_OF_EXT_MEMORY := \ + $(shell mem 2> $(DEV_NULL) | grep 'total contiguous extended memory' | awk '{print $$1;}') + ifeq ($(_B_OF_EXT_MEMORY),) + _B_OF_MEMORY := \ + $(shell mem 2> $(DEV_NULL) | grep 'total conventional memory' | awk '{print $$1;}') + else + _B_OF_MEMORY := \ + $(shell expr 1048576 '+' $(_B_OF_EXT_MEMORY) 2> $(DEV_NULL)) + endif + ifeq ($(_B_OF_MEMORY),) + # Windows 2003 has the systeminfo utility use it if mem doesn't work + _MB_OF_MEMORY := \ + $(shell systeminfo 2> $(DEV_NULL) | grep 'Total Physical Memory:' | awk '{print $$4;}' | sed -e 's@,@@') + else + _MB_OF_MEMORY := $(shell expr $(_B_OF_MEMORY) '/' 1024 2> $(DEV_NULL)) + endif + endif + ifeq ($(shell expr $(_MB_OF_MEMORY) '+' 0 2> $(DEV_NULL)), $(_MB_OF_MEMORY)) + MB_OF_MEMORY := $(_MB_OF_MEMORY) + else + MB_OF_MEMORY := 512 + endif  endif    # Machines with 512Mb or less of real memory are considered low memory @@ -398,13 +419,13 @@      fi)    MAX_VM_MEMORY := $(shell \      if [ $(MB_OF_MEMORY) -le 1024 ] ; then \ - expr $(MB_OF_MEMORY) '-' 128 ; \ + expr $(MB_OF_MEMORY) '-' 128 2> $(DEV_NULL) ; \      else \        echo "896"; \      fi)    MIN_VM_MEMORY := $(shell \      if [ $(MAX_VM_MEMORY) -le 128 ] ; then \ - expr $(MAX_VM_MEMORY) '-' 8 ; \ + expr $(MAX_VM_MEMORY) '-' 8 2> $(DEV_NULL) ; \      else \        echo "128"; \      fi)

              People

              • Assignee:
                ohair Kelly Ohair (Inactive)
                Reporter:
                igor Igor Nekrestyanov (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: