Comment 4 for bug 541520

Revision history for this message
Jason Brittain (jason-brittain) wrote :

My short opinion is: Yes, it does make sense to use the CMS GC for Tomcat by default.

Aaron: Thanks very much for the link to Sun's Hotspot memory management white paper, and for the suggestion to use CMS by default. I have seen quite a few production Tomcat environment config files over the years, each one specifying to use a different set of the GC startup switches, and I often wondered which one made the most sense. The white paper you gave us the link for has text that specifically says that the CMS GC is particularly well suited for web servers, or similar situations where lowest response time is very important. Until now, I had not seen much credible documentation that specifically said that.

From the perspective of looking at this problem over a period of years, the right answer actually changes because the JVM's features change. Right now, with the features of the current Sun JDKs and OpenJDKs, the CMS GC appears to be the right GC algorithm to use for a Tomcat JVM because CMS is well supported: it's been in the code for quite some time (since the 1.4.1 release, according to the docs), and I have not heard any complaints about its stability.

Of course we're only talking about the package defaults and general recommendations, and it is up to the user to carry out some performance testing to find what works best for their webapp(s), with their own performance goals in mind.

For both the Sun Hotspot JDK and OpenJDK running a Tomcat JVM, I recommend using -XX:+UseConcMarkSweepGC as the default, and in the case where Tomcat is running on a single CPU chip that has either a single or dual core inside, I also recommend using -XX:+CMSIncrementalMode. But, incremental mode probably shouldn't be the default in the Tomcat package's defaults file because we don't know what hardware the user is going to run it on. We can add the additional option in there, commented out, however:

# When using the CMS garbage collector, enable this option if you run Tomcat
# on a machine with exactly one CPU chip that contains one or two cores.
#JAVA_OPTS="$JAVA_OPTS -XX:+CMSIncrementalMode"

Also, this GC setting should be valid for Tomcat 5.5.x and Tomcat 6.0.x running on any HotSpot JVM (including OpenJDK) version 1.4.1 or higher, though I'd suggest using it only on version 1.5.0 or higher. I believe that means it should go into both the tomcat55 and tomcat6 packages.

Some other JVMs, including recent GNU gij, and Apache Harmony JDKs both take these JVM arguments and at least these switches don't cause any error. But, I don't know whether it has any positive or negative effects.