国际物流云商系统day_第1页
国际物流云商系统day_第2页
国际物流云商系统day_第3页
国际物流云商系统day_第4页
国际物流云商系统day_第5页
已阅读5页,还剩31页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、JBOSS ProfilerPerformance ProfilingContentsMotivation The problemProfilingProfiling ToolsJava and ProfilingJBoss ProfilerExampleMotivationMore computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason - including blind stupidity. - Pro

2、f. William A. WulfWe should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. - Prof. Donald E. Knuth What is a profilerA program that helps you figure out where a program is spending most of its time. discover how it is using memory.how many

3、 of what sorts of object.What is a profiler toolTool used for program analysisprogram analysis is the use of specialized software, called a profiler, to gather data about a programs execution.The profiler is used to determine how long certain parts of the program take to executehow often they are ex

4、ecutedto generate the call graph (the mathematical graph of which functions call which other functions)Influental Profiler1982 Gprof: a Call Graph Execution Profileradding a stopwatch to each function (compile with pg flag with gcc, run program - gmon.out run gprof program analyses gmon.out)JProbeOp

5、timizeIT2004 gprof and appeared on the list of the 20 most influental PLDI (programming language design and implementation) of all timeMethods of data gatheringStatistical profilersSamplinga timer thread suspends all threads periodically (10ms)looks up the call stack of each threadProc: fastConst: h

6、ow many times was the method called cant deduce.InstrumentingProc: can potentially be very specificCons: can cause bugsslows down the target programHow can I performance profile my Java code?*java -prof MyClassExample A simple classpublic class Tomer public static void main(String args) System.out.p

7、rintln(hi there);Running the class with profilerA file f was created that containsc:tempjava -prof Tomerhi thereDumping CPU usage in old prof format . done.count callee caller time1032 java.lang.Math.max(II)I java.util.jar.JarFile.hasClassPathAttribute()Z 16729 java.lang.AbstractStringBuilde

8、r.append(C)Ljava/lang/AbstractStringBuilder; java.lang.StringBuffer.append(C)Ljava/lang/StringBuffer; 0506 java.io.Win32FileSystem.isSlash(C)Z java.io.Win32FileSystem.normalize(Ljava/lang/String;II)Ljava/lang/String; 0506 java.lang.String.charAt(I)C JVMPIJava Virtual Machine Profiler Interfacea two-

9、way function call interface between the Java virtual machine and an in-process profiler agentJVMPIjava -Xrunmyprofiler:heapdump=on,file=log.txt ToBeProfiledClassJVMPI Events * method enter and exit * object alloc, move, and free * heap arena create and delete * GC start and finish * JNI global refer

10、ence alloc and free * JNI weak global reference alloc and free * compiled method load and unloadshutdown JVMPI Events * thread start and end * class file data ready for instrumentation * class load and unload * contended Java monitor wait to enter , entered, and exit * contended raw monitor wait to

11、enter, entered, and exit * Java monitor wait and waitedJVMPI Events * monitor dump * heap dump * object dump * request to dump or reset profiling data * Java virtual machine initialization and ProfilersJprobe profilerOptimizeitCodeWarrior (IDE that has a profiler in it)JprofJinsightHpJMeterNumega an

12、d many moreHPROF SUNs JVM has a default implementation of JVMPI named HPROFHPROF is actually a JVM native agent library which is dynamically loaded through a command line option, at JVM startup, and es part of the JVM process. By supplying HPROF options at startup, users can request various types of

13、 heap and/or cpu profiling features from HPROF. The data generated can be in textual or binary format, and can be used to track down and isolate performance problems involving memory usage and inefficient code. The binary format file from HPROF can be used with tools such as HAT to browse the alloca

14、ted objects in the heap.Command used: javac -J-Xrunhprof:cpu=samples foo.java .HPROFCommand used: javac -J-Xrunhprof:cpu=samples foo.java .CPU SAMPLES BEGIN (total = 252378) Wed Oct 07 13:30:10 1998rank self accum count trace method 1 4.96% 4.96% 12514 303 sun/io/ByteToCharSingleByte.convert 2 3.18%

15、 8.14% 8022 306 java/lang/String.charAt 3 1.91% 10.05% 4828 301 sun/tools/java/ScannerInputReader. 4 1.80% 11.85% 4545 305 sun/io/ByteToCharSingleByte.getUnicode 5 1.50% 13.35% 3783 304 sun/io/ByteToCharSingleByte.getUnicode 6 1.30% 14.65% 3280 336 sun/tools/java/ScannerInputReader.read 7 1.13% 15.7

16、8% 2864 404 sun/io/ByteToCharSingleByte.convert 8 1.11% 16.89% 2800 307 java/lang/String.length 9 1.00% 17.89% 2516 4028 java/lang/Integer.toString 10 0.95% 18.84% 2403 162 java/lang/System.arraycopy.CPU SAMPLES ENDJVMPI Simple ImplGet the current thread cpu time with JVMPI#include / global jvmpi in

17、terface pointerstatic JVMPI_Interface *jvmpi_interface;extern C / profiler agent entry point JNIEXPORT jint JNICALL JVM_OnLoad(JavaVM *jvm, char *options, void *reserved) / get jvmpi interface pointer if (jvm-GetEnv(void *)&jvmpi_interface, JVMPI_VERSION_1) GetCurrentThreadCpuTime(); package dk.capg

18、emini.tc;public class JProf public static native long getCurrentThreadCpuTime();static System.loadLibrary(capjprof); JBOSS ProfilerIts based on a JVMPI agent written in Ccaptures the events from the JVM into binary log filesweb-application that analyzes thatJBoss-profiler its easier to configure tha

19、n most existing profilersJboss Profiler FeaturesYou can setup triggers for starting the data-event capturing Regular exclusion filters Find which objects still are alived Featuresmethod entry/exit (CPU and Time) object-alloc thread start/end class loading object-release InterceptorsJVMPI (which is b

20、eing converted to JVMTI) AOP we can focus excatly on what we need and instrumentate only the classes we would need to analyzeGetting Data into Production Environmentssleep mode select events for a finite number of methods Front-endsWEB application developing an ant integration which will generate re

21、ports that will extend functionality on JUnitInstallationNot a final moduleDownload it from CVS / SourceforgeCurrent version 1.0.0 published in february 05How it worksConfigure the parametersProfiler will stays sleeping until you send a weak-up signalAfter it starts, everything will be sent to .log.

22、gz filesAfter youve finished your test-case, you can send a stop signalusing the same method you used to send the weak-up signalHow it worksThe wake-up and stop signalkill -3 ctrl-break on windowsprofilerConsole that connects to its engine using a socketMbean Analyzing the datajboss-profiler.war ana

23、lyze your .log.gz. InstallationUnzip the jboss-profiler.tar.gzSee readme.txtWindows: put jbossInspector.dll in your PATHPOSIX: libjbossInspector.so in your LD_LIBRARY_PATHDeploy jboss-profiler.war (front-end for analysis)JBoss Profiler Getting Deep process information about applications after the application raninterceptor written in C that use JVM

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论