tietang / javamelody

Automatically exported from code.google.com/p/javamelody
0 stars 1 forks source link

Add CPU sampling profiler #149

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is a contribution to the "add a sampling CPU profiler" from the TODO list 
#10.
The attached files comes from MessAdmin (http://messadmin.sourceforge.net). 
There are some references to i18n and date/time utility classes not included 
here, but which you can easily replace with your own.

I hereby give permission to Emeric Vernat to use, copy, modify this code as he 
sees fit, including placing it under the same license as JavaMelody uses.

Original issue reported on code.google.com by cedrik.l...@gmail.com on 6 Oct 2011 at 9:10

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks, it looks good. I will try it.

But is it needed to ignore all those threads and packages in prof.jsp if 
threads with state != runnable are already ignored in SamplingProfiler?

(Note to myself: Would it be better to count individually the first 
StackTraceElement(s) in the stack-traces?)

Original comment by evernat@free.fr on 8 Oct 2011 at 8:18

GoogleCodeExporter commented 9 years ago
In the monitoring reports, the new *Hotspots* screen displays CPU hotspots in 
executed methods for all the JVM. Like javamelody, the overhead of hotspots is 
low: it is based on sampling of stack-traces of threads, without 
instrumentation. And like javamelody, it is made to be always active if 
enabled. (It is currently not enabled by default. It may be enabled by default 
in the future.) Two parameters can be defined in web.xml, in context or in 
system properties like other javamelody parameters:

    * "sampling-seconds" to enable the sampling and to define its period. A period of 10 seconds can be recommended to have the lowest overhead, but then a few hours may be needed to have significant results for a webapp under use. If you don't mind having more overhead or want a result faster in test, you can use a value of 1 or 0.1 in second for this parameter.
    * "sampling-excluded-packages" to change the list of excluded packages ("java,sun,com.sun,javax,org.apache,org.hibernate,oracle,org.postgresql,org.eclipse" by default)

It is committed in trunk (revision 3470) and ready for the next release (1.47).

If you want to test it, you can download a build from trunk:
https://javamelody.googlecode.com/files/javamelody-20130818.jar

Thanks Cédric for your ideas and code. The committed code is a bit different 
(revision 3470 and next revisions) than the attached files. In particular, 
there is no String concat in the sampler to know if a package is excluded and 
there is no autoboxing of counts.

Original comment by evernat@free.fr on 18 Aug 2013 at 12:58