Skip to main content

CompileThreshold server jvm option

1 reply [Last post]
Joined: 2007-10-30
Points: 0

I have been playing with the -XX:CompileThreshold jvm option for a benchmark of my application, and I don't understand the results.

When I put CompileThreshold very low, like for instance 10, the performance is worst. If I put it higher it gets slowly better until around 10.000, where performance starts to stabilize. I have understood that this is the default for Sun's server JVM, so I could just as well leave the CompileThreshold setting for what it is.

But I don't understand why performance is worst for the lowest value?
My benchmark consists of very many floating point arithmetic calculations and heavy physical memory access. A number of cases are calculated and timings are measured in a one batch.
This complete batch I run 3 times to let the JIT compiler do its work and I use only the timings of the 3rd run. Every time I can see a big performance difference between the 1st and the 2nd run, the 3rd run is almost the same as the 2nd run.

My understanding of CompileThreshold was, that the lower you put its value, the less iterations of some code were needed to let the JIT compiler start compiling it. So if I would put it very low I would see a big performance slowdown in the very short run, but the same or slightly better performance soon after that. However this is not what I see happening. What's going on here?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2005-07-11
Points: 0

It's true that a lower setting for CompileThreshold will trigger compilations
of hot methods sooner. However, the compiler has less profile information
for those methods and can't always apply all the available optimizations
as it needs to make more conservative assumptions. As we run in the
interpreter for a longer period of time, more profile information is collected
and better assumptions can be made, which results in better generated
code. This is likely the effect that you are seeing.

It's been stated in the past that a low compile threshold can actually reduce
performance and this is a (rather typical) example of that. That's not to say
that no application will benefit from tuning the compile threshold, but few will.