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

Bad XMM performance on java.lang.MathBench.sqrtDouble

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 16, 17
    • Fix Version/s: 17
    • Component/s: hotspot
    • Subcomponent:
    • Resolved In Build:
      b17
    • CPU:
      x86

      Description

      We have new j.l.Math JMH here: https://github.com/openjdk/jmh-jdk-microbenchmarks/blob/master/micros-jdk11/src/main/java/org/openjdk/bench/java/lang/MathBench.java

      We discovered a funny "regression" with plain sqrt.

         vsqrtsd 0x50(%r10),%xmm0,%xmm0

      17-b12:
      Benchmark Mode Cnt Score Error Units
      MathBench.sqrtDouble thrpt 12 94635.738 ± 47.086 ops/ms
      StrictMathBench.sqrtDouble thrpt 12 94652.203 ± 10.816 ops/ms

      I added another case:

          @Benchmark
          public double sqrtDoubleAfterAdd() {
              return Math.sqrt(double81 + double4Dot1);
          }

      So the double add result would be at hand into the sqrt, now we get

        1.22% ││ 0x00007ff2d93e85d7: vmovsd 0x50(%r10),%xmm0
        1.51% ││ 0x00007ff2d93e85dd: vaddsd 0x40(%r10),%xmm0,%xmm0
        1.93% ││ 0x00007ff2d93e85e3: vsqrtsd %xmm0,%xmm0,%xmm0 ;*invokestatic sqrt {reexecute=0 rethrow=0 return_oop=0}

      and the performance goes UP!

      Benchmark Mode Cnt Score Error Units
      MathBench.sqrtDouble thrpt 4 94649.452 ± 40.929 ops/ms
      MathBench.sqrtDoubleAfterAdd thrpt 4 210876.199 ± 163.751 ops/ms

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              sviswanathan Sandhya Viswanathan
              Reporter:
              ecaspole Eric Caspole
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: