Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performance gain in compiling java to native code?

Is there any performance to be gained these days from compiling java to native code, or do modern hotspot compilers end up doing this over time anyway?

like image 810
jason Avatar asked Sep 09 '08 06:09

jason


People also ask

Is Java code slower than native code?

slower than compiled languages such as C or C++, similar to other just-in-time compiled languages such as C#, much faster than languages without an effective native-code compiler (JIT or AOT), such as Perl, Ruby, PHP and Python.

Can Java be compiled to native code?

Yes! Native Image The native image feature with the GraalVM SDK helps improve the startup time of Java applications and gives them a smaller footprint. Effectively, it's converting bytecode that runs on the JVM (on any platform) to native code for a specific OS/platform — which is where the performance comes from.

What is Java native compilation?

Native code compiler for Java translates the Java code into a binary representation that can be linked to precompiled library files and resources to create an executable program. Native code compilers eliminate the need for JVM and interpreters to convert the Java byte code, which is a portable intermediate code.

Is used to improve the performance this is a component which helps the program execution to happen faster in Java?

The just-in-time (JIT) compiler is the heart of the Java Virtual Machine. Nothing in the JVM affects performance more than the compiler, and choosing a compiler is one of the first decisions made when running a Java application—whether you are a Java developer or an end user.


2 Answers

There was a similar discussion here recently, for the question What are advantages of bytecode over native code?. You can find interesting answers in that thread.

like image 138
Einar Avatar answered Oct 04 '22 02:10

Einar


Some more anecdotal evidence. I've worked on a few performance critical real-time trading financial applications. I agree with Frank, nearly every time your problem is not the lack of being compiled, it is your algorithm or data structure. Modern hot-spot compilers are very good with the right code, for example the CERN Colt library is within 90% of compiled, optimised Fortran for numerical work.

If you are worried about speed I'd really recommend a good profiler and get evidence as to where your bottlenecks are - I use YourKit and have been very pleased.

We have only resorted to native compiled code for speed in one instance in the last few years, and that was so we could use CUDA and get some serious GPU performance.

like image 28
Nick Fortescue Avatar answered Oct 04 '22 03:10

Nick Fortescue