Disable Java JIT for a specific method/class?
Asked Answered
A

2

9

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)
Arrhenius answered 23/10, 2010 at 14:2 Comment(6)
Did you file a bug already? Or did you find an existing bug, which describes your problem?Gingili
Sounds very unlikely that it's due to the JIT, no? Couldn't it be due to a race-condition (since the timing changes when you disable jit)...Micky
I'm only using a single thread. I'm busy looking into the bug, but don't really have the time right now. The bug occurs consistently after a specific method has been compiled by the JIT. For now I'm just setting the -XX:CompileThreshold option high enough.Arrhenius
Have you tried a later version of the JDK ?Fideicommissum
Blaming the JVM should usually be pretty far down the list :)Song
I'll see who's to blame later when I have the time, but for now disabling the JIT for a specific method makes my problem go away.Arrhenius
A
10

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

-X:CompileCommand=exclude,the/package/and/Class,methodName
Arrhenius answered 23/10, 2010 at 15:15 Comment(3)
Sun/Oracle Java 6 and above use -XX:CompileCommand option. See java options for more information, specifically for v8.Stoker
Sorry to dig up such an old post; if I were to use this with a named inner class would I delimit it as com/domain/package/Outer/Inner or com/domain/package/Outer$Inner?Martinez
I encountered the same problem today. After some experimenting, it seems that we should use com/domain/package/Outer$Inner.Katharinakatharine
G
6

Yes, there is one. You can supply the affected classes you want to exclude JIT compilation at start-up:

-Xjit:exclude={package/class.method|package/class.method}
Gingili answered 23/10, 2010 at 14:5 Comment(2)
I get "Unrecognized option: -Xjit:exclude={...} Could not create the Java virtual machine."Arrhenius
-X options are nonstandard. They may change between versions, and are dependent on your JVMHyperesthesia

© 2022 - 2024 — McMap. All rights reserved.