JVM Series IX (VM performance monitoring tools - Java Mission Control).

I, EDITORIAL

Previous article we introduced some command performance monitoring, including jmap (raw heap memory snapshots) and most is these two commands jstack (thread generated snapshots), in fact, in the absence of a number of monitoring tools that we use to tuning to monitor virtual machine performance. But these two command has its own shortage of places:

  • Use jmap command, starting from the Heap Dump, the entire JVM is a pause, a few G's Heap possible pause a few seconds, you need to very carefully indeed when executed on a production environment.
  • Use jstack command, ThreadDump also cause JVM pauses, plus the -l parameter, longer pause in the production environment to perform very carefully indeed.

Later, a number of monitoring tools came into being, such as Jconsule, VisualVM and fees JProfiler etc. This article introduces the Java Mission Control.

二、Java Mission Control

Java Mission Control (referred to as the JMC) is a Java application for managing, monitoring, profiling and troubleshooting tool suite comes with free after JDk7 7u40, run "JAVA_HOME" \ bin \ jmc.exe to run JMC.

Another advantage is that JMC: using sampling, rather than the traditional code implantation techniques, the impact on the performance of the application is very small, we can do JMC driving pressure measurement (the only impact may be more full gc).

JMC includes two main functions:

  • Real-time monitoring of JVM runtime
  • Java Flight Recorder sampling and analysis

real time monitoring

If the remote server, using the former to open JMX

-Dcom.sun.management.jmxremote.port=${YOUR PORT}
-Dcom.sun.management.jmxremote 
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.ssl=false 
-Djava.rmi.server.hostname=${YOUR HOST/IP}

File -> Connections -> Create a new connection, fill in the above parameters host and port JMX

By "+" to add a variety of statistical charts on demand.

"Trigger" Tab according to the CPU, information such as a thread, a certain threshold is set to trigger an alarm.

"Memory" tab to provide information and the GC heap. Follow the number of GC, GC occurs with time and changes in heap memory, in order to adjust jvm parameters.

"Thread" tab can follow the thread of each share of the CPU, a deadlock situation, and thread stack information.

Flight Recorder (sampling and analysis)

To the use of sampling, you must add parameters:

-XX:+UnlockCommercialFeatures 
-XX:+FlightRecorder

Sampling time default 1 minute, can be adjusted as needed on their own, the event set selected for profiling, which can then set the sampling profile information, such as:

  • Plus the number of objects statistics: Java Virtual Machine -> GC -> Detailed -> Object Count / Object Count after GC
  • Method Invocation sampling interval from 10ms instead 1ms (but not less than 1ms, otherwise it will affect the performance): Java Virtual Machine -> Profiling -> Method Profiling Sample / Method Sampling Information
  • Socket and File sampling, 10ms for too long, but even changed 1ms may not be able to grasp what can cancel altogether: Java Application-> File Read / FileWrite / Socket Read / Socket Write

Then began Profile, the time after the end of the Profile, the record will automatically download back, displayed in the JMC.

Information from the show, we can generally read JVM parameters, detailed information GC, hot code, object allocation and thread and so on.

In general, as far as possible to ensure that the following points, your program will run faster:

  • Allocate fewer objects
  • As far as possible be less full gc
  • Assigned little as possible outside in TLAB

Guess you like

Origin www.cnblogs.com/jmcui/p/12523822.html