5. JAVA Application Profiling
5
SNo Capability
1 Native Level
2 Running/Paused/Blocked Thread
3 Wait vs Read Time differentiation
4 Monitor or Lock Information
Performance Analyser Features
6. JAVA Application Profiling
6
SNo Type Description
1 Method Execution time of method
2 Memory Number, size and method of object allocation
Profile Types
7. JAVA Application Profiling
7
SNo Type Description
1 Profiler Tool that shows behavior of jvm java & native code
2 Profile File that contains information collected by Profiler
3 Overhead Time spent by the profiler collecting the profile information
4 Call Tree Listing of methods in a call stack
5 Filter Artifact that narrows scope of collected profile information
Terminology
8. JAVA Application Profiling
8
SNo Type Description
1 Experiment Artifact produced by collecting a profile of an application
2 collect Command line tool used to collect an experiment or profile by profiling and tracing function usage
3 Analyser GUI used to view collected experiment
4 er_print Command line tool used to view collected experiment
5 Inclusive time Time taken to execute a method and submethods
6 Exclusive time Time taken to execute a method excluding submethods
7 Attributed time Time attributed to a method
8 Caller Calee A relationship of a method either being called by some
method (a caller), or a method being called by some other method (a callee)
9 System CPU Elapsed execution time within operating system kernel
10 User CPU Elapsed execution time outside operating system kernel
Oracle Performance Analyser Terminology
9. JAVA Application Profiling
9
SNo Type Description
1 Instrumentation insertion of counters, timers into java byte code to be profiled
2 Heap The memory pool used by JVM for objects allocated with new keyword
3 Garbage
collection
Operation responsible for cleanup of unused java objects from Heap
4 Memory leak Unused object that cannot be collected due to one or more objects holding references
5 Self time The amount of time needed to execute the instructions in a method excluding submethods
6 Hot spot Method with large Self Time
7 Root method Method selected for performance profiling
NetBeans Profiler Terms
10. JAVA Application Profiling
10
Solaris Studio Performance Analyer
● Both Java & native code (Java,C,C++,Fortran)
● Method Profiling
● Monitor/Lock Profiling
11. JAVA Application Profiling
11
Solaris Studio Performance Analyer
1. Category - User CPU, System CPU, Lock contention
2. Within each Category - Inclusive Time & Exclusive Time
14. JAVA Application Profiling
14
Solaris Studio Performance Analyer
Collect Options
-o <experimentFile> Create experiment file name with specified name
-d <experimentDirectoryPath> Put Experiment file in specified directory
-p <option> (on| lo| hi) Frquency of sample collection (default 10ms)
-A <option> (on|off|copy) Application artifact archived or copied
-y <signal> Toggle data collection based on specifeid signal
-h <cpu counter> (Solaris) Specify cpu counter (ex cache miss,TLB miss etc.
20. JAVA Application Profiling
20
Solaris Studio Performance Analyer
View Collected Experiment
Analyzer GUI
SNo Icon Description
1 Open experiment File
2 Combine an experiment’s data to an existing experiment
3 Drop an experiment’s results from the experiments already
loaded
4 Collect an experiment
5 Print the listing of data currently displayed in the Analyzer
21. JAVA Application Profiling
21
Solaris Studio Performance Analyer
View Collected Experiment
Analyzer GUI
SNo Icon Description
6 Create a new Analyzer window with the same experiment file loaded in both windows
7 Close and exit the Analyzer GUI program
8 Modify the category of information to display
9 Filter the data presented
10 Show and/or hide APIs or methods
11 Switches to alternative viewing modes: User, Expert, Machine
22. JAVA Application Profiling
22
Solaris Studio Performance Analyer
View Collected Experiment
Analyzer GUI
SNo TabName Description
1 Summary Shows all the recorded metrics for the selected object, both as values and
percentages, and information on the selected object
2 Event Shows the available data for the selected Java method, source code line, or program
counter, including the event type, method name, LWP Id, threadId, and CPU Id
30. JAVA Application Profiling
30
Solaris Studio Performance Analyzer
View Collected Experiment
Analyzer GUI
Call Stack Fragment
Fragment Specific Metric
Next we will talk about java application profiling
Intrusive to responsiveness & throughput of application
Reactive - in response to production issue
Planned - specific performance requirements are known
Example of application profilers and the supported platforms
List of Performance Analyser features
Types of Profile
Description of profler terminology
Descrioption of oracle analyser terminology
Description of netbean profiler terminology
can be used to profile C, C++, and Fortran based applications
As a java profiler most useful as most useful as a method profiler and Java monitor/lock profiler
Data that is displayed in Performance Analyser
This slide shows the two distinct steps to profiling.
The first is collecting an experiment using the Performance Analyzer’s collect command
The second step, analysis, is viewing the collected experiment and analyzing its results with either the Performance Analyzer’s Analyzer GUI tool or er_print
Execution of the collect command results in generation of test.1er file in directory where this command is run
List of options to collect comand
This is an example of Delay profile data collection based on specified signal (application warmup)
two ways to view the collected data in the experiment file. One way is using the GUI, called the Analyzer, and the second way is using a command line tool called
er_print
The Analyzer can be launched with the name of the experiment to load. Assuming an experiment named test.1.er, the Analyzer loads the test.1.er experiment auto-
matically by executing the displayed command
View of the Open experiment dialog box
Default analyzer View
Analyzer Tool bar icon description
Analyzer Tool bar icon description
There are two tabs on the right panel of the default Analyzer GUI view, a Summary tab and Event tab. Information found on the Summary and Event tabs on the right panel are described above
Useful Tabs → Functions, Call Tree, Callers-Callees, Source, and Disassembly
The default view for the Functions tab lists inclusive and exclusive User CPU columns for Java methods in the Java application and orders the list of methods in decreasing order of exclusive User CPU time
The Call Tree tab shows the hierarchy of calls where an application spends its time. This view offers the ability to quickly recognize at a high level and
in what use case(s) an application spends most of its time
The time and percent shown at each node in the Call Tree is the cumulative time spent both in the method represented by the node and everything it calls
Identify method with highest percentage execution time among all the methods that consitute the total execution time
(As shown in this slide the render method has highest contribution to total time to execute of the paint method)
In this slide notice that the sum of attributed metrics for the callees and the selected method add up to the inclusive metric for the center method
In this slide notice that the sum of attributed metrics for the callers add up to the inclusive metric for the center method
In this slide notice that the add method can be used to create custom call stack fragment
In this slide notice that attributed metric for center method is updated once caller is added to the call stac/k fragment
This slide shows the use of the functions tab to identify hot methods
Complementary to using the Call Tree, is to analyze the experiment using the Functions tab and identifying the hottest methods in the applica-
tion. This approach focuses more on improving the implementation of a specific method.
(As shown in this slide Blit.Blit method is identified as a hot method)
This slide shows a description of analyzer tabs. Functions and Call Tree are the most useful are highlighted in green.
Description of analyser tabs continued
This slide shows difference between User Expert and Machine modes of view
Filter timeline to narrow investigation to specific time interval
This slide shows the usage of the er_print command.
The er_print command line utility prints an ASCII text version of the various displays found in the Performance Ana-
lyzer GUI such as method lists and callers-callees of User CPU, System CPU, and User Lock consumers
Er_Print command Syntax
---------------------------------------
The text between [ and ] means the arguments are optional. Text demarcated by | means any of the options can be used between the | characters. And text between
< and > means a name of a script or file that you have created is required, or an er_print command is required. When the -script option is not used, er_print
reads commands from the command line
This slide shows example usage of the er_print command to print the top 10 hottest methods sorted by exclusive user cpu time.
The limit command tells er_print to limit the number of methods printed with the functions command to the number
of methods given as an argument to the limit command
The csingle command prints the callers-callees of the method name passed as an argument to the csingle command
This slide shows example usage of the filter outfile and viewmode commands.
Filters command = limit the samples to specific interval, multiple intervals separated by comma
Outfile command = specify name of output file
Viewmode command = change to user,expert or machine mode
This slide lists the available metrics in analyzer
Next we will talk about the features of the netbeans profiler
Low Overhead : You can control the profiler’s performance impact on your application. Based on your selections, the performance impact ranges from extensive to none
CPU performance profiling: Time spent in every method of your application or just in selected methods can be reported
Memory profiling: You can check for excessive object allocations
Memory leak detection:The profiler’s statistical reports make it easy todetect object instances that are leaking
This slide shows the usage of the monitor tab in netbeans
Menu -->Attach Profiler-->Open Dialog Option View → Default Monitor allows thread and lock contention monitor with minimal overhead
This slide describes the default monitor view
Default monitor view displays live thread state and jvm memory information in telemetry overview panel as shown in this slide
This slide describes the steps to obtain a cpu profile
From Menu -->Attach Profiler-->Choose CPU option on the left and ensure default quick sample radio button is selected
This slide shows the location of the the Live Results View of the Profiler
This slide shows the function hotspots ordered in descending order of self time consumed
This slide shoes feature in netbeans profiler to take snapshot stack state
This slide shows the Call Tree View of the Snapshots View
Clicking on the the combined tab on the lower right shows both call tree and hot spot function as shown in this slide
This slide shows that by clicking a method in the Hot Spot list will find that method’s entry in the Call Tree making it easy to see the relationship between a method’s root and the hot spot
Next we look at the memory tab.
From Menu -->Attach Profiler-->Choose Memory option on the left and check the record full object lifecycle and record stack trace checkboxes.
This slide describes the avg age and generations tab of net beans profiler.
Avg. Age. Average age of the Live Objects. The age of each object is the num-
ber of garbage collections that it has survived. The sum of the ages divided by
the number of Live Objects is the Avg. Age.
Generations. Calculated using the Live Objects. The Generations value is the
number of different ages for the Live Objects.
An increasing value of generations is a sign of a memory leak
This slide show allocation call tree for an object
Click on Take Snapshot and Right Click Object to see the allocation stack trace ( Detailed breakup of the method which allocated object on heap)
This slide shows example of offline heap dump analysis in netbean profiler.
A binary heap dump is a snapshot of all the objects in the Java HotSpot VM at the time the heap dump is taken
Click Profile -> Load Heap Dump for offline analysis of Memory Dump file useful to troubleshoot OOMemory Error
Heap dump can be generated with jmap command
In this slide, the highlighted numbers show that 16.4% of total heap allocation is attributed to char[]