-
Bug
-
Resolution: Unresolved
-
P4
-
11, 17, 21, 24, 25
-
x86_64
ADDITIONAL SYSTEM INFORMATION :
## System / OS / Java Runtime Information
# Java version
java 23.0.1 2024-10-15
java 21.0.5 2024-10-15 LTS
java 17.0.12 2024-07-16 LTS
# Operating system details
$ cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.6 LTS"
NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
$ uname -a
Linux shuntian 5.15.0-84-generic #93~20.04.1-Ubuntu SMP Wed Sep 6 16:15:40 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Missed optimization in C2 compiler. This bug affects java 21.0.5
2024-10-15 LTS, java 23.0.1 2024-10-15, java 17.0.12 2024-07-16 LTS
and openjdk 11.0.18 2023-01-17. It was not reproduced in GraalVM JDK.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The following steps shows how to reproduce the bug on Java 21.0.5 in a Ubuntu Linux environment.
# Compile
$ javac C.java
# Default or compilation up to level 4
$ time java C
# Output (up to several seconds)
real 0m8.089s
user 0m8.425s
sys 0m0.028s
# Compilation up to level 3/2/1
$ java -XX:TieredStopAtLevel=3 C
# Output (hundreds of milliseconds)
real 0m0.511s
user 0m0.635s
sys 0m0.028s
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
C2 compiler should be no more slower than C1 when the method is hot
ACTUAL -
C2 compiler is much slower
---------- BEGIN SOURCE ----------
# C.java
public class C {
private static final double Z = 0.3;
public static double process(final double x) {
double w = (double) 0.1;
double p = 0;
p = (double) (3.109615012413746E307 % (w % Z));
p = (double) (7.614949555185036E307 / (x % x)); // <- return value only dependends on this line
return (double) (x * p);
}
public static void main(String[] args) {
int N = 30000000;
for (int i = 0; i < N; i++) {
process(1.0E-15d);
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
GraalVM for Level 4 are fine.
FREQUENCY : always
## System / OS / Java Runtime Information
# Java version
java 23.0.1 2024-10-15
java 21.0.5 2024-10-15 LTS
java 17.0.12 2024-07-16 LTS
# Operating system details
$ cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.6 LTS"
NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
$ uname -a
Linux shuntian 5.15.0-84-generic #93~20.04.1-Ubuntu SMP Wed Sep 6 16:15:40 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Missed optimization in C2 compiler. This bug affects java 21.0.5
2024-10-15 LTS, java 23.0.1 2024-10-15, java 17.0.12 2024-07-16 LTS
and openjdk 11.0.18 2023-01-17. It was not reproduced in GraalVM JDK.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The following steps shows how to reproduce the bug on Java 21.0.5 in a Ubuntu Linux environment.
# Compile
$ javac C.java
# Default or compilation up to level 4
$ time java C
# Output (up to several seconds)
real 0m8.089s
user 0m8.425s
sys 0m0.028s
# Compilation up to level 3/2/1
$ java -XX:TieredStopAtLevel=3 C
# Output (hundreds of milliseconds)
real 0m0.511s
user 0m0.635s
sys 0m0.028s
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
C2 compiler should be no more slower than C1 when the method is hot
ACTUAL -
C2 compiler is much slower
---------- BEGIN SOURCE ----------
# C.java
public class C {
private static final double Z = 0.3;
public static double process(final double x) {
double w = (double) 0.1;
double p = 0;
p = (double) (3.109615012413746E307 % (w % Z));
p = (double) (7.614949555185036E307 / (x % x)); // <- return value only dependends on this line
return (double) (x * p);
}
public static void main(String[] args) {
int N = 30000000;
for (int i = 0; i < N; i++) {
process(1.0E-15d);
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
GraalVM for Level 4 are fine.
FREQUENCY : always
- links to
-
Review(master) openjdk/jdk/22786