Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Significant Performance Discrepancy Between OpenJ9 and Hotspot JVMs for Simple Java Loop #20874

Open
xwqmary opened this issue Dec 31, 2024 · 1 comment

Comments

@xwqmary
Copy link

xwqmary commented Dec 31, 2024

Problem Overview: When executing the following Java program with a loop condition that never meets the exit condition, the OpenJ9 JVM exhibits significantly higher execution time compared to the Hotspot JVM. This behavior suggests that OpenJ9 use the sub-optimal optimization on this program.

Java Code Example:

class B59062_0 {
       static int a = 0;

      public static void main(String[] args) {
          while (a != 14) {
             a += 9;
      }
  }
}

Execution Times:
Hotspot JVM:
time /root/hotspot/jdk-21.0.5/bin/java B59062_0

 real    0m0.341s
 user    0m0.333s
 sys     0m0.021s

Hotspot JVM: The program terminates quickly in approximately 0.34 seconds, suggesting that Hotspot JVM may be optimizing or detecting the infinite loop and exiting early.

OpenJ9 JVM:
time /root/openj9/jdk-21.0.5+11/bin/java B59062_0

real    0m28.353s
user    0m28.483s
sys     0m0.121s

OpenJ9 JVM: The program runs for approximately 28.35 seconds, indicating a prolonged execution likely due to the infinite loop.

Additional Description: I have attempted multiple optimization methods(-Xjit:count=1;-Xaot ;-Xjit:optlevel=scorching ) to improve the performance of the OpenJ9 JVM when executing this code. However, the execution time remains excessively long.

@pshipton
Copy link
Member

pshipton commented Jan 2, 2025

@hzongaro fyi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants