RFR: 8348638: Performance regression in Math.tanh [v7]
Mohamed Issa
duke at openjdk.org
Wed Apr 23 16:30:49 UTC 2025
> The changes described below are meant to resolve the performance regression introduced by the **x86_64 tanh** double precision floating point scalar intrinsic in #20657. Additionally, new input values are provided for the existing micro-benchmark and a new micro-benchmark is included to check the performance of specific input value ranges to help prevent regressions in the future.
>
> 1. Check and handle high magnitude input values before those in other ranges. If found, **+/- 1** is returned almost immediately without having to go through too many computations or branches.
> 2. Reduce the lower bound of the input range that triggers a quick **+/- 1** return from **|x| >= 32** to **|x| >= 22**. This new endpoint is the exact value required for correctness that's used by the original OpenJDK implementation.
>
> The results of all tests posted below were captured with an [Intel® Xeon 6761P](https://www.intel.com/content/www/us/en/products/sku/241842/intel-xeon-6761p-processor-336m-cache-2-50-ghz/specifications.html) using [OpenJDK v25-b15](https://github.com/openjdk/jdk/releases/tag/jdk-25%2B15) as the baseline version.
>
> For the first set of performance data collected with the new built-in **tanhRange** micro-benchmark, see the table below. Each result is the mean of 8 individual runs, and the input ranges used match those in the bug report with two additional ones included. In the high value scenarios (100, 1000, 10000, 100000), the changes increase throughput values over the baseline. Also, there is a small negative impact to the low value (1, 2, 10, 20) scenarios.
>
> | Input range(s) | Baseline (ops/s) | Change (ops/s) | Change vs baseline (%) |
> | :-------------------: | :----------------: | :----------------: | :------------------------: |
> | [-1, 1] | 22671 | 22190 | -2.12 |
> | [-2, 2] | 22680 | 22191 | -2.16 |
> | [-10, 10] | 22683 | 22149 | -2.35 |
> | [-20, 20] | 22694 | 22183 | -2.25 |
> | [-100, 100] | 29806 | 33675 | +12.98 |
> | [-1000, 1000] | 46747 | 49179 | +5.20 |
> | [-10000, 10000] | 50579 | 52070 ...
Mohamed Issa has updated the pull request incrementally with one additional commit since the last revision:
Make regular tanh benchmark inputs constant values
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/23889/files
- new: https://git.openjdk.org/jdk/pull/23889/files/cd6e1bab..64abe5f7
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=23889&range=06
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=23889&range=05-06
Stats: 6 lines in 1 file changed: 2 ins; 0 del; 4 mod
Patch: https://git.openjdk.org/jdk/pull/23889.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/23889/head:pull/23889
PR: https://git.openjdk.org/jdk/pull/23889
More information about the hotspot-compiler-dev
mailing list