Introduction and installation of JVM analysis tool JProfiler

Table of contents

1. What is JProfiler?

Two, JProfiler functional structure 

1. Analysis agent

2. Record data

3. Snapshot

3. Installation 

1. What is JProfiler?

JProfiler is a professional tool for profiling what's going on inside a running JVM. You can use it in development, quality assurance, and firefighting tasks when something goes wrong with your production system.
JProfiler mainly deals with four topics:

  • method call

This is often referred to as "CPU profiling". Method calls can be measured and visualized in different ways. Analysis of method calls can help you understand what your application is doing and find ways to improve its performance.

  • distribute

Analyzing the allocation, chaining of references, and garbage collection of objects on the heap falls under the "memory analysis" category. This feature enables you to fix memory leaks, generally use less memory, and allocate fewer temporary objects.

  • Threads and Locks

Threads can hold locks, for example by synchronizing on objects. Deadlocks can occur when multiple threads cooperate, and JProfiler can visualize them for you. Also, locks can be contended, which means threads have to wait to acquire them. JProfiler provides insight into threads and their various locking situations.

  • higher level subsystem

Many performance issues occur at a higher semantic level. For example, for JDBC calls, you might want to find out which SQL statement is the slowest. For such subsystems, JProfiler provides "probes" that attach specific payloads to the call tree.
JProfiler's UI is provided as a desktop application. You can profile live JVMs interactively or automatically without using the UI. Profile data is persisted in snapshots which can be opened using the JProfiler UI. Additionally, command-line tool and build tool integrations help you automate your analysis sessions.

Two, JProfiler functional structure 

A full picture of all important interactions involving the profile application, JProfiler UI and all command line utilities is given below.

1. Analysis agent

The "JVM Tool Interface" (JVMTI) is a native interface that profilers use to access information and add hooks for inserting their own detections. This means that at least part of the analysis agent must be implemented as native code, so the JVM analysis program is not platform independent. JProfiler supports a range of platforms listed on the website.
JVM profilers are implemented as native libraries loaded at startup or sometime later. To load it at startup, add the VM argument -agentpath:<path To native library> to the command line. You rarely need to add this parameter manually because JProfiler will add it for you, e.g. in IDE integration, integration wizard, or if it starts the JVM directly. However, it's important to know that this is why profiling is enabled.
If the JVM successfully loads the native library, it calls a special function in the library, giving the profiling agent the opportunity to initialize itself. JProfiler will then print two diagnostic messages prefixed with JProfiler> so you know profiling is active. Most importantly, if you pass the -agentpath VM parameter, the analysis agent will either load successfully, or the JVM will not start.
Once loaded, the profiling agent asks JVMTI to be notified of various events, such as thread creation or class loading. Some of these events pass analytics data directly. Using classload events, the profiling agent inserts classes as they are loaded, and inserts its own bytecode to perform measurements.
JProfiler can be accessed by using the JProfilerUI or by using the bin/jpenable command line tool. In this case, it may be necessary to retransform a large number of already loaded classes in order to apply the required tools.

2. Record data

The JProfiler agent only collects profiling data. The JProfiler UI is launched separately and connects to the profiling agent via a socket. This means that it really doesn't matter whether the profiling JVM is running on the local machine or a remote machine - the communication mechanism between the profiling agent and the JProfiler UI is always the same.
From the JProfiler UI, you can instruct the agent to record data, display profiling data in the UI, and save snapshots to disk. As an alternative to the UI, the profiling agent can be controlled through its MBean. The command line tool to use this MBean is bin/jpcontroller.
Another way to control the profiling agent is to use a set of predefined triggers and actions. In this way, the analysis agent can run in unattended mode. This is called "offline profiling" in JProfiler and is very useful for automating profiling sessions.

3. Snapshot

