RFR: 6506405: Math.abs(float) is slow

Joe Darcy darcy at openjdk.java.net
Thu Jul 8 00:48:47 UTC 2021


On Wed, 7 Jul 2021 20:29:37 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> 
> 
> With this change there is no measurable effect on performance on macOS, but on Linux there is approximately a 10% throughput improvement.

The improvement is with the default options, without turning intrinsics off?

I'm somewhat indifferent toward the change. On platforms with intrinsics, the intrinsic hardware instruction should run quickly regardless of how the Java code is implemented. On older versions of the platform the bitwise conversion (longBitsToDouble and friends) was slow, so the floating-point operations would be faster. However, the bitwise conversion should now be fast everywhere.

As a minor behavioral difference, the behavior on some NaN values would change in terms of which NaN was returned as a result, but any NaN is allowed by the spec.

If the new code is faster with intrinsics enabled on a common platform, I'd be happy to review a slightly refactored version of the PR.

-------------

PR: https://git.openjdk.java.net/jdk/pull/4711


More information about the core-libs-dev mailing list