Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Java JIT for a specific method/class?

I'm having an issue in my Java application where the JIT breaks the code. If I disable the JIT, everything works fine, but runs 10-20x slower.

Is there any way to disable the JIT for a specific method or class?

Edit: I'm using Ubuntu 10.10, getting the same results both with:

OpenJDK Runtime Environment (IcedTea6 1.9) (6b20-1.9-0ubuntu1)
OpenJDK 64-Bit Server VM (build 17.0-b16, mixed mode)

and:

Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) 64-Bit Server VM (build 14.2-b01, mixed mode)
like image 434
Ralf Avatar asked Oct 23 '10 14:10

Ralf


People also ask

How do you disable a method in Java?

disable() method is available in java. lang package. disable() method is used to cause the compiler to stop operation. disable() method is a static method, it is accessible with the class name and if we try to access the method with the class object then we will not get any error.

Does Java use JIT or AOT?

There are two main compilation strategies in Java: Just in Time Compilation (JIT) and Ahead of Time Compilation (AOT). The first generates machine code during the execution of the program itself (i.e., shortly before the first invocation of a Java method).

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.


1 Answers

The following option works on my JVMs, to exclude a specific method:

-X:CompileCommand=exclude,the/package/and/Class,methodName
like image 163
Ralf Avatar answered Oct 07 '22 23:10

Ralf