Skip to content

[GR-60803][Native Image] For loop performance in native image is not good #10392

Closed
@akashKarmakar02

Description

@akashKarmakar02

Describe the Issue

I was testing performance in native-image. so i decided to test for loop
graalvm 23.0.1 os: linux arch: x86_64
Code:

class Main {
  public static void main(String[] args) {
    for (int i = 0; i < Integer.parseInt(args[0]); i++);
  }
}

native image compilation command: native-image -O3 -march=native Main

time output:
image

Using the latest version of GraalVM can resolve many issues.

GraalVM Version

java 23.0.1 2024-10-15
Java(TM) SE Runtime Environment Oracle GraalVM 23.0.1+11.1 (build 23.0.1+11-jvmci-b01)
Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 23.0.1+11.1 (build 23.0.1+11-jvmci-b01, mixed mode, sharing)

Operating System and Version

Linux fedora 6.12.6-200.fc41.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 19 21:06:34 UTC 2024 x86_64 GNU/Linux

Troubleshooting Confirmation

Run Command

./main 99999999
java Main 99999999

Expected Behavior

native-image should have run faster

Actual Behavior

native image is 5 times slower

Steps to Reproduce

  1. create java file with
class Main {
  public static void main(String[] args) {
    for (int i = 0; i < Integer.parseInt(args[0]); i++);
  }
}
  1. compile it with java and native image native-image -O3 -march=native Main
  2. and run them

Additional Context

No response

Run-Time Log Output and Error Messages

No response

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions