How To Spice Up Java With the VTune™ Performance Analyzer

For the entire article with figures and code samples please check out: /sites/default/files/article/149015/how-to-spice-up-java-with-the-vtune.pdf


by Levent Akyil

Software optimization is the process of improving software by eliminating bottlenecks so that it operates more efficiently on a given system and optimally uses resources. Identifying the bottlenecks in the target application and eliminating them appropriately is the key to efficient optimization. There are many optimization methodologies, which help developers answer the questions of why to optimize, what to optimize and how to optimize, and these methods aid developers in reaching their performance requirements. In this article, I’ll use a top-down approach and this means that I’ll start at a very high level, taking a look at the overall environment, and then successively drill down into more detail as I begin to tune the individual components within the system. This approach is targeted towards Java server applications, but can be applied to client applications as well.

Performance of the Java application in a nutshell depends on:

· the database and I/O configuration, if used;

· the choice of operating system;

· the choice of JVM and JVM parameters;

· the algorithms used;

· the choice of hardware



Performance tuning at micro-architecture level usually focuses on reducing the time it takes to complete a well-defined workload. Performance events can be used to measure the elapsed time; therefore, reducing the elapsed time of completing a workload is equivalent to reducing measured processor cycles (clockticks).

Intel® VTune™ Performance Analyzer is one of the most powerful tools available for software developers who are interested in this type of performance analysis. The easiest way to identify the hotspots in a given application is to sample the application with processor cycles, and VTune™ analyzer utilizes two profiling techniques, sampling and call graph, to help the developer identify where most of the clockticks are spent, in addition to many other processor events. The sampling can be in two forms: processor event based and time based sampling. Event based sampling (EBS) relies on the performance monitoring unit (PMU) supported by the processors. From this point forward, event based sampling (EBS) will be referred to as sampling.

In a compatible Java development environment, the VTune™ Performance Analyzer can be used to monitor and sample JIT-compiled Java code. The VTune analyzer gets the names of the active methods along with their load addresses, sizes, and debug information from the JVM and keeps this data in an internal file for later processing when viewing results. When your Java application executes, the Just-in-Time (JIT) compiler converts your VM bytecode to native machine code. Depending on your Java environment, either the VM or the JIT provides the VTune analyzer with information about active Java classes and methods, such as their memory addresses, sizes, and symbol information. The VTune analyzer uses this information to keep track of all the classes and methods loaded into memory and the processes that are executed. It also uses this information for final analysis. In summary, the VTune analyzer can identify performance bottlenecks, code emitted by the JIT Compiler (no bytecode support with EBS) and analyze the flow control.

Basically, there are two ways VTune Analyzer can analyze your Java application: VTune analyzer starts the JVM and the application to analyze or VTune analyzer starts the analysis without starting the application and user has to start application outside the VTune analyzer separately. The latter method is available only for sampling method and is useful to analyze applications such daemons, services, long running apps, etc.

The first and easiest way for VTune analyzer to analyze your application is to start it within VTune analyzer (Figure 6). VTune analyzer allows 3 types of applications or configuration: Application (.class or .jar), Script, and Applet. The following steps are showing how to setup VTune analyzer to analyze .class application.

· Start VTune™ Performance Analyzer.

· Click Sampling/Call Graph Wizard (please see following sections for more detail on these methods).

· Select Java Profiling.

· Select one of the following methods: Application (.class or .jar), Script, and Applet. We’ll assume application is selected for the following steps.

· Application: The VTune™ Performance Analyzer will launch a Java application. You must specify the Java launcher and the application.

· Script: A launching script invokes a specified Java application.

· Applet: The VTune analyzer invokes a Java applet. You must specify the applet viewer and applet.

· Select Java Launcher and enter any other special JVM arguments

· Select the main class or jar file. If there are any command line arguments used, enter them. Also select any component (.jar/directory) needed in the Classpath.

· Click Finish. The VTune analyzer will now launch application.


Sometimes, it is not possible or desired to start the Java application (e.g daemons, services, etc) with VTune analyzer however it is still possible to perform analysis on such applications (Figure 7).

· Start VTune™ Performance Analyzer.

· Click Sampling/Call Graph Wizard (please see following sections for more detail on these methods).

· Select Window*/Windows* CE/Linux Profiling. Uncheck Automatically generate tuning advice if selected.

· Check (Select)No application to launch.

· Check (select) Modify default configuration when done with wizard, and then click Finish.

· In Advanced Activity Configuration window, select Start data collection paused if it is not desired to start collection right away.

· Resume the collections before starting the application or during the application running.

· Start the application in the usual manner. Wait patiently for your software to complete and/or run your software until you have executed the code path(s) of interest.

Note 1: Selecting Window*/Windows* CE/Linux Profiling is not a mistake because this is the only option where we can tell VTune analyzer not to launch any application.

Note 2: If the Java application is executed outside the VTune analyzer then please make sure to pass correct argument to the JVM.

· For Java version 1.4.x, use -Xrunjavaperf

· For Java version 1.5 and higher, use "-agentlib:javaperf"


For Java applications (running on BEA, Sun or IBM JVMs), all the Java methods are combined and displayed as java.exe.jit on windows and java.jit on Linux in the Module view. You can view the individual methods and drill down to the Hotspot view by double-clicking it. The IBM and Sun JVMs use both interpretation mode and jitted mode of Java code execution. When sampling, only jitted code profiling is associated with the executing Java methods. When the JVM interprets the code, the samples are attributed to the JVM itself. You can use the call graph collector to obtain a complete view of all executed methods.

Again, for the entire article check out: /sites/default/files/article/149015/how-to-spice-up-java-with-the-vtune.pdf







Скачать how-to-spice-up-java-with-the-vtune.pdf1.7 МБ
Пожалуйста, обратитесь к странице Уведомление об оптимизации для более подробной информации относительно производительности и оптимизации в программных продуктах компании Intel.