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 help you detect and resolve these thread problems.

The following views are available for detecting thread bottlenecks:

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

 

Parent topic

Getting started with run-time problem determination

Collecting data for thread bottleneck detection

Prerequisites:

To collect data:

  1. In the Profiling tab of the Profile dialog box, select the Thread Analysis profiling set.

  2. Click Profile to start your application.

  3. 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 terminate your application.

Use the Thread View and UML2 Sequence Diagram views for thread bottleneck detection

The Thread View displays a thread execution history for all threads in your application, and explicitly indicates deadlock and contention situations. The UML2 Object Interactions view displays 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

    Arrows indicating lock requests between threads. An arrow points from a thread that is requesting a lock to the thread that holds the lock. A single arrow indicates a thread contention: one thread is waiting for another thread to release a lock. Multiple arrows indicate a deadlock if they show a circular lock-request pattern, in which threads prevent each other from running because they are waiting for each other to release a lock.

  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 tool-tip.

    2. Right-click the Thread Analysis profiling resource, and from the pop-up menu select Open With > UML2 Object Interactions.

    3. In the Thread View list of threads, select the thread that is holding the lock that you want to investigate. The UML2 Object Interactions view shows the selected thread’s object interactions, including the lock and requests for the lock.

    4. 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 Profiling Monitor. The Current Time indicator is located, by default, at the left edge of the Thread View graph. To move it, grab it with the mouse.

  4. Display the source code that is responsible for holding the lock, if it is available. To do this, right-click the most recent call in the Call Stack for the thread that is holding the lock, and then select 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.

Use the Execution Flow and Execution Flow Table views

These views display, in different formats, 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.