This page describes the Methods profiling mode.
The Methods profiling mode tracks methods call trees, execution times and invocations count if configured, enabling to measure and optimize application performance. Use this profiling mode if experiencing slow responses or optimizing algorithms for speed of execution. See First Profiling Session for details on starting a profiling session.
The Methods mode is designed to provide profiling data from all classes and methods without any initial setup. The profiling session is started by simply clicking the Profile or Attach button in toolbar. The other toolbar buttons are described in the Toolbar Buttons section.
- Pause live results allows to stop updating live results. Pressed automatically when a context menu is displayed for the profiling results.
- Update live results is enabled when the Pause live results is pressed, allows to manually update paused live results.
- Show delta/absolute values controls switching between absolute and incremental values.
- Forward calls shows/hides the Forward calls view (visible by default). See the Methods Views section for details.
- Hot spots shows/hides the Hot spots view (hidden by default). See the Methods Views section for details.
- Reverse calls shows/hides the Reverse calls view (visible by default). See the Methods Views section for details.
- Select threads shows a list of threads to be included/excluded from the displayed results. See the Selecting Threads section for details.
- Take snapshot saves the currently available profiling data to a file which can be reopened later for offline analysis or compared with another snapshot.
- Reset results clears the currently available profiling data, enabling to start collecting new data from a defined point.
- Take thread dump action takes snapshot of all threads in the profiled JVM including their call stacks and displays it in a separate view. See the Thread Dump chapter for details.
- Take heap dump action saves a snapshot of all objects currently stored in the heap memory in a .hprof format and optionally opens it in a heap viewer. See the Heap Dump chapter for details.
- Request garbage collection action requests garbage collection in the profiled JVM. There's no guarantee when or if at all the garbage collection will be performed. To make sure GC will be run, the action should be invoked several times.
There are the following three different views on the Methods data collected by the profiler:
- Forward calls view shows the methods execution tree, from a thread down to single method calls. The Self time node represents execution time of the method, without any outgoing calls.
- Hot spots view shows a flat list of methods without the incoming/outgoing context. If sorted by the Self Time, it can immediately uncover an obvious performance bottleneck.
- Reverse calls view shows a flat list of methods for each thread and a tree of all execution points of these methods, transitively. It helps to discover the right call tree affected by a slowdown.
The Methods views provide the following data columns, either shown by default or initially hidden:
- Name column shows name of the method or thread, or Self time in a tree table which represents the own method time without outgoing calls.
- Total Time column shows the total wall clock time of the method - the time between entering and exiting the method, including outgoing calls to other methods, including sleeps, waits, blocking IO etc.
- Total Time (CPU) column shows the total CPU time of the method - the time between entering and exiting the method, including outgoing calls to other methods, excluding sleeps, waits, blocking IO etc.
- Self Time column (Hot Spots only) shows the own wall clock time of the method - the time between entering and exiting the method, excluding outgoing calls to other methods, including sleeps, waits, blocking IO etc.
- Self Time (CPU) column (Hot Spots only) shows the own CPU time of the method - the time between entering and exiting the method, excluding outgoing calls to other methods, excluding sleeps, waits, blocking IO etc.
- Hits column shows the minimal number of invocations of this method. Internally the value describes how many times the sampling engine noticed the method as being executed, which can significantly differ from the real number of method invocations, based on sampling frequency and method self time.
- Invocations column shows the exact number of method invocations.
Tip: The columns can be displayed or hidden using the right corner button in the view header by clicking the dropdown arrow (or right clicking the header on Mac OS X). The relative value bar can be displayed or hidden for every column which displays a relative value by resizing the column.
By default results for all threads are displayed. By clicking the Select threads toolbar button it's possible to select just some threads and the methods executed by other threads won't be displayed in the results.
Initially the Show all threads option is selected, which means that resuls of all threads including any new threads started in future will be displayed. Deselecting this option clears all selected threads, enabling to quickly select one desired thread. Clicking a thread in the Select thread table also deselects the option, but keeps the other threads selected, which makes it easier to remove just one thread from the results.
Whenever the Show all threads option is not selected, the Merge selected threads becomes enabled. This option allows to merge methods executed from different threads into single call tree, making it easier to analyze profiling data from multiple worker threads etc.
Searching And Filtering Results
A method can be found in results using the Find stripe which opens by invoking the Find action in results context menu or IDE Edit menu or using the Ctrl+F keyboard shortcut. Values of the Name column are searched for the entered substring, optionally matching case if selected. Once a search has been performed, it can be repeated using the F3 or Shift+F3 shortcuts. Next appearance of the currently selected value of Name column can be found using the Ctrl+F3 shortcut. Based on the current Methods view, the following actions for searching selection are also available in results context menu: Find in Forward Calls, Find in Hot Spots and Find in Reverse Calls.
Collected results can be filtered using the Filter stripe which opens by invoking the Filter action in results context menu or using the Ctrl+G keyboard shortcut. Values of the Name column are filtered by the entered substring depending on the selected filter mode (Contains, Does Not Contain, Regular Expression), optionally matching case if selected. The toplevel thread nodes are always displayed, only the method nodes are filtered.
To cover various use cases of methods profiling the profiler offers four profiling modes with different profiling techniques and settings. The modes and settings can be changed in the Settings pane which is displayed by pressing the Settings switch in Profiler window toolbar.
Methods Profiling Modes
- All classes uses sampling and collects profiling data from methods of all classes. This mode is selected by default and doesn't require any additional configuration.
- Project classes uses sampling and collects data from methods of projects classes. This mode doesn't require any additional configuration.
- Selected classes uses bytecode instrumentation and collects data from methods of the defined classes. To use this mode, at least one class has to be selected for profiling. See the Selecting Classes And Methods For Profiling section for more information on selecting a class. See the Configuring Additional Options section for details on the additional settings.
- Selected methods uses bytecode instrumentation and collects data from the defined methods. To use this mode, at least one method has to be selected for profiling. See the Selecting Classes And Methods For Profiling section for more information on selecting a method. See the Configuring Additional Options section for details on the additional settings.
Selecting Classes And Methods For Profiling
Selected classes or methods instruct the profiler from where to start collecting the profiling data. Once a JVM executes a selected method or method of a selected class, the profiler starts collecting data of this method and all methods called by this method, transitively. The following ways can be used to select a class or method for instrumented profiling:
- Using the Select Class or Select Method dialog. The dialog allows to select one or several classes or methods from a project or .class/.jar file. It can be opened directly from the Methods Settings pane.
- From code editor. Java code editor provides Profile | Profile Class and Profile | Profile Method actions in its context menu.
- From Navigator. Java Navigator provides Profile | Profile Class and Profile | Profile Method actions in its context menu.
- From profiling results. Live or saved Methods results provide Profile Class and Method actions in its context menu. Also a special column Selected is available to select methods for profiling. The column can be displayed using the right corner button in the view header by clicking the dropdown arrow (or right clicking the header on Mac OS X).
Configuring Additional Options
Whereas the selected classes and methods instruct the profiler from where to start profiling, the additional options define where to stop collecting the profiling data in order to lower the overhead and keep the profiling data clear and focused. These options are available:
- Limit outgoing calls defines the maximum depth of methods in selected class' or method's call tree which will be profiled. Setting outgoing calls to 0 means that only the selected methods will be profiled. Methods called from these methods won't appear in the collected data and will be included in Self time of the selected methods. Setting outgoing calls to 1 means that the profiler will collect data from the selected methods and all methods directly called from these methods. The further calls won't appear in the collected data and will be included in Self time of the calling methods. Etc.
- Skip core Java classes option configures the profiler to not collect data from the core Java classes.
The Methods profiling mode, selected Classes/Methods and additional options can be changed at any time during a running profiling session. The changes are applied by clicking the Apply button on the right side of the settings area.
Tip: To provide even more control of what methods will be profiled there's a special mode with fully manual setup of profiled classes and instrumentation filter. See Features For Expert Users for details.