| JDK 17 | JDK 21 |
|---|---|
| 17.0.9-oracleFixed | 21 b25Fixed |
|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
|
|
Relates :
|
ADDITIONAL SYSTEM INFORMATION :
aarch64, Apple M1 Max, macOS 13.2.1
A DESCRIPTION OF THE PROBLEM :
Math.log using the generic dlog intrinsic is much slower than StrictMath.log on aarch64.
Caused by JDK-8215133
Related to JDK-8210858
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac Main.java
java Main
java -XX:+UnlockDiagnosticVMOptions -XX:DisableIntrinsic=_dlog Main
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The elapsed time without additional options is less than or equal to the time with the _dlog intrinsic disabled.
ACTUAL -
java Main
6200ms
java -XX:+UnlockDiagnosticVMOptions -XX:DisableIntrinsic=_dlog Main
860ms
---------- BEGIN SOURCE ----------
import java.util.Random;
import java.util.concurrent.TimeUnit;
public class Main {
public static void main(String[] args) throws Exception {
while (true) {
final Random random = new Random();
final double[] values = new double[100_000_000];
for (int i = 0; i < values.length; i++)
values[i] = random.nextDouble();
System.gc();
final long start = System.nanoTime();
double blackhole = 0;
for (int i = 0; i < values.length; i++)
blackhole += Math.log(values[i]);
final long elapsed = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
System.out.println(elapsed + "ms (" + blackhole + ")");
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Disable the _dlog intrinsic on aarch64 like -XX:DisableIntrinsic=_dlog do and use the StrictMath implementation.
FREQUENCY : always
|