On Sep 4, 2009, at 1:31 PM, Sean Owen wrote:

(just to make sure everyone's on the same page, given the title of
this thread -- these are not javac optimizations)

I do think it's worth cataloging recommended JVM flags for runtime
use. My current recommendations are:

-server
-da -dsa (I think these are redundant since assertions are off by
default but...)
-XX:+NewRatio=9 (for CF code this tunes for more long-lived objects)
-XX:+UseParallelGC -XX:+UseParallelOldGC (nice win for multiprocessor machines)

But even -server is redundant on server class machines, which even some desktop machines with a few cores qualify as these days. IMO, garbage collection parameters are best set after observing your application under load based on log analysis and typical usage patterns. Until then, just use the defaults. Moreover, the number of options available to the GC is mostly overwhelming and leads to a whole big mess of parameters with most people never knowing what they really need and often just making things worse. Time and time again I see people making assumptions about performance without being pragmatic and doing the work to test (Paging in Lucene is the classic example). I've seen clients spend weeks on JVM tuning when some changes (often simple) in their application gave 10-20% improvements and massive reductions in memory all at very little cost. None of those gains would have been feasible w/o pragmatic testing under load and an analysis of their application. As Ted said, time is better spent on algorithms and data structures, especially in these early stages.


Of course the right flags vary according to usage. It's important
enough to performance to publish recommendations.

While it may be true that one could get a 2x speedup by better
algorithms, I don't see that it follows that a 10% win just by adding
the right JVM flags is somehow not useful. 10% is certainly nothing to
sneeze at IMHO, for a couple seconds of change to a script. Right?

Of course, but it often becomes a black hole figuring out how all those parameters work and which ones help and hurt. Not to say you shouldn't do it and that it isn't welcome, just that it is often hard to give general recs for those things given all the platforms that Java runs on. Instead, I'd suggest we could give resources to people on how they can determine them.

-Grant

Reply via email to