Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Explanation of Java -Xprof Output

Tags:

java

profiler

I am trying to interpret profiling output produced by specifying the -Xprof flag.

For my application I get profiling output like this:

 Flat profile of 8.34 secs (775 total ticks): main
  Interpreted + native   Method
 10.4%    66  +    12    java.lang.ClassLoader.defineClass1
  3.6%    27  +     0    java.nio.HeapCharBuffer.<init>
  2.5%     1  +    18    java.io.UnixFileSystem.getBooleanAttributes0
...
 74.4%   380  +   179    Total interpreted (including elided)
     Compiled + native   Method
  0.3%     0  +     2    java.util.jar.JarFile$1.hasMoreElements
  0.3%     0  +     2    org.reflections.vfs.ZipDir$1$1.computeNext
  0.1%     0  +     1    java.lang.Object.<init>
...
  1.7%     3  +    10    Total compiled
         Stub + native   Method
  7.5%     0  +    56    java.util.zip.ZipFile.getEntry
  4.7%     0  +    35    java.lang.Object.getClass
  3.2%     0  +    24    java.lang.System.arraycopy
...
 23.2%     0  +   174    Total stub
  Thread-local ticks:
  3.1%    24             Blocked (of total)
  0.7%     5             Class loader

For each thread. My question is what is the difference between Interpreted, Compiled, and Stub methods, what are Thread-local ticks, and what is the meaning of the + native column? Is there any canonical documentation for the -Xprof profiler? Googling Xprof has yielded little.

like image 763
qwwqwwq Avatar asked Aug 18 '15 22:08

qwwqwwq


People also ask

What is the output of Java compiler?

The most common form of output from a Java compiler is Java class files containing platform-neutral Java bytecode, but there are also compilers that output optimized native machine code for a particular hardware/operating system combination, most notably the now discontinued GNU Compiler for Java.

What is Java simple explanation?

Java is a widely used object-oriented programming language and software platform that runs on billions of devices, including notebook computers, mobile devices, gaming consoles, medical devices and many others. The rules and syntax of Java are based on the C and C++ languages.

What are the input and output functions in Java?

The InputStream is used to read data from a source and the OutputStream is used for writing data to a destination. Here is a hierarchy of classes to deal with Input and Output streams. The two important streams are FileInputStream and FileOutputStream, which would be discussed in this tutorial.


1 Answers

The only place where I have ever found information on tools like XProf is some (slightly older) paper-based Java books.

  • Interpreted + native: This figure shows the ticks used by the JVM while executing interpreted methods. The extra (+native) columns shows the native C methods that were called by these interpreted methods.
  • Compiled + native: This figure shows the ticks used by the methods that were already parsed by the JIT compiler. After running your program a while, most of your major consumers from the interpreted section should appear as "Compiled" as JIT will compile them.
  • Stubs + native: This figure is for JNI calls. This will likely to use the "native" column only as JNI is of course executed as a series of native calls.
  • Thread-local ticks: This is listed as "miscellaneous" other entries and was written somewhere that "should not raise concerns from performance optimization perspective". I am not sure how much we want to trust that, but XProf is really not a documented tool just as you stated above.
like image 154
Gergely Bacso Avatar answered Oct 22 '22 10:10

Gergely Bacso