Performance Tuning Guide

 Previous Next Contents View as PDF  

Tuning the WebLogic JRockit 7.0 JVM Thread System

WebLogic JRockit 7.0 JVM has two different thread systems, native threads and thin threads. The first thing to do when tuning the thread system is to select the thread system that works best for your application. What then are the pros and cons of the two thread systems and why should you prefer one thread system over another? Begin by understanding the differences between the two thread systems. The native thread model is the common threading model that most JVMs use, where each Java thread is mapped to an operating system thread of its own. The thin thread model is a hybrid threading model where WebLogic JRockit 7.0 JVM has a small fixed number of operating system threads and consequently runs multiple Java threads on top of the same operating system thread. Both models are preemptive threading models, so if one thread uses its whole time slice it gets preempted and another Java thread gets to run instead.

What are the advantages of the native thread system? The foremost advantage is that it is standard, so if you have an application that has native code and that native code relies upon the fact that each Java thread is mapped on to a operating system thread of its own, this is the only model that works (both DB2 and Oracle level 2 JDBC database drivers have been known to rely upon this). The second advantage is that on a multiprocessor system when the application has few active threads, the operating system scheduling system is better at utilizing the CPUs efficiently. A disadvantage of using native threads is that context switching is more costly as it has to be done in the operating system instead of only in the JVM. Another disadvantage is that every Java thread consumes more resources, because it requires an operating system thread of its own.

When should you use thin threads? The major benefit of using thin threads is that switching between java threads is a lot cheaper as it can be done inside the VM rather then in the operating system. Therefore the general recommendation is that if there are more than a couple of hundred threads you should try the thin thread model and determine whether it works better for your application. On Linux you should try the thin thread model, especially on a single-CPU system. This is because Linux threads in themselves are very expensive to use. In addition, if the number of threads is high, you should consider -Xallocationtype:global as suggested above to reduce heap fragmentation.

 

Back to Top Previous Next