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

4

13

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?

Forebrain answered 16/12, 2015 at 15:31 Comment(0)
G
21

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.

Galibi answered 16/12, 2015 at 16:17 Comment(3)
I am learning java and have so many doubts regarding most of the stuff.....thank you for your answer. :) further I would like to know what compiler comes in to play when we disable JIT?Forebrain
@Forebrain disabling the JIT means there is no compiler. Instead the code is only run in interpreter mode.Galibi
I was a bit surprised that this ancient java.compiler property still works despite you can’t really use it to specify an actual compiler implementation, so I investigated a bit and found JDK-8227229 which explains a bit of the history and also reveals the surprising fact that specifying -Xdebug makes -Djava.compiler=NONE ineffective, so using -Xint has always been the more reliable option.Kiely
P
13

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.

Parrot answered 3/6, 2019 at 9:33 Comment(0)
D
3

For IBM the correct option is -Xnojit or -Xint

Doherty answered 6/10, 2016 at 20:2 Comment(2)
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From ReviewAcute
When I wrote his answer I was not allowed to comment. Otherwise, I would have.Doherty
T
1

In HotSpot VM JIT compilation can be disabled with the option -XX:-UseCompiler which skips compiler threads initialization.

It is true by default:

product(bool, UseCompiler, true,                                          
        "Use Just-In-Time compilation")   
Thaler answered 26/9, 2019 at 7:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.