Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if the JIT compiler is off in Java

I would like to know how to check if the JIT compiler is turned off. I have the following code which is meant to turn the JIT compiler off.The problem is, I am not sure if it is actually doing that. So I was wondering if there is a way of checking if the JIT is off. I looked at the Compiler class but there isn't any method like isDisabled/enabled().

Code:

Compiler.disable();  

Any help or direction will be highly appreciated.

like image 260
isaiah Avatar asked Feb 26 '12 21:02

isaiah


People also ask

How do I know if JIT is enabled?

To verify the JIT was enabled, create a page that calls the phpinfo() function, request the page from your browser, and verify opcache. jit_buffer_size shows the value of 100M rather than 0. Learn more about PHP's JIT compiler in our PHP 8.0 announcement.

What happens if JIT compiler is absent in Java?

Without the JIT, the VM has to interpret the bytecodes itself - a process that requires extra CPU and memory. The JIT compiler doesn't compile every method that gets called because thousands of methods can be called at startup.

Is JIT enabled by default?

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.


2 Answers

You can printout methods when they get compiled, with `-XX:+PrintCompilation if your method isn't printed out or suddenly gets faster after it is print out, you can see the likely cause.

like image 156
Peter Lawrey Avatar answered Oct 12 '22 22:10

Peter Lawrey


In the article Performance Features and Tools.

The JIT compiler was first made available as a performance update in the Java Development Kit (JDK) 1.1.6 software release and is now a standard tool invoked whenever you use the java interpreter command in the Java 2 platform release.

You can disable the JIT compiler using the -Djava.compiler=NONE option to the Java VM.

So, you can deduce that when the variable is not set, or set to something other than NONE, then the JIT is enabled.

like image 39
Edwin Dalorzo Avatar answered Oct 13 '22 00:10

Edwin Dalorzo