Java performance on Solaris - Managing CPUs

Santosh BhushanSoftware Design and Dev
Published:
Java performance on Solaris - Managing CPUs

There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".  

In a multithreaded environment where multiple threads are fighting for the CPU cycles, which in turn are the causes for things like switch context, thread migration and thereby causing latency. Assigning critical process or thread within a process to a set of dedicated CPU's improves the performance of the given application. It is because the set of dedicated CPU's is not shared by any other application. I have also observed that not only the process or application but critical thread within the process or application if it is bind to a CPU then that too improves performance.


Background
Post Solaris 10 when a user thread is created, LWP (light weight process) is simultaneously created which maps user thread to kernel thread. Light weight process is a layer between user thread and kernel thread. LWP is present because user thread cannot directly interact with kernel thread. A program will create a set of these processes running on Solaris and in turn consuming (competing for, waiting for) resources.

Performance is potentially a huge issue and beyond the scope of this Article. You can read more about performance via a lot of different sites, and a reasonable place to start is : http://www.princeton.edu/~unix/Solaris/troubleshoot/index.html 

This article is really how to maximise performance of a critical application by using dedicated CPU.


Binding a process to a set of dedicated CPU
Step1: Find out how many logical processor Solaris has
# psrinfo -vp 
                      

Open in new window



Step2: Create a processor set

# psrset -c <CPUID separated by comma>
                      

Open in new window


It will create processor set and generate processor set id usually starting from 1.
Note:  One can create multiple processor set.

Step3: Find out the PID for your application (assume it is already running)
#psj
                      

Open in new window


Step 4: Bind the PID to the processor set you have created in Step 2
#psrset -b <Processor Set ID> <PID of Application>
                      

Open in new window


Step 5:  Verify the performance of your application

Binding user thread  to a set of dedicated CPU
Step1: It remains the same as described earlier.

Lets bind the process to CPU 1-5 and two critical thread to CPU 6 and CPU 7 respectively.
Step2:
#psrset -c 1-5 
                      

Open in new window

This will create processor set ID 1 having CPU 1,2,3,4 and 5.

#psrset -c 6
                      

Open in new window

This will create processor set ID 2 having CPU 6

#psrset -c 7
                      

Open in new window

This will create processor set ID 3 having CPU 7

Step3:
Find out the PID for your application (assume it is already running)

#psj
                      

Open in new window


Step4: Dump the thread stack  into a text file
#jstack <PID> > jstack.txt 
                      

Open in new window


Step5: Find the NID value (hexadecimal) for the critical thread and convert into decimal.
#vi jstack.txt | grep "application level search to find out your critical thread" 
                      

Open in new window

Get the corresponding NID value and convert into decimal

Step6:  Verify that those thread are present in your apps.
#prstat -p <PID> -L
                      

Open in new window

It will list all the LWP's for the given PID.

Step 7: Bind the process and LWPs.
#psrset -b <Processor Set ID(1)> <PID of Application> 
                      #psrset -b <Processor Set ID(2)> <PID of Application/LWP(Decimal vlaue of NID)>
                      #psrset -b <Processor Set ID(3)> <PID of Application/LWP(Decimal vlaue of NID)>
                      

Open in new window


Verify the performance.

Note: you can start an application on the processor set by the following command
#pserset -e <Processor Set ID> java application name. 
                      

Open in new window

0
4,298 Views
Santosh BhushanSoftware Design and Dev

Comments (0)

Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.