JVM Runtime Compilers: -client or -server
By dagastine on Sep 26, 2005
The following is the first edition of a series of articles on JVM performance tuning basics. The suggestions are generally applicable to J2SE releases starting with 1.3, I'll try to note when release defaults differ, and plan to give you many reasons why to upgrade to our latest releases. JVM Runtime Compilers – Client or Server? The Sun JVM has two runtime compilers. Here's a brief summary of each of the systems and when to use each. Client Compiler The client compiler is for use with client applications, generally short lived, where application startup time and memory footprint size are most important. There are many features in J2SE 5.0 address these requirements. A good example is class data sharing. The client compiler is the default option for J2SE 1.3 - 1.4.2, with a change in J2SE 5.0 with the addition of the server ergonomics (see below). When do I use the client compiler? Use the client runtime compiler when application startup and memory footprint are most important to you. How do I use the client compiler? J2SE releases 1.3 to 5.0: specify -client as the first JVM tuning option. Example: > java -client my.clientApp Note: The client compiler (-client) is the default, out of the box compiler choice for J2SE releases 1.3 to 1.4.2, and J2SE 5.0 on Windows (32-bit). Server Compiler The server compiler is targetted for long lived applications where runtime performance and throughput are essential, and startup speed and memory footprint are not. When do I use the sever compiler? Its important to use -server for all server applications. For older JVMs (1.3 – 1.4.1) be sure you're running the latest update release. Its also worth trying the server compiler for your long lived IDE's (Netbeans) or cpu intensive trading applications. Use cases where runtime performance is important are broad and include both client and server applications. How do I use the server compiler? J2SE releases 1.3 to 5.0: specify -server as the first JVM tuning option. Example: > java –server my.serverApp Note: The server compiler (-server) is generally not on by default and must be specified on the command line for J2SE releases 1.3 to 1.4.2. Server ergonomics changes this default in J2SE 5.0. J2SE 5.0 Server Ergonomics The server ergonomics feature in Tiger will modify default JVM tuning options and enable the server compiler if you're running on a server class machine machine. In the J2SE 5.0 a server-class machine has been defined as a machine with 2 or more physical processors and 2 or more Gbytes of physical memory. A single hyperthreaded cpu is counted as one physical processor. Upgrade to J2SE 5.0 There are many, many reasons to upgrade to J2SE 5.0 and to the latest update J2SE 5.0_05. See the J2SE 5.0 Performance Whitepaper for details on Tiger performance improvements. Below is a few of the features recently added in J2SE 5.0_05. Large Page Support for Solaris, Linux, and Windows. J2SE 5.0_05 adds large pages support to Linux and Windows. To enable on these platforms use: -XX:+UseLargePages. This feature is on by default on Solaris 10. For more details see: http://java.sun.com/docs/hotspot/VMOptions.html (bottom of the page) System.arraycopy optimizations on SPARC and x64 System.arraycopy optimizations first identified on x64 platforms have now been extended to include SPARC platforms as well. Synchronization Performance Improvements The J2SE 5.0_05 server compiler includes simple lock coarsening. This is the first phase of our uncontended synchronization performance improvements coming in upcoming update releases. Continued J2SE API Performance Improvements J2SE 5.0_05 includes many improvements to the J2SE API. This is part of Sun's continued Java performance worka nd you should expect to see more improvements in future updates as well.