RFR: 8348638: Performance regression in Math.tanh [v8]
Emanuel Peter
epeter at openjdk.org
Fri May 2 06:03:52 UTC 2025
On Fri, 25 Apr 2025 12:07:28 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:
>> Mohamed Issa has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Switch to constant double fields with separate micro-benchmarks
>
> Over all the patch looks good to me now apart from concerns around benchmark, existing Java implementation handles special cases upfront, thereby compromising the performance of most common cases. Java implementation scores above intrinsic in two outlier ranges < 2^-55 and > 22. While intrinsic implementation is performant for a meaty generic range ie. > 2^-55 and < 22.0
> We get around 30% performance uplift from intrinsic implementation over java implementation for the bulky generic input range.
> For ranges above 22.0, we now see better performance in comparison to the earlier intrinsic implementation.
>
> New benchmark shows clear gain for the value range [A][B][C] this patch optimizes.
>
>
> Baseline:
> =========
> Benchmark (tanhRangeIndex) Mode Cnt Score Error Units
> TanhPerf.TanhPerfConstant.tanhConstDouble1 N/A thrpt 2 117588.175 ops/ms
> TanhPerf.TanhPerfConstant.tanhConstDouble21 N/A thrpt 2 117550.954 ops/ms
> TanhPerf.TanhPerfConstant.tanhConstDoubleLarge N/A thrpt 2 117580.385 ops/ms => A
> TanhPerf.TanhPerfConstant.tanhConstDoubleSmall N/A thrpt 2 403652.485 ops/ms
> TanhPerf.TanhPerfConstant.tanhConstDoubleTiny N/A thrpt 2 408909.294 ops/ms
> TanhPerf.TanhPerfRanges.tanhNegRangeDouble 0 thrpt 2 397200.032 ops/ms
> TanhPerf.TanhPerfRanges.tanhNegRangeDouble 1 thrpt 2 116082.297 ops/ms
> TanhPerf.TanhPerfRanges.tanhNegRangeDouble 2 thrpt 2 112213.540 ops/ms
> TanhPerf.TanhPerfRanges.tanhNegRangeDouble 3 thrpt 2 433899.459 ops/ms => B
> TanhPerf.TanhPerfRanges.tanhPosDoubleRange 0 thrpt 2 396818.181 ops/ms
> TanhPerf.TanhPerfRanges.tanhPosDoubleRange 1 thrpt 2 115886.117 ops/ms
> TanhPerf.TanhPerfRanges.tanhPosDoubleRange 2 thrpt 2 112048.023 ops/ms
> TanhPerf.TanhPerfRanges.tanhPosDoubleRange 3 thrpt 2 440250.930 ops/ms => C
>
> WithOpt:
> ========
> Benchmark (tanhRangeIndex) Mode Cnt Score Error Units
> TanhPerf.TanhPerfConstant.tanhConstDouble1 N/A thrpt 2 116459.753 ops/ms
> TanhPerf.TanhPerfConstant.tanhConstDouble21 N/...
@jatin-bhateja @missa-prime Is https://bugs.openjdk.org/browse/JDK-8355238 related to this bug here?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/23889#issuecomment-2846434350
More information about the hotspot-compiler-dev
mailing list