Although the JProfiler UI can display real-time profiling data, it is often necessary to save a snapshot of all recorded profiling data. Snapshots can be saved manually in the JProfiler UI or automatically by triggering an action.
Snapshots can be opened and compared in the JProfiler UI. For automated processing, the command-line tools bin/jpexport and bin/jpcompare can be used to extract data from previously saved snapshots and create HTML reports.
A low-overhead way to take a heap snapshot from a running JVM is to use the bin/jpdump command-line tool. It uses the JVM's built-in functionality to save HPROF snapshots, which can be opened by JProfiler and does not require the profiling agent to be loaded. 

3. Installation 

下载:ej-technologies - Java APM, Java Profiler, Java Installer Builder

Executable installers are provided for Windows and Linux/Unix to guide you step-by-step through the installation. Simplifies installation if a previous installation is detected.

 On macOS, JProfiler uses the standard installation process for UI applications: a DMG archive is provided, which you can double-click to install in Finder, and then you can drag the JProfiler application bundle to the /applications folder. The folder is visible in the DMG as a symbolic link.

 On Linux/Unix, installers are not executable after downloading, so they must be prepended with sh when executing them. If the parameter -c is passed, the installer will perform a command line installation. Use the parameter -q to perform a completely unattended installation of Windows and Linux/Unix. In this case, you can pass an additional parameter -dir<directory> to select the installation directory.

 

 After running the installer, it saves a file .install4j/response.varfile which contains all user input. You can obtain this file and use it to automate unattended installations by passing the argument -varfile <path to response.varfile> on the command line.
To set license information for unattended installations, pass -Vjprofiler.licenseKey=<license-key> -Vjprofiler.licenseName=<username> and -Vjprofiller.licenseCompany=<companyName> as command line arguments (optional). If you have a floating license, use FLOAT:<server name or IP address> instead of a license key.
The archive is also provided as a ZIP file for Windows and as a .tar.gz file for Linux. Order

tar xzvf filename.tar.gz

will extract the .tar.gz archive into a separate top-level directory. To start JProfiler, execute bin/JProfiler in the extracted directory. On Linux/Unix, the file jprofiler.desktop can be used to integrate the jprofiler executable into the window manager. For example, on Ubuntu, you can drag a desktop file into the launcher sidebar in order to create a permanent launcher item.

Distributing profiling agents to remote computers
JProfiler has two parts: on the one hand the desktop UI and the command-line utility to manipulate snapshots, and on the other hand the profiling agent and the command-line application that controls the profiling JVM. The installers and archives you download from the website contain these two parts.
However, for remote profiling, you only need to install the profiling agent on the remote side. While you can simply extract the archive using a JProfiler distribution on a remote machine, you may wish to limit the number of files required, especially when automating deployment. Additionally, the evaluation agent is freely redistributable, so you can ship it with your application or install it on customer machines for troubleshooting.
To get a minimal package with an evaluation agent, the Remote Integration Wizard shows you the download link for the corresponding agent archive, and a download page that contains the agent archive files for all supported platforms. In the JProfiler GUI, invoke Session->Integration Wizard->New Server/Remote Integration, select the "Remote" option, and proceed to the remote installation directory step.

 The URL for the HTML overview page for a specific JProfiler version is:

https://www.ej-technologies.com/download/jprofiler/agent?version=13.0.7

The format of the download URL for a single proxy archive is:

https://download.ej-technologies.com/jprofiler/jprofiler_agent_<platform>_13_0_7.<extension>

Where platform corresponds to the proxy directory name in the bin directory, and the extension is zip on Windows, .tgz on macOS, and .tar.gz on Linux/Unix. For Linux, x86 and x64 are combined, so for Linux x64 the URL would be:

https://download.ej-technologies.com/jprofiler/jprofiler_agent_linux-x86_13_0_7.tar.gz

The proxy archive contains the required native proxy libraries as well as the jpenable, jpdump and jpcontroller executables. The executables in the archive only require Java 6 as a minimum version, while the profiling agent is available for Java 5 or higher.
After extracting the agent archive on the remote machine, you see the subdirectories described below. They are subsets of full JProfiler installations on their respective target platforms.

 

Guess you like

Origin blog.csdn.net/leesinbad/article/details/132101633