Friday, May 18, 2007

Java VM Tuning - GC selection

GC collector selection:

(1)default collector(serial collector).
(2)throughput collector,which try to maximum CPU usage (minimize the CPU
usage by GC). But it could introduce big pause. So, this collector
cannot be used for RTS game server.
(3)Concurrent Low Pause Collector. On uniprocessor, this collector will
have worse performance than the default GC collector (serial collector).
On Two CPU machine, this collector will not pause the running
application, but it consume too much percentage of CPU. But for more CPU
(like 3 or 4), this collector is better than the default collector.

Currently, it is assumed that 2 processors machine will be used.
So, the default GC will be used.

The two main factors for JVM optimization are :

(1)Heap Size (-Xms and -Xmx)
(2)The second most influential knob is the proportion of the heap
dedicated to the young generation. By default, the young generation size
is controlled by NewRatio. For example, setting -XX:NewRatio=3 means
that the ratio between the young and tenured generation is 1:3. In other
words, the combined size of the eden and survivor spaces will be one
fourth of the total heap size. The bigger this ratio, the less pause.
However, more frequently the GC runs. This can be logged by another
command line options: -verbose:gc -XX:+PrintGCDetails.

If this ratio set to 15, you will see the GC runs very with less pause
each time.

Have no idea about the default value of this ratio.

Total Heap Size:

Since collections occur when generations fill up, throughput is
inversely proportional to the amount of memory available. Total
available memory is the most important factor affecting garbage
collection performance.

Unless having problems with pauses, try granting as much memory as
possible to the virtual machine. The default size (64MB) is often too
small.

To make sure the pause is not too big, adjust the NewRatio accordingly.

No comments:

Post a Comment