RFR: 8348638: Performance regression in Math.tanh [v7]
Jatin Bhateja
jbhateja at openjdk.org
Fri Apr 25 12:09:51 UTC 2025
On Fri, 25 Apr 2025 00:47:43 GMT, Mohamed Issa <duke at openjdk.org> wrote:
>> test/micro/org/openjdk/bench/java/lang/MathBench.java line 67:
>>
>>> 65: public double double1 = 1.0d, double2 = 2.0d, double81 = 81.0d, doubleNegative12 = -12.0d, double4Dot1 = 4.1d, double0Dot5 = 0.5d;
>>> 66:
>>> 67: public static final double tanhConstInputs[] = {-2.0, -1.0, -0.5, -0.1, 0.0, 0.1, 0.5, 1.0, 2.0};
>>
>> Static final arrays have mutable elements, you should declare individual static fields with different constant values.
>> We can also use @Stable annotation, in that case array index must be a constant. Is better to go with few individual static final fields with constant values.
>
> I switched to individual static final fields with constant values. There are separate micro-benchmarks included as well.
Hi @missa-prime , I still feel that due to new parameter we have significantly increased the overall benchmark time as other kernels are redundantly executed multiple times.
Please find attached a reference implementation of new benchmark and lets revert adding new parameters from MathBench.java
[TanhPerf.txt](https://github.com/user-attachments/files/19907952/TanhPerf.txt)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23889#discussion_r2060120275
More information about the hotspot-compiler-dev
mailing list