Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to turn off JIT compiler and is there a performance impact by doing so?

What does it mean for a Java program to be JIT'ed and does it make the execution a lot more faster? Or are there bytecodes which are not JIT'ed?

like image 962
CoDerus Avatar asked Dec 16 '15 15:12

CoDerus


People also ask

How does JIT improve performance?

The JIT compiler helps improve the performance of Java programs by compiling bytecodes into native machine code at run time. The JIT compiler is enabled by default. When a method has been compiled, the JVM calls the compiled code of that method directly instead of interpreting it.

What is JIT performance?

Just-in-time compilation is a method for improving the performance of interpreted programs. During execution the program may be compiled into native code to improve its performance. It is also known as dynamic compilation. Dynamic compilation has some advantages over static compilation.

Is JIT compilation slower?

JIT compilers translate continuously, as with interpreters, but caching of compiled code minimizes lag on future execution of the same code during a given run. Since only part of the program is compiled, there is significantly less lag than if the entire program were compiled prior to execution.


2 Answers

From the doc,

-Xint

Runs the application in interpreted-only mode. Compilation to native code is disabled, and all bytecode is executed by the interpreter.

The java.compiler system property is known by Compiler class before Java 9. In Java 9 it's marked as @Deprecated.

like image 119
Hong Avatar answered Oct 25 '22 00:10

Hong


There is two ways to disable the JIT

-Djava.compiler=NONE 

or this will almost never compile anything

-XX:CompileThreshold=2000000000

or on IBM JVM

-nojit

Disabling the JIT can slow down your code a lot e.g. 50x but not always. If you spend most of your time doing IO or GUI updates you might find it makes little difference.

like image 40
Peter Lawrey Avatar answered Oct 25 '22 01:10

Peter Lawrey