I have a JAVA process that runs every day and takes about 1,000 or 2,000 hits before it is fully optimized by the JIT. What I'd like to do is save the JIT info so that the next day it can start in an optimized state. It seems like this should be possible, but I have not been able to find any method for doing so.
-
2http://stackoverflow.com/questions/1992486/why-doesnt-the-jvm-cache-jit-compiled-code – stacker Feb 01 '10 at 17:28
-
1how much of a performance hit (in seconds) are you seeing for the jitting process vs jvm startup vs normal app startup. – Peter Recore Feb 01 '10 at 17:44
3 Answers
You could use an ahead-of-time compiler like JET or GCJ, but I don't believe there's any standard way to save the JIT form. Keep in mind that this ties your program into the architecture you're running on, but it sounds like you're aware and accepting of this.

- 1,249
- 1
- 10
- 21
-
3Some more info from http://www.javalobby.org/forums/thread.jspa?threadID=15812: Apparently the current research shows that loading the cached JIT is slower than recompiling it in most cases, but that you may want to give JRockit a try. – Jon Feb 01 '10 at 17:27
-
3that thread is 6 years old - i'm not sure it qualifies as "current" research" :) – Peter Recore Feb 01 '10 at 17:41
-
3You make an excellent point that I should have noticed (or checked). I'm still just reeling from that Bush-Kerry race. – Jon Feb 01 '10 at 17:51
-
1on the other hand, it is possible the research hasn't changed at all since then! processors are still a lot faster than disks (if anything, they are even more faster than disks than they were before, unless you are lucky enough to be running a solid state disk in your servers.) – Peter Recore Feb 01 '10 at 18:00
One option is to control the number of invocations needed for a method to be considered eligible for JIT compile.
-XX:CompileThreshold (default 10000).
You could play around various values to tune up with your application.
Please note that setting this to ZERO is NOT recommended.

- 1,271
- 9
- 7
Can you just keep your app running? What happens if you just have your app sleep until the next day rather than shutting down? You will then save time starting up the JVM as well as potentially skipping the jitting phase.

- 14,037
- 4
- 42
- 62
-
1this is attractive, but i don't have that level of control over the enterprise decisions. – Zip Feb 01 '10 at 17:44
-
1