HPjmeter-like graphical tool to view -agentlib:hprof profiling output
Asked Answered
G

4

11

What tools are available to view the output of the built-in JVM profiler? For example, I'm starting my JVM with:

-agentlib:hprof=cpu=times,thread=y,cutoff=0,format=a,file=someFile.hprof.txt

This generates output in the hprof ("JAVA PROFILE 1.0.1") format.

I have had success in the past using HPjmeter to view these output files in a reasonable way. However, for whatever reason the files that are generated using the current version of the Sun JVM fail to load in the current version of HPjmeter:

java.lang.NullPointerException
    at com.hp.jmeter.f.jb.a(Unknown Source)
    at com.hp.jmeter.f.a.a(Unknown Source)
    at com.hp.c.a.j.z.run(Unknown Source)
Exception in thread "HPeprofDataFileReaderThread" java.lang.AssertionError: null pointer exception from loader
    at com.hp.jmeter.f.a.a(Unknown Source)
    at com.hp.c.a.j.z.run(Unknown Source)

(Why would they obfuscate the bytecode for a free product?!)

Two questions arise from this:

  1. Does anyone know the cause of this HPjmeter error? (EDIT: Yes--see below)
  2. What other tools exist to read hprof files? And why are there none from Sun (are there)?

I know the Eclipse TPTP and other tools can monitor JVMTI data on the fly, but I need a solution that can process the generated hprof files after the fact since the deployed machine only has a JRE (not a JDK) intalled.

EDIT: A very helpful HPjmeter developer replied to my question on an HP ITRC forum indicating that heap=dump needs to be included in the -agentlib options temporarily until a bug in HPjmeter is fixed. This information makes HPjmeter viable again, but I will still leave the question open to see if anyone knows of any other tools.

EDIT: As of version 4.0.00 of HPjmeter (available 05/2009) this bug has been fixed.

Gadoid answered 1/4, 2009 at 22:33 Comment(0)
F
6

Your Kit Java Profiler is able to read hprof snapshots (I am not sure if only for memory profiling or for CPU as well). It is not free but is by far the best java profiler I ever used. It presents the results in a clear, intuitive way and performs well on large data sets. The documentation is also pretty good.

Forebode answered 2/4, 2009 at 18:34 Comment(1)
It would appear from their documentation that they only support memory-related portions of the HPROF file: yourkit.com/docs/80/help/hprof_snapshots.jsp -- thanks for the reference, though; it looks like a good profiler.Gadoid
U
1

For viewing and analyzing the output of hprof=samples or hprof=cpu I have used PerfAnal with good results. The GUI is a bit spartan, but very useful.

PerfAnal is a free download (GPL, originally an example project in the book Java Programming on Linux). See this article:

http://www.oracle.com/technetwork/articles/javase/perfanal-137231.html

for more information and the download.

Normally you can just run

java -jar PerfAnal.jar hprof.java.txt

You may need to fiddle with -Xmx for large hprof files.

Unseasoned answered 5/10, 2010 at 8:51 Comment(0)
C
0

I am not 100% sure it'll work (it sounds like it will) and I am not sure it'll show it in the format you want... but have you thought about the VisualVM?

I believe it'll open up the resulting file.

Corrosion answered 1/4, 2009 at 23:19 Comment(4)
VisualVM apparently only loads "heap dump" information (not profiling data) out of hprof files and apppears to hang loading said file anyhow. Have you had success with this? I'm really looking for something >= HPJmeter that works :-)Gadoid
Unfortunately I haven't used it yet... just aware of it. Have you tried using Visual VM to do the profiling (but it sounds like you really want an offline viewer)?Corrosion
Yeah, there are certainly a variety of tools I could use to profile locally, but it would be nice to have something that could display the hprof files offline. HPJmeter is sooo close, if I could only get it to work. I wish they distributed the source code.Gadoid
@DavidCitron visualvm appears to hang if you open a format=a file but works ok with format=b but doesn't seem to understand cpu=samplesScevor
P
0

I have been using Eclipse Memory Analyzer for analyzing different performance problems successfully. First of all, install the tool as described in the project webpage in Eclipse.

After that, you can create a dump file knowing the pid of the jvm to be analyzed

jmap -dump:format=b,file=<filename>.hprof <jvm_pid> 

Then just import the .hprof file in eclipse. It has some automatic reports that try (for me they usually do not work) to point out which could be the possible problems.

Edit:

Answering the comment: You are right, it is more like a leak finder for Java. For performance problems, I have played with JRat for small projects. It shows time comsumed per method, number of times a method is called, hierarchy of calls, etc. The only problem is that as far as I know, it does not support .hprof files. To use it, yo need to execute your program adding a VM argument

-javaagent:<path>/shiftone-jrat.jar

This will generate a directory with the profile captured by the tool. Then, execute

 java -jar shiftone-jrat.jar

And open the trace. Even been a simple tool, I think it could be useful.

Plot answered 15/4, 2009 at 11:49 Comment(1)
I played with the MAT a while ago, but my recollection is that it only analyzes the HEAP DUMP portion of the hprof file, not the performance-profiling portion. Have they added that functionaliy?Gadoid

© 2022 - 2024 — McMap. All rights reserved.