Getting Started with Eclipse Jifa
Tags: java, performance, tutorial, opensource
Published: 2022-02-28 16:06:39

<!-- wp:paragraph -->
<p>I have been posting multiple <strong>videos about the Performance Engineering Series</strong> on <a href="https://www.youtube.com/playlist?list=PLJ9A48W0kpRJ6Za-PG87scNCJp7kFgW2g" target="_blank" rel="noreferrer noopener">QAInsights channel,</a> which will help you to get started with troubleshoot Java applications. In this blog post, we are going to see how you can use Eclipse Jifa to identify potential performance bottlenecks in your Java applications.  Let us get started.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Eclipse Jifa</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p><a href="https://github.com/eclipse/jifa" target="_blank" rel="noreferrer noopener">Eclipse Jifa</a> (Java Issue Finder Assistant) is an open-source application to troubleshoot Java applications. The inception phase of Jifa was back in 2020 by Alibaba under the Eclipse Foundation. Developers from Netflix, Alibaba Cloud, and other developers are contributing to Jifa project. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Jifa is a scalable web-based application, easy to deploy, and maintain. Right now, it supports the following analysis: <strong>Heap Dump, Thread Dump (an enterprise feature) and GC Log</strong>. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Jifa's frontend is Vue 2.0, backend is Eclipse Vert.x. Jifa's analytical engine consists of Heap Dump service and GC Log Analyzer. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Scalability can be achieved by deploying Jifa in a Master-Worker fashion, also known as the Map-Reduce pattern. Most of the performance testing tools use this technique to generate more load for the target application. </p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Install</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>There are multiple ways you can follow to install Jifa. The easiest way is to run the docker container using the below command.</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>docker run -p 8102:8102 jifadocker/jifa-worker:demo</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>Jifa also supports Kubernetes and Master-Worker patterns for scalability, or you can build the artifacts using Gradle and deploy. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>For personal use, I'd recommend docker mode. For enterprise use, please use Master-Worker or Kubernetes patterns for the enterprise features. </p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3>Master-Worker Deployment</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Before you get started, please make sure you have <code>nodejs</code>, <code>npm</code>, Gradle and <code>JDK 11</code> is installed.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>git clone https://github.com/eclipse/jifa</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>./gradlew buildJifa</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>cd jifa/deploy/default_pattern</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>./deploy_jifa.sh</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Launch <code>127.0.0.1:8089</code></p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":9103,"sizeSlug":"full","linkDestination":"media"} -->
<div class="wp-block-image"><figure class="aligncenter size-full"><a href="https://qainsights.com/wp-content/uploads/2022/02/image-17.png"><img src="https://qainsights.com/wp-content/uploads/2022/02/image-17.png" alt="" class="wp-image-9103"/></a><figcaption>Jifa Home Page</figcaption></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>If you want to deploy only the workers, use the below commands.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>cd deploy</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>./deploy_worker.sh</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Launch <code>127.0.0.1:8102</code>.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>In Master-Worker mode, <code>master</code> node routes the user requests from the client to the workers and schedules new workers on-demand.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>worker</code> nodes perform the analysis.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3>Kubernetes </h3>
<!-- /wp:heading -->

<!-- wp:code -->
<pre class="wp-block-code"><code>cd scripts/docker_images
./build_image.sh
cd ../..
cd deploy/k8s_pattern
./deploy.sh</code></pre>
<!-- /wp:code -->

<!-- wp:paragraph -->
<p>Launch <code>localhost:8089</code></p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":9104,"sizeSlug":"full","linkDestination":"media"} -->
<div class="wp-block-image"><figure class="aligncenter size-full"><a href="https://qainsights.com/wp-content/uploads/2022/02/image-18.png"><img src="https://qainsights.com/wp-content/uploads/2022/02/image-18.png" alt="Jifa Enterprise Features" class="wp-image-9104"/></a><figcaption>Jifa Enterprise Features</figcaption></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>In Kubernetes mode, workers can be orchestrated based on the analysis tasks. To release a pod, click on <code>release</code> button.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":9127,"sizeSlug":"full","linkDestination":"media"} -->
<div class="wp-block-image"><figure class="aligncenter size-full"><a href="https://qainsights.com/wp-content/uploads/2022/02/image-30.png"><img src="https://qainsights.com/wp-content/uploads/2022/02/image-30.png" alt="Release Worker" class="wp-image-9127"/></a><figcaption>Release Worker</figcaption></figure></div>
<!-- /wp:image -->

<!-- wp:heading -->
<h2>Heap Dump Analysis</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Let us upload a sample heap dump to Jifa and play around with the features. There are multiple ways you can generate a heap dump. In this demo, I am going to upload a heap dump from JMeter. But you can upload any heap dump you want.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Launch Jifa, click on <strong>Heap Dump Analysis</strong> &gt; <strong>Add Heap Dump file</strong> to upload the file.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":9106,"sizeSlug":"full","linkDestination":"media"} -->
<div class="wp-block-image"><figure class="aligncenter size-full"><a href="https://qainsights.com/wp-content/uploads/2022/02/image-19.png"><img src="https://qainsights.com/wp-content/uploads/2022/02/image-19.png" alt="" class="wp-image-9106"/></a><figcaption>Upload Heap Dump</figcaption></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Jifa supports various sources such as S3, OSS, URL, SCP or local for upload the file. Drag and drop the heap dump file (OpenJDK HPROF format) or click the <strong>Upload </strong>icon to upload. </p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":9107,"sizeSlug":"full","linkDestination":"media"} -->
<div class="wp-block-image"><figure class="aligncenter size-full"><a href="https://qainsights.com/wp-content/uploads/2022/02/image-20.png"><img src="https://qainsights.com/wp-content/uploads/2022/02/image-20.png" alt="" class="wp-image-9107"/></a></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Click <code>analyze</code> to get started. Check <strong>keep unreachable objects</strong> and click <strong>Confirm</strong>. </p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":9109,"sizeSlug":"full","linkDestination":"media"} -->
<div class="wp-block-image"><figure class="aligncenter size-full"><a href="https://qainsights.com/wp-content/uploads/2022/02/image-21.png"><img src="https://qainsights.com/wp-content/uploads/2022/02/image-21.png" alt="" class="wp-image-9109"/></a><figcaption>Analyze</figcaption></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Once the analysis is complete, Jifa will display all the details.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":9110,"sizeSlug":"full","linkDestination":"media"} -->
<div class="wp-block-image"><figure class="aligncenter size-full"><a href="https://qainsights.com/wp-content/uploads/2022/02/image-22.png"><img src="https://qainsights.com/wp-content/uploads/2022/02/image-22.png" alt="Jifa Analysis" class="wp-image-9110"/></a><figcaption>Jifa Analysis</figcaption></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>The analyzed information might be familiar if you are familiar with Eclipse MAT. Jifa uses Eclipse MAT under the hood for Heap dump analysis to detect memory leaks for better performance. The following are the features of Heap Dump Analysis in Jifa.</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li>Overview</li><li>Leak Suspects</li><li>GC Roots</li><li>Dominator Tree</li><li>Class Histogram</li><li>Unreachable Objects</li><li>Duplicated Classes</li><li>Class Loaders</li><li>Direct Byte Buffer</li><li>System Property</li><li>Thread Info</li><li>OQL</li><li>Other features</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>Jifa features <code>an inspector</code> panel where the search using the object address is possible to dive into the respective object. The Inspector panel can be toggled on/off under <strong>Settings</strong>.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":9112,"sizeSlug":"full","linkDestination":"media"} -->
<div class="wp-block-image"><figure class="aligncenter size-full"><a href="https://qainsights.com/wp-content/uploads/2022/02/image-23.png"><img src="https://qainsights.com/wp-content/uploads/2022/02/image-23.png" alt="" class="wp-image-9112"/></a></figure></div>
<!-- /wp:image -->

