RFR: 8360559: Optimize Math.sinh for x86 64 bit platforms
Mohamed Issa
missa at openjdk.org
Mon Jul 7 03:10:15 UTC 2025
The goal of this PR is to implement an x86_64 intrinsic for java.lang.Math.sinh() using libm. There is a new set of micro-benchmarks are included to check the performance of specific input value ranges to help prevent regressions in the future.
The command to run all range specific micro-benchmarks is posted below.
`make test TEST="micro:SinhPerf.SinhPerfRanges"`
The results of all tests posted below were captured with an [Intel® Xeon 8488C](https://advisor.cloudzero.com/aws/ec2/r7i.metal-24xl) using [OpenJDK v26-b4](https://github.com/openjdk/jdk/releases/tag/jdk-26%2B4) as the baseline version.
For performance data collected with the new built in range micro-benchmark, see the table below. Each result is the mean of 8 individual runs, and the input ranges used match those from the original Java implementation. Overall, the intrinsic provides an an average uplift of 64% when input values fall into the middle three ranges where heavy computation is required. However, very small inputs and very large inputs show drops of 74% and 66% respectively.
| Input range(s) | Baseline throughput (ops/ms) | Intrinsic throughput (ops/ms) | Speedup |
| :------------------------------------: | :-------------------------------: | :--------------------------------: | :--------: |
| [-2^(-28), 2^(-28)] | 844160 | 216029 | 0.26x |
| [-22, -2^(-28)], [2^(-28), 22] | 81662 | 157351 | 1.93x |
| [-709.78, -22], [22, 709.78] | 119075 | 167635 | 1.41x |
| [-710.48, -709.78], [709.78, 710.48] | 111636 | 177125 | 1.59x |
| (-INF, -710.48], [710.48, INF) | 959296 | 313839 | 0.33x |
Finally, the `jtreg:test/jdk/java/lang/Math/HyperbolicTests.java` test passed with the changes.
-------------
Commit messages:
- x86_64 intrinsic for sinh using libm
Changes: https://git.openjdk.org/jdk/pull/26152/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=26152&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8360559
Stats: 740 lines in 26 files changed: 737 ins; 0 del; 3 mod
Patch: https://git.openjdk.org/jdk/pull/26152.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/26152/head:pull/26152
PR: https://git.openjdk.org/jdk/pull/26152
More information about the core-libs-dev
mailing list