Guide to Java Profilers

In this post, we will cover some of the popular and best Java Profilers. We will be covering following Java Profilers in our post.

 

Introduction to Java Profilers

As a developer, we always try to write best and efficient code.While writing code for complex and enterprise applications, we may want to get an understanding of the JVM internals

  • What is the total memory allocated
  • What is the overall impact of making changes in the code and design?
  • Impact of concurrent execution in our application.
  • Memory usage for our application.
  • Garbage Collection, CPU utilization etc.
  • Area of improvements and bottleneck in our applications.

 

Debugging these kinds of performance issues is always challenging and if these are happening only in a specific environment (say your production environment ) is not difficult but sometimes not feasible.

Java Profiler is a tool which can help us in all these cases.These profilers work at the JVM level and hook themselves to Java bytecode operations.

 

This post is intended to give an overview of the Java profilers and will not cover features in detail. Please refer to feature section on the product home page.

 

1. JProfiler

Jprofiler is one of the most used Java Profiler for Java-based standard and enterprise applications.Jprofiler provides plugins to work with all of the popular Java IDEs.

Some of the main features of Jprofiler are

  • CPU Profiling (One of the best feature of Jprofiler).
  • Heap snapshot analysis.
  • Method call chain view.
  • Memory profiling.

This is how Jprofiler interface looks like

Jprofiler

As mentioned above, Jprofiler provides a way to integrate with all popular Java IDEs.It also provides an option to integrate with the remote machine. 

Let’s cover some of the main features of Jprofiler

 

1.1 Call Hierarchy

If we want to get an understanding of the memory usage and call hierarchy for the given session, we can click on “all Objects” under Live memory link.

Jprofiler

1.2 CPU Profiling

JProfiler offers various ways to record the call tree to optimize for performance.

Jprofiler

1.3 Database Profiling

Jprofiler provides good support for JDBC, JPA/Hibernate, and other popular databases.

Jprofiler

 

If you want to try, you can get trial copy of Jprofiler

 

2. YourKit

Yourkit is one of the mature and best Java profilers.YourKit core features include

  • Local and Remote profiling (Built-in SSH tunneling support).
  • CPU Profiling
  • Memory Profiling (memory leak, usage etc)
  • Thread usage.
  • Automated profiling.
  • GC analysis.

For more detailed about the features, please refer YourKit Features

Here is a sample dashboard for our Spring Boot based REST application

YourKit

 

2.1 Performance Chart

Performace chart shows all telemetry graphs in the same place to give you a complete picture of the system

YourKit Performance View

 

2.2 Thread View

Thread view gives complete pictures of the application’s thread with an option to show “Live”, “Live and Finished” and “Finished” thread view.

YourKit Thread View

 

2.3 Exception

One of the main features of Yourkit is its ability to profile thrown Exceptions.

YourKit Exception Profiling

Please refer to YourKit site for getting trial license

 

3. Java VisualVM

Java VisualVM is profiler tool provided by Java Development Kit (JDK).VisualVM relies on and works closely with some of the other tool provided by JDK to get all this data.It has the capabilities to detect all running local and remote VM’s.It also gives the option to configure an additional connection using JMX.

Here is the default layout of Java VisualVM

VisualVM

Some of the features offered by the Java VisualVM are

  • Display Local And Remote Java Processes
  • Display Process Configuration And Environment
  • Monitor Process Performance And Memory
  • Profile Performance And Memory Usage

 

3.1 Thread View

VisualVM provides detailed overview of the threads with an option to filter out results based on the requirements

VisualVm Thread Profiling

 

3.2 Application Monitoring

VisualVM Monitoring

 

VisualVM also provides an option to take a snapshot of the profiling session.This snapshot can be used at the later stage of the analysis.

One of the advantages of VisualVM is that it comes with JDK.We don’t have to pay any license fees to use this tool

 

 

4. Graal VisualVM

With JDK9, Java VisualVM has been moved to a new place known as GraalVM .Some of the feature provided by Graal are

  • Performance – Graal incorporates our research on compiler technology, and offers better peak performance on some workloads than a traditional JVM.
  • Embed dynamic languages and native code with sandboxing capabilities.
  • Live GraalVM processes, and analyzing applications at the guest language level (Heap Viewer)

 

 

5. APM Profilers

There are other sets of APM tools which provide a different kind of Java profiling for your applications.

Some of the popular and widely used APM solutions are

  1. New Relic
  2. Dynatrace
  3. Aappdynamics
  4. Stackify
  5. Java Mission Control

These tools work entirely different way than the Java profilers explained in above section.

These tools work by installing a java agent on the host machine.These agents will be responsible for sending required information back to the main server for analysis and evaluation.

These profilers agents are designed for

  1. Use minimum or negligible resources.
  2. No impact on production servers
  3. Send only required information back to the main APM server.

 

Summary

In this post, we discussed profiling and some of the best Java Profilers.We did not cover different features of these Java Profilers as it needs a separate article for each profiler.

Choosing a profiler is dependent upon developer and the level of analysis and information required by the team.

Umesh

Hello!! I am Umesh- an engineer by profession and a photographer by passion.I like to build stuff on the web using OSS and love to capture the world through my lens.

follow me on:

1
Leave a Reply

avatar
0 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
0 Comment authors
Recent comment authors

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
newest oldest most voted
Notify of