participate


Java Virtual Machine (JVM) - best way to tell when JIT compiling occurs?
<<   Back to Forum  |   Give us Feedback
This topic has 1 reply on 1 page.
bbatman
Posts:218
Registered: 8/6/99
best way to tell when JIT compiling occurs?   
Feb 24, 2008 3:43 AM

 
Does anyone know what is the best technique for detecting when JIT compiling occurs during a running application?

The best approach that I can think of is this: use CompilationMXBean.getTotalCompilationTime(). I tested it quickly just now, and it seems to work as advertised (I could see JIT compilation occurring at several distinct places in my application's lifecycle). Unfortunately, it suffers from these defects:

a) the time resolution of getTotalCompilationTime is milliseconds, so it is conceivable that a hot method got compiled, but that its compilation time was < 1 ms, which could mean that its compilation goes undetected (because it was not big enough to increase the ms count). Why oh why did Sun not use System.nanoTime here?

b) some platforms do not support this method (but you can call isCompilationTimeMonitoringSupported first to find out)

The only other approach that I have seen suggested is to run your JVM with the ?XX:+PrintCompilation option, and then redirect stdout to a stream that you capture, and then parse it looking for the compilation outputs.

This second approach also has defects:

a) XX options cannot be counted on

b) there is no documentation of or commitment to the output format, so if you assume a format and it changes, you will cease detecting compilation

c) it is much more of a pain to do
 
bbatman
Posts:218
Registered: 8/6/99
Re: best way to tell when JIT compiling occurs?   
Feb 27, 2008 9:48 PM (reply 1 of 1)  (In reply to original post )

 
See also this RFE: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6667691
 
This topic has 1 reply on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 26
  • Guests : 122

About Sun forums
  • Sun Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Sun Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums