![]() |
Java Interactive Profiler |
TimeLineProfiler
-- threw an exception when
an exception was thrown in the program being profiled.
net.sourceforge.jiprof.instrument.clfilter.GenericClassLoaderFilter
,
which allows you to specify which class loader(s) to apply profiling to. This is done
by a new profile property: accept-class-loaders
, which is comma separated list
of fully qualified class or interface names. Allowing interface names comes in handy when dealing with
Tomcat where you might want to specify org.apache.catalina.loader.Reloader
rather than org.apache.catalina.loader.WebappClassLoader
. If
GenericClassLoaderFilter
is used, but no values are specified for
accept-class-loaders
, then the System Class Loader is used. Note also that
GenericClassLoaderFilter
will not defer to other Class Loader Filters.include
which allows you to explicitly specify
which classes or packages to include in the profile.
output-summary-only=yes
to the profile properties file.
/profile/timeline.profile.properites
)Object.wait
,
Thread.sleep
, Thread.join
or Thread.yeild
is not longer
counted as part of a method's net time. In addition any time spent waiting to enter a synchronized
block of code will also not be counted toward a method's net time.
Note to anyone who has built a custom profiler
class: your class will now be required to have two additional static methods:
public void beginWait(className, methodName)
and
public void endWait(className, methodName)
.synchronized, wait, sleep, join
and
yield
(as discussed above). This is shown in the output via W:START
and W:END
.output
to XML
(or both
).
output-method-signatures
.
Setting this to yes
causes JIP to include the signature
of a method, in addition to its name and package, in the output. For
compatability, the default value is no
.
...
START [9] ProjectComponent:getProject()Lorg/apache/tools/ant/Project; (org.apache.tools.ant)
END [9] ProjectComponent:getProject()Lorg/apache/tools/ant/Project; (org.apache.tools.ant)
START [9] Project:log(Lorg/apache/tools/ant/Task;Ljava/lang/String;I)V (org.apache.tools.ant)
Time: 3260 ms.
START [9] Project:fireMessageLogged(Lorg/apache/tools/ant/Task;Ljava/lang/String;I)V (org.apache.tools.ant)
ALLOC [9] BuildEvent (org.apache.tools.ant)
START [9] BuildEvent:(Lorg/apache/tools/ant/Task;)V (org.apache.tools.ant)
START [9] ProjectComponent:getProject()Lorg/apache/tools/ant/Project; (org.apache.tools.ant)
END [9] ProjectComponent:getProject()Lorg/apache/tools/ant/Project; (org.apache.tools.ant)
START [9] Task:getOwningTarget()Lorg/apache/tools/ant/Target; (org.apache.tools.ant)
END [9] Task:getOwningTarget()Lorg/apache/tools/ant/Target; (org.apache.tools.ant)
END [9] BuildEvent:(Lorg/apache/tools/ant/Task;)V (org.apache.tools.ant)
...
Ledgend:
profiler-class=net.sourceforge.jiprof.timeline.TimeLineProfiler
Notes on usage:
- output-method-signatures
can be used to display the full method signature.
clock-resolution
can be used to toggle the unit of time used to generate
the timeline. You can use either ms
for milliseconds or ns
for
nanoseconds. (Note that this property is not used by the standard profiler).
track.object.alloc=on|off
.
output
property is ignored.
net.sourceforge.jiprof.instrument.clfilter.JBossServletClassLoaderFilter
if you
only want to profile your Servlets.
net.sourceforge.jiprof.instrument.clfilter.JBossEJBClassLoaderFilter
for
profiling SessionBeans.
net.sourceforge.jiprof.instrument.clfilter.JBossUniversalClassLoaderFilter
for
profiling both Servlets and SessionBeans.
These should only be used interactively (i.e., profiler=off
, remote=on
). It is also
recommended that you exercise the code to be profiled at least once before you begin profiling.
ClassLoaderFilter
(com.mentorgen.tools.profile.instrument.clfilter.AntTaskClassLoaderFilter)
to allow profiling of code
from an Ant task that is runing in the same JVM that Ant is (thanks to Paul Hudson
for submitting this)ConcurrentModificationExceptions
.
Thanks Nathan for pointing this problem and submitting a patch!debug
flag in the profile properties file now produces additional
output. This includes reporting that an exception has been detected as well as
outputting the names of any methods that the profiler needed to "fixup".
Both of these pieces of information are quite useful in debugging potential
problems with JIP's output. Anyone who gets output from JIP that looks suspicious
is encouraged to include debugging information, if possbile, when reporting their
problem.NullPointerException
.ConcurrentModificationException
has been
fixed. A number of users reported that at the end of a profile they were
getting this exception. The worst part was that they also weren't getting
any output!.xml
and the output type was set to xml
or both
, the actual output file name was ending in
.xml.xml
.profile-properties
file
profiler-class=[your-profiler-class]
Your profiler doesn't need to implement any particular
interface, but rather it just needs to contain the same
methods as the default profiler
(com.mentorgen.tools.profile.runtime.Profile
)
JIP uses the ASM library to instrument bytecode. One of the libraries that Hibernate depends on uses an older version of ASM. Since JIP gets loaded before Hibernate, the newer version of ASM was taking precedent and causing Hibernate not to work.
JIP uses the ASM library to instrument bytecode. There was a compatability issue when using ASM 2.0 in conjuntion with code that was compiled with the AspectJ compiler. This has been fixed in the current version of ASM (2.2.1). This release of JIP uses the new version of ASM and now works with AspectJ compiled code.
When using interactive profiling, there were a couple of cases where the results of the profile had problems.
The fix for this introduces the idea of an interaction. In a webapp, a single thread could service multiple requests. What you'd like to see is each of these requests to have their own call graph and timings. This new unit of scope is called an interaction. There are few things to note about the way interactions behave:
+------------------------------
| Thread: 37
+------------------------------
...
+------------------------------
| Thread: 37 (interaction #2)
+------------------------------
...
+------------------------------
| Thread: 37 (interaction #3)
+------------------------------
interaction
that is sandwiched between the thread
element
and the frame
element. (my sincerest
apologies to anyone who
is integrating with JIP via the XML output
for changing the document structure.)The summary section of the profiler output was only summarizing (rolling up) items that appeared in the previous section. This might not be a complete picture since the output of the previous section can be limited via the profile properties.
The headings for sections 2 and 3 of the text file that JIP generates were confusing and generally not helpful. They have been update to read "Most expensive methods (by net time)" for the second section and "Most expensive methods summarized" for the third section.
docs
directory.src/client
.src/example-properties
.Important Note: The package forClassLoaderFilter
s has been changed fromcom.mentorgen.toos.profile
tocom.mentorgen.tools.profile.instrument.clfilter
. Please update your profile property files.
ExtensionsClassLoaderFiler
.debug
property
in the profile properties file. With this set to on
it's now possible to see which classes are being instrumented
for profiling and which are not. I did this because Tomcat
one day just started classloading my webapp with the wrong
classloader (this was using the Eclipse plugin — I'm not
sure if that had anything to do with it as I've not see this
behavior if I make a WAR file and start Tomcat manually)
With the debug flag set to on
it's possible to
spot this behavior.profile.txt
and the output type as both
you would end up with profile.txt.xml
. This has
been fixed. In the case above, you can name the file either
profile.txt
or just profile
and the files should be named correctly.yyyyMMdd-HHmmss
.output=[option]
Where option is
text
— the normal text output.xml
— output the raw profile
as an XML document.both
— output both text and
xml docs.text
.
com.mentorgen.tools.profile.Profile
setFileName
start
stop
clear
track.object.alloc=on
ClassLoaderFilter
interface.
This mechanism implements the chain of responsibility pattern.
The way that is works is that it will go through a number
of ClassLaoderFilters
until it finds one that will
work. For example, the default properties file has a
section that looks like:
ClassLoaderFilter.1=com.mentorgen.tools.profile.WebAppClassLoaderFilter
ClassLoaderFilter.2=com.mentorgen.tools.profile.StandardClassLoaderFilter
ClassNotFoundException
. The problem here had to do
with the Profiler being loaded with the application
classloader while some of the instrumented classes
where loaded by the extension classloader. This has
been fixed by only instrumenting classes that are
loaded by the application classloader for standalone
apps and Tomcat's webapp classloader for web applications.
Note that only Java 5 and Tomcat 5.5 are currently
supported. See the
classloader doc for more information<clinit>
)
that are called before a thread started to execute
were throwing off the call stack / profiler info.
This issue has been resolved in this release.include
option in the profile properties
is no longer supported. Now all classes that are loaded by the
application or webapp classes loader are included by default.
The exclude
is still available, so you can
filter out anything that you don't want to see.-Dprofile.properties=<file name>
example.bat
. It profiles
ANT
building the profiler.