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

Mac OS build settings should use -O3

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 15
    • Fix Version/s: 15
    • Component/s: infrastructure
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b27
    • CPU:
      x86
    • OS:
      os_x

      Description

      Mac OS X should use -O3 optimization level to be consistent with other platforms and benefit Mac OS X java with the same performance levels as other platforms.

      Mac OS X has used -Os level optimization since management of the platform JDK was handed over from Apple. This level of optimization was Apple's policy, not OpenJDK's. The policy was established in a time when memory was tight (I was there at the time.) Since then other platforms have moved on, making the decision to target speed over disk space. Specifically, using -O3 level optimization.

      I've personally seen 20-30% improvement in performance in C/C++ applications using -O3 over -Os. But, of course, the performance team should verify the affect on the JDK.

      A 11% real time improvement can be seen with a rough HelloWord compile/run.

      >> time $JDK15Os/bin/java HelloWorld.java
      Hello World!

      real 0m0.385s
      user 0m0.842s
      sys 0m0.049s
      >> time $JDK15Os/bin/java HelloWorld.java
      Hello World!

      real 0m0.368s
      user 0m0.810s
      sys 0m0.049s
      >> time $JDK15Os/bin/java HelloWorld.java
      Hello World!

      real 0m0.382s
      user 0m0.834s
      sys 0m0.050s

      >> time $JDK15O3/bin/java HelloWorld.java
      Hello World!

      real 0m0.365s
      user 0m0.734s
      sys 0m0.051s
      >> time $JDK15O3/bin/java HelloWorld.java
      Hello World!

      real 0m0.363s
      user 0m0.749s
      sys 0m0.048s
      >> time $JDK15O3/bin/java HelloWorld.java
      Hello World!

      real 0m0.367s
      user 0m0.755s
      sys 0m0.052s

      The down side is about a 7% increasingly in the disk size of the JDK (520,941,898 bytes vs 486,650,895 bytes), but this is consistent with the difference on other platforms.

      diff -r de8d5e5dd4e0 make/autoconf/flags-cflags.m4
      --- a/make/autoconf/flags-cflags.m4 Sat Jun 06 10:05:20 2020 -0300
      +++ b/make/autoconf/flags-cflags.m4 Mon Jun 08 09:52:41 2020 -0300
      @@ -239,21 +239,11 @@
             C_O_FLAG_NONE="${C_O_FLAG_NONE} ${DISABLE_FORTIFY_CFLAGS}"
           fi
         elif test "x$TOOLCHAIN_TYPE" = xclang; then
      - if test "x$OPENJDK_TARGET_OS" = xmacosx; then
      - # On MacOSX we optimize for size, something
      - # we should do for all platforms?
      - C_O_FLAG_HIGHEST_JVM="-Os"
      - C_O_FLAG_HIGHEST="-Os"
      - C_O_FLAG_HI="-Os"
      - C_O_FLAG_NORM="-Os"
      - C_O_FLAG_DEBUG_JVM=""
      - else
      - C_O_FLAG_HIGHEST_JVM="-O3"
      - C_O_FLAG_HIGHEST="-O3"
      - C_O_FLAG_HI="-O3"
      - C_O_FLAG_NORM="-O2"
      - C_O_FLAG_DEBUG_JVM="-O0"
      - fi
      + C_O_FLAG_HIGHEST_JVM="-O3"
      + C_O_FLAG_HIGHEST="-O3"
      + C_O_FLAG_HI="-O3"
      + C_O_FLAG_NORM="-O2"
      + C_O_FLAG_DEBUG_JVM="-O0"
           C_O_FLAG_SIZE="-Os"
           C_O_FLAG_DEBUG="-O0"
           C_O_FLAG_NONE="-O0"

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              ihse Magnus Ihse Bursie
              Reporter:
              jlaskey Jim Laskey
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: