Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java application profiling

Tags:

I am looking for a Java code profiler which I can use to profile my application (its a service which runs in backend) on production (so means low over head, and it must not slow down my application). Primarily I want calling tree profiling, that is if a() calls b() and then b() calls c(), then how much time a() b() and c() took, both inclusively and exclusively.

Have seen jvisualvm and jprofiler, but this is not what I am looking for, because I cannot tie my production application to them as it will cause a major performance issue.

Also, I did go through metrics (https://github.com/dropwizard/metrics), but it does not give me a functionality to profile the calling tree.

Callgrind (http://valgrind.org/docs/manual/cl-manual.html) type library is what I need, as it gives calling tree profiling functionality and advanced options like avoiding calling cycles (recursion). But I am not sure that Callgrind can be used on production as it dumps data when program terminates.

Can anyone suggest good calling tree profiler for java that can be used on production without compromising the performance?

like image 419
Arry Avatar asked Mar 07 '14 12:03

Arry


People also ask

What is profiling Java application?

Profiling is the process of examining an application to locate memory or performance-related issues. When profiling a Java application, you can monitor the Java Virtual Machine (JVM) and obtain data about application performance, including method timing, object allocation and garbage collection.

What is profiling an application?

Software development teams are looking for solutions to improve application performance and gain visibility. Application profiling solutions enable the discovery of resources, baseline application performance, and visualization of component interaction through flow maps built on real-time data.

How do Java profilers work?

Sampling profilers work by periodically querying the JVM for all the running threads and getting the stack trace for each thread. It then determines what method each thread was executing when the sample was taken and compares the samples to determine how much time was spent in that method.

What is memory profiling in Java?

Memory profiling enables you to understand the memory allocation and garbage collection behavior of your applications over time. It helps you identify method calls in the context within which most memory was allocated and combine this information with the number of allocated objects.


2 Answers

Take a look at Java Mission Control in conjunction with Flight Recorder. Starting with the release of Oracle JDK 7 Update 40 (7u40), Java Mission Control is bundled with the HotSpot JVM, so it is highly integrated and purports to have small effects on run-time performance. I have only just started looking at it, and I do see some call tree functionality.

enter image description here

like image 200
kc2001 Avatar answered Oct 06 '22 00:10

kc2001


In general you don't (or I won't recommend) profilers that instrument your application. Instrumenting always means an uncontrollable production overhead.

What you can use is a sampling profiler. A sampling profiler makes a snapshot of the stack traces at a controllable interval. What you don't get is call counts, but, after some runtime, you get a good overview where you have hotspots. Since you can adjust the sample interval of the profiler you can influence the overhead of it.

A usable sampling profiler is shipped with the JDK, see the hprof page in the java 7 documentation. In former times there existed some graphical analysis tools for the hprof cpu traces (not the heap traces). Now they are gone. However, you can already work with the generated text file.

I took a quick look on the Java Mission Control stuff mentioned above. I think it is quite mighty and will satisfy a lot of needs, in the white paper they say it has only 2% overhead. However, it is not totally what I personally need or want. For my applications it is better to have a "light" profiling enabled all the time.

like image 42
cruftex Avatar answered Oct 05 '22 23:10

cruftex