Find the CPU-consuming Java Thread PS command
Command: PS-MP pid-o thread,tid,time or PS-LFP pid
The main purpose of this command is to get some information about the threads that correspond to a process. For example, if you want to analyze some of the running bottlenecks of a Java process, you can use this command to find the CPU time of all current thread, the last column here.
For example, a tid:30834 is found here, which takes up the most time.
Through the printf "%xn" 30,834 first into 16, continue to dump the current JVM process through the jstack command stack information. The grep command allows you to find the thread ID information that corresponds to the 16 feed, and you will soon be able to locate the most CPU-consuming code.
Simply explained, jstack the content of this thread of information:
"dboserviceprocessor-4-thread-295" daemon prio=10 tid=0x00002aab047a9800 nid=0x7d9b waiting on condition [ 0X0000000046F66000]
Nid: The corresponding Linux operating system under the TID, is the previous conversion of the 16 binary digits
Tid: This should be the only address location in the JVM's JMM memory specification, and if you can use it in a detailed analysis of some of the JVM's memory data, I'm not in that position, so let's put it down.
Command: TOP-HP PID
The results show:
And the previous effect, you can track it in real time and get the most CPU-consuming threads in the specified process. The previous method is used to extract the corresponding thread stack information.
Determining I/O bottlenecks
Command: Mpstat-p all 1 1000
The results show:
Notice the%iowait column in this, the time the CPU spends waiting for I/O operations. This value continues to be high and can often be caused by an I/O bottleneck.
This parameter makes it more intuitive to see if there is a bottleneck in the current I/O operation.
Command: iostat-m-X 1 1000
Also, you can observe the%iowait data in the corresponding CPU, in addition to the Iostat also provides some more detailed I/O state data, such as more important:
Avgqu-sz:the average queue Length of the requests that were issued to the device. (Disk queue request length, normal 2,3 is better.) Can be understood as CPU load)
Await:the average time (in milliseconds) for I/O requests issued to the device to is served. (Represents the total time from wait to completion of an I/O operation)
Both SVCTM and%util represent the time spent on processing the I/O request and the CPU time scale. These two parameters are not primary when judging whether the bottleneck
r/s w/s and rmb/s wmb/s are some of the states that represent the I/O that the current system is processing, which is what we often call TPS, the latter being throughput. This is also the evaluation of a system performance indicators
Command: Pidstat-p pid-u-d-t-w-h 1 1000
The results show:
A fairly practical command that can be based on a process to analyze the corresponding performance data, including Cpu,i/o,ir, CS and so on, can make it easier for developers to observe the operation of the system more refined. However, Pidstat appears to be in some newer versions of the 2.6 kernel and needs to be installed with Sysstat packs.
Ubuntu can be installed through the sudo apt-get install Sysstat.
Command: Sar-x PID 1 1000
SAR can also specify the corresponding PID, focus on a few fixed parameters, not as strong as Pidstat. I do not see the corresponding I/O, IR and other information.
The functions of SAR can be covered by mpstat, Iostat and other functions.
Command: dstat-y--tcp 1 1000
Through Dstat--tcp can be more convenient to see the current TCP various states, do not need every time netstat-nat to see
NETSTAT-NATP: Check the corresponding network links, pay attention to the next recv-q, Send-q, state.
Lsof-p PID: Find the file handle of the corresponding PID
Lsof-i: 80: Find out which process the corresponding port is occupied by
Lsof/tmp/1.txt: Find out which process the corresponding file is occupied by
Tcpdump/wireshark: Bag Analysis tool
Jstat/jmap/jstack/jps and a series of Java monitoring commands
If you want to do some performance tuning work, you must be good at using some tools to focus on the appropriate state. Through the Linux command you can easily observe the CPU, I/O, network and other relatively peripheral state, many times can already solve most of the problems. Some of the running state monitoring within the JVM requires the use of some unique tools for fine-grained observations.