Certain environment parameters and settings can be used to tune Java performance within the operating system. In addition, many of the techniques for tuning system components, such as CPU, memory, network, I/O, and so on, can serve to increase Java performance. To determine which may be beneficial to your situation, refer to the specific sections in this book.
Use the following environmental settings:
Usually the first limit that is reached is the number of file descriptors a process may have. Independently of Java, it is recommended to set this number to at least 40000 with the following command:
# ulimit -n 40000
It is also recommended that you set the Transmit Queue Size to 2048 as described in Adapter Transmit and Receive Queue Tuning.
Because the JVM searches the directories in the order in which they appear in the CLASSPATH environment variable, reorder the CLASSPATH environment variable so that the most commonly used libraries appear before any others.
The most common performance bottleneck encountered in Java applications is Garbage Collection (GC). GC is a single-threaded process that reclaims memory locations that are no longer being used by any portion of the currently executing program. When GC runs, all other threads are stopped until it has completed.
To improve GC performance, do the following:
# java -ms128M -mx128M your_program
To obtain the best possible Java performance and scalability, it is recommended that you use the latest version of the operating system and the latest available JVM and Just In Time (JIT) versions.