Getting started: Thread bottleneck detection

Thread bottlenecks such as contentions and deadlocks can slow your application or bring it to a halt. The Profiling and Logging perspective includes views and tools that can help you detect and resolve these thread problems.

You can use the following views to detect thread bottlenecks:

When working to detect thread bottlenecks, you often select profiling resources in the Profiling Monitor view.

You can also investigate thread bottlenecks using custom probes that you design in Probekit.

Collecting data for thread bottleneck detection

You can use the Thread Analysis profiling set to collect data about thread bottlenecks in your application.

Prerequisites:

To collect data:
  1. Click Run > Profile.
  2. On the Profiling page of the Profile dialog box, select the Thread Analysis profiling set.
  3. Click Profile to start your application.
  4. Exercise the parts of your application that you think are experiencing thread bottlenecks. Thread data is collected and recorded in a Thread Analysis profiling resource, which is displayed in the Profiling Navigator. You can now stop your application.

Using the Thread View, Call Stack View, and UML2 Sequence Diagram views for thread bottleneck detection

In the Thread View, you can see a thread execution history for all threads in your application, plus explicit indications of deadlocks and contentions. In the Call Stack View, you can see stack frames for all the threads of the selected profiling resources. In the UML2 Object Interactions view, you can see the sequence of calls during the profiling run.

To detect thread bottlenecks:
  1. Display the Thread View: Right-click the profiling resource for the data that you collected, and from the pop-up menu select Open With > Thread View.
  2. In the Thread View, look for vertical arrows between threads. Vertical arrows point from a thread that is requesting a lock to the thread that holds the lock. A single arrow indicates a thread contention where one thread is waiting for another thread to release a lock. Multiple arrows indicate a deadlock where the two threads belong to the same deadlock thread state.
  3. Identify the methods that were called at the time of the bottleneck. To identify the methods, perform the following steps:
    1. Find the name of the lock that the thread is waiting for. In the Thread View, pause the cursor over the thread at the location that is waiting for the lock. The name of the lock, as well as the name of the locking thread that is holding the lock, is displayed in the ToolTip.
    2. Right-click the Thread Analysis profiling resource in the Profiling Monitor view and click Open With > UML2 Object Interactions. The UML2 Object Interactions view shows the method invocations between the Java class instances.
    3. In the Thread View, position the Current Time indicator over the arrow for the request that you want to investigate. This synchronizes both the UML2 Object Interactions view and the Call Stack profiling resource in the Call Stack View. By default, the Current Time indicator is located at the left edge of the Thread View graph. To move this indicator, drag it to the new location or click the seconds time ruler in the Thread View.
  4. If available, display the source code that is responsible for holding the lock. To do this:
    1. Click the drop-down menu in the title bar of the Thread View and click Open Call Stack View.
    2. Right-click the most recent call in the Call Stack for the thread that is holding the lock and then click Open Source from the pop-up menu. Source code is available only if you are profiling a Java™ project that is currently open in the Java perspective. You can now make changes in your code to resolve the bottleneck.
  5. Profile your application again to verify that you have resolved the bottleneck.

For more information, read Detecting thread bottlenecks.

Using the Execution Flow and Execution Flow Table views

In these views, you can see different formats of the raw data on which the Thread View is based.

To use these views:
  1. To display the Execution Flow or Execution Flow Table view, select Window > Show View > Other; expand the Profiling and Logging entry in the Show View dialog box, and select the view that you want to display.
  2. In the Execution Flow and Execution Flow Table view, you can subtract the time attributed to profiling by selecting Compensated Time from the pop-up menu.

Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.