<!-- wp:heading -->
<h2>Thread Dump Analysis</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Go to Jifa home page and click on <strong>Thread Dump Analysis</strong> to upload a sample thread dump. Analyze the thread dump to view the output. Thread dump analysis helps to identify issues like thread locks, deadlocks, to understand threads' state and more.  </p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":9115,"sizeSlug":"large","linkDestination":"media"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><a href="https://qainsights.com/wp-content/uploads/2022/02/image-24.png"><img src="https://qainsights.com/wp-content/uploads/2022/02/image-24-1024x524.png" alt="" class="wp-image-9115"/></a><figcaption>Thread Dump Analysis</figcaption></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>The following are the features in <strong>Thread Dump Analysis</strong>.</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li>Basic Information</li><li>Thread Overview</li><li>Thread Group Overview</li><li>Java Monitor</li><li>Stack Trace</li><li>Raw content</li></ul>
<!-- /wp:list -->

<!-- wp:heading -->
<h2>GC Log Analysis</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Garbage Collection Log analysis helps to optimize GC settings, memory management and more. To generate a GC log, pass the <code>-verbose:gc -Xlog:gc*:file=./gc.log</code> to the JVM arguments for Java 9 or above. This will generate a GC log in the current directory.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Upload gc.log to Jifa to analyze. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Jifa supports the following for GC log analysis:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li>OpenJDK 8 and 11</li><li>Serial GC, Parallel GC, CMS GC, G1 GC, ZGC</li></ul>
<!-- /wp:list -->

<!-- wp:image {"align":"center","id":9116,"sizeSlug":"full","linkDestination":"media"} -->
<div class="wp-block-image"><figure class="aligncenter size-full"><a href="https://qainsights.com/wp-content/uploads/2022/02/image-25.png"><img src="https://qainsights.com/wp-content/uploads/2022/02/image-25.png" alt="GC Log Analysis" class="wp-image-9116"/></a><figcaption>GC Log Analysis</figcaption></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>The Overview </strong>tab features the problems and suggestions, metadata, and Key Performance Indicators. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Graph </strong>tab features visualizations about GC count, pause time, heap, and more.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":9118,"sizeSlug":"large","linkDestination":"media"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><a href="https://qainsights.com/wp-content/uploads/2022/02/image-26.png"><img src="https://qainsights.com/wp-content/uploads/2022/02/image-26-1024x559.png" alt="GC Graphs" class="wp-image-9118"/></a><figcaption>GC Graphs</figcaption></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>GC Cause and Phase </strong>displays about GC activities such as Full GC, Young GC, and more and the pie chart.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":9119,"sizeSlug":"large","linkDestination":"media"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><a href="https://qainsights.com/wp-content/uploads/2022/02/image-27.png"><img src="https://qainsights.com/wp-content/uploads/2022/02/image-27-1024x272.png" alt="GC Cause and Phase" class="wp-image-9119"/></a><figcaption>GC Cause and Phase</figcaption></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p><strong>GC Detail</strong> tab helps to filter the GC events, log time, and more.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":9120,"sizeSlug":"full","linkDestination":"media"} -->
<div class="wp-block-image"><figure class="aligncenter size-full"><a href="https://qainsights.com/wp-content/uploads/2022/02/image-28.png"><img src="https://qainsights.com/wp-content/uploads/2022/02/image-28.png" alt="GC Detail" class="wp-image-9120"/></a><figcaption>GC Detail</figcaption></figure></div>
<!-- /wp:image -->

<!-- wp:heading -->
<h2>Conclusion</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Jifa is a great tool to identify potential memory leaks, thread issues for Java applications. If you do not have the ability to install GUI based tools like MAT, VisualVM, or if you do not have high memory to process large dump files, then Jifa can help you. Jifa supports multiple sources to upload the dump/log file. Jifa user interface is intuitive and easy to navigate. But navigating tree structure is cumbersome. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>GC Log analysis in JIFA provides problems and suggestions. But for heap dump and thread dump, you need to wear a detective hat to troubleshoot the problems. </p>
<!-- /wp:paragraph -->