Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the commonly used performance analysis commands and tools

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the knowledge of "what are the commonly used performance analysis commands and tools". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Common command jstack

View: / usr/bin/jstack-l 11400

Export: / usr/bin/jstack 11400 > thread.txt

Statistics: / usr/bin/jstack-l 11400 | grep 'Apollo-RemoteConfigRepository-1' | wc-l

View the process with high cpu usage:

Output: 1

Output:

"SimplePauseDetectorThread_0" # 78 daemon prio=9 os_prio=0 tid=0x00007f664c07c800 nid=0x2efd sleeping [0x00007f662aa37000]

Java.lang.Thread.State: TIMED_WAITING (sleeping)

At java.lang.Thread.sleep (Native Method)

At java.lang.Thread.sleep (Thread.java:340)

At java.util.concurrent.TimeUnit.sleep (TimeUnit.java:386)

At org.LatencyUtils.TimeServices.sleepNanos (TimeServices.java:62)

At org.LatencyUtils.SimplePauseDetector$SimplePauseDetectorThread.run (SimplePauseDetector.java:116)

"Thread-32" # 77 daemon prio=9 os_prio=0 tid=0x00007f664c074800 nid=0x2efc waiting on condition [0x00007f662aa78000]

Java.lang.Thread.State: WAITING (parking)

At sun.misc.Unsafe.park (Native Method)

-parking to wait for (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)

At java.util.concurrent.locks.LockSupport.park (LockSupport.java:175)

At java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await (AbstractQueuedSynchronizer.java:2039)

At java.util.concurrent.LinkedBlockingQueue.take (LinkedBlockingQueue.java:442)

At org.LatencyUtils.PauseDetector$PauseDetectorThread.run (PauseDetector.java:85)

"RxIoScheduler-1 (Evictor)" # 76 daemon prio=5 os_prio=0 tid=0x00007f66a8735800 nid=0x2eed waiting on condition [0x00007f662acb9000]

Java.lang.Thread.State: TIMED_WAITING (parking)

At sun.misc.Unsafe.park (Native Method)

-parking to wait for (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)

At java.util.concurrent.locks.LockSupport.parkNanos (LockSupport.java:215)

At java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos (AbstractQueuedSynchronizer.java:2078)

At java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take (ScheduledThreadPoolExecutor.java:1093)

At java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take (ScheduledThreadPoolExecutor.java:809)

At java.util.concurrent.ThreadPoolExecutor.getTask (ThreadPoolExecutor.java:1067)

At java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1127)

At java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:617)

At java.lang.Thread.run (Thread.java:745)

"Connection evictor" # 75 daemon prio=5 os_prio=0 tid=0x00007f66a8659000 nid=0x2eec waiting on condition [0x00007f662acfa000]

2efd

Output: PID USER PR NI VIRT RES SHR S% CPU% MEM TIME+ COMMAND

12029 root 20 0 4396512 813692 8668 S 6.2 10.2 0:05.74 java

12527 root 20 0 4396512 813692 8668 S 6.2 10.2 0:41.19 java

Top-H-p 11400

Printf'% x\ n' 12029

Jstack 11400 | grep 2efd-A 30

Jstack

Usage: jstack [- l] (to connect to running process) jstack-F [- m] [- l] (to connect to a hung process) jstack [- m] [- l] (to connect to a core file) jstack [- m] [- l] [server_id@] (to connect to a remote debug server) Options:-F to force a thread dump. Use when jstack does not respond (process is hung)-m to print both java and native frames (mixed mode)-l long listing. Prints additional information about locks-h or-help to print this help message

Thread states that are noteworthy are:

Deadlock, Deadlock (focus)

In progress, Runnable

Wait for resources, Waiting on condition (focus)

Waiting to get the monitor, Waiting on monitor entry (focus)

Pause, Suspended

Object waiting, Object.wait () or TIMED_WAITING

Blocking, Blocked (focus)

Stop, Parked

Jstack can get information about the java stack and native stack running the java program. You can easily know how the current thread is running.

Usage command parameter usage jmap

View the memory image information of a process: jmap 11400

Show Java heap details: jmap-heap 11400

Display statistics of objects in the heap: / usr/bin/jmap-histo:live 11400 | head-20

Generate heap dump snapshot dump file: jmap-dump:live,format=b,file=/tmp/heap.hprof 11400

Output: Attaching to process ID 11400, please wait...

Debugger attached successfully.

Server compiler detected.

JVM version is 25.121-b13

0x0000000000400000 7K / usr/java/jdk1.8.0_121/jre/bin/java

0x00007f664832e000 250K / usr/java/jdk1.8.0_121/jre/lib/amd64/libsunec.so

0x00007f6684bfe000 66K / usr/lib64/libbz2.so.1.0.6

0x00007f6684e0e000 153K / usr/lib64/liblzma.so.5.2.2

0x00007f6685034000 88K / usr/lib64/libz.so.1.2.7

0x00007f668524a000 97K / usr/lib64/libelf-0.166.so

0x00007f6685462000 19K / usr/lib64/libattr.so.1.1.0

0x00007f6685667000 86K / usr/lib64/libgcc_s-4.8.5-20150702.so.1

0x00007f668587d000 294K / usr/lib64/libdw-0.166.so

0x00007f6685ac5000 19K / usr/lib64/libcap.so.2.22

0x00007f6685cca000 107K / usr/lib64/libresolv-2.17.so

0x00007f6685ee4000 30K / usr/lib64/libnss_dns-2.17.so

0x00007f66862eb000 90K / usr/java/jdk1.8.0_121/jre/lib/amd64/libnio.so

0x00007f6687be0000 113K / usr/java/jdk1.8.0_121/jre/lib/amd64/libnet.so

0x00007f6687df7000 49K / usr/java/jdk1.8.0_121/jre/lib/amd64/libmanagement.so

0x00007f66c8000000 64K / usr/lib64/libnss_myhostname.so.2

0x00007f66c9bc1000 121K / usr/java/jdk1.8.0_121/jre/lib/amd64/libzip.so

0x00007f66c9ddc000 60K / usr/lib64/libnss_files-2.17.so

0x00007f66c9fef000 48K / usr/java/jdk1.8.0_121/jre/lib/amd64/libinstrument.so

0x00007f66ca1f9000 220K / usr/java/jdk1.8.0_121/jre/lib/amd64/libjava.so

0x00007f66ca425000 64K / usr/java/jdk1.8.0_121/jre/lib/amd64/libverify.so

0x00007f66ca633000 42K / usr/lib64/librt-2.17.so

0x00007f66ca83b000 1110K / usr/lib64/libm-2.17.so

0x00007f66cab3d000 16591K / usr/java/jdk1.8.0_121/jre/lib/amd64/server/libjvm.so

0x00007f66cbb2f000 2105K / usr/lib64/libc-2.17.so

0x00007f66cbefd000 18K / usr/lib64/libdl-2.17.so

0x00007f66cc101000 99K / usr/java/jdk1.8.0_121/jre/lib/amd64/jli/libjli.so

0x00007f66cc317000 138K / usr/lib64/libpthread-2.17.so

0x00007f66cc533000 159K / usr/lib64/ld-2.17.so

Output: Attaching to process ID 11400, please wait...

Debugger attached successfully.

Server compiler detected.

JVM version is 25.121-b13

Using parallel threads in the new generation.

Using thread-local object allocation.

Concurrent Mark-Sweep GC

Heap Configuration:

MinHeapFreeRatio = 40

MaxHeapFreeRatio = 70

MaxHeapSize = 536870912 (512.0MB)

NewSize = 134217728 (128.0MB)

MaxNewSize = 134217728 (128.0MB)

OldSize = 402653184 (384.0MB)

NewRatio = 2

SurvivorRatio = 8

MetaspaceSize = 21807104 (20.796875MB)

CompressedClassSpaceSize = 1073741824 (1024.0MB)

MaxMetaspaceSize = 268435456 (256.0MB)

G1HeapRegionSize = 0 (0.0MB)

Heap Usage:

New Generation (Eden + 1 Survivor Space):

Capacity = 120848384 (115.25MB)

Used = 66229472 (63.161346435546875MB)

Free = 54618912 (52.088653564453125MB)

54.80377131066974% used

Eden Space:

Capacity = 107479040 (102.5MB)

Used = 63536296 (60.592933654785156MB)

Free = 43942744 (41.907066345214844MB)

59.11505722418064% used

From Space:

Capacity = 13369344 (12.75MB)

Used = 2693176 (2.5684127807617188MB)

Free = 10676168 (10.181587219238281MB)

20.144413966758577 used

To Space:

Capacity = 13369344 (12.75MB)

Used = 0 (0.0MB)

Free = 13369344 (12.75MB)

0.0% used

Concurrent mark-sweep generation:

Capacity = 402653184 (384.0MB)

Used = 176729160 (168.54206085205078MB)

Free = 225924024 (215.45793914794922MB)

43.89116168022156% used

Output:

Num # instances # bytes class name

-

1: 273268 29359760 [C

2: 337511 10800352 java.util.concurrent.ConcurrentHashMap$Node

3: 217704 10449792 org.aspectj.weaver.reflect.ShadowMatchImpl

4: 116214 10226832 java.lang.reflect.Method

5: 217712 6966784 org.aspectj.weaver.patterns.ExposedState

6: 69225 6647552 [Ljava.lang.Object

7: 271133 6507192 java.lang.String

8: 12598 6112856 [B

9: 1479 3026296 [Ljava.util.concurrent.ConcurrentHashMap$Node

10: 50114 2806384 java.util.LinkedHashMap

11: 24799 2751976 java.lang.Class

12: 66869 2674760 java.util.LinkedHashMap$Entry

13: 34280 2507280 [Ljava.util.HashMap$Node

14: 11273 2043680 [I

15: 78910 1932576 [Z

16: 60015 1920480 java.util.HashMap$Node

17: 78497 1883920 [Lorg.aspectj.weaver.ast.Var

Output: Dumping heap to / tmp/heap.hprof...

Heap dump file created

Jmap

Usage:

Jmap [option]

(to connect to running process)

Jmap [option]

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report