I've recently found out a JVM switch I was not aware of in the past, -Xcomp. The documentation says that if specified it causes 100% of the classes to be compiled with maximum optimization.
I also know that if nothing is specified the default execution mode is mixed-mode that, if I've correctly grasped the idea, means that some classes will be compiled and other not, am I right?
Well, that stated I would like to know if there is some kinda guideline one should follow when choosing whether to use one option rather than another. I've tried to execute the J2EE app I'm working on both with and without the -Xcomp option and I've measured a noticeable slowdown when the option is set. In a sense this is expectable, since the HotSpot has to compile some pieces of code that otherwise would have not, but I was expecting that after an initial transient subsequent operations would have been run faster. Is that right?
In conclusion I would like to get more information about the meaning of these settings, their runtime impacts and the way they operate when set.
Any hint/help is truly appreciated.
The JVM keeps track of how many times a method is
executed by the interpreter and compiles the method
once the number of executions have exceeded a
threshold. As you say -Xcomp causes every method
to be compiled. That includes methods that are
executed only once. For those you pay the price
for compiling and don't get any benefit because
the method is never executed again. The assumption
is that methods that are performance critical are
executed often and will get compiled. I would say
in your case since you don't see improved performance
that assumption is correct. I don't have any more details
about these setting because I just use the default