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

Performance regression in Math.tanh

XMLWordPrintable

    • b17
    • 24
    • x86_64

      I am seeing a significant performance drop for Math.tanh API with latest jdk-25 build vs jdk-23.0.2

      /home/jatinbha/softwares/jdk-23.0.2//bin/java
      CPROMPT>java -Xbatch -XX:-TieredCompilation -cp /home/intel/.m2/repository/net/jafama/jafama/2.3.2/jafama-2.3.2.jar:. perf_tanh 10000 1
      [time] 151 ms [res] 4730986895511650304
      CPROMPT>
      CPROMPT>
      CPROMPT>export JAVA_HOME=/home/jatinbha/softwares/jdk-25/
      CPROMPT>export PATH=$JAVA_HOME/bin:$PATH
      CPROMPT>
      CPROMPT>java -Xbatch -XX:-TieredCompilation -cp /home/intel/.m2/repository/net/jafama/jafama/2.3.2/jafama-2.3.2.jar:. perf_tanh 10000 1
      [time] 755 ms [res] 4730986895511650304


      While the attached test compares the performance of FastMath.tanh routine from JaFaMa library (https://github.com/jeffhain/jafama) vs JDK Math.tanh implementation, the concern here is mainly around Math.tanh performance with JDK-25.


      tanh is used as a common activation function in DNNs, one of its references is seen in Jlama - Java-based inferencing engine.
      https://github.com/tjake/Jlama/blob/main/jlama-core/src/main/java/com/github/tjake/jlama/math/ActivationFunction.java#L35C34-L35C42

            jbhateja Jatin Bhateja
            jbhateja Jatin Bhateja
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: