Exercise 1.3: Identifying a thread bottleneck

Before you begin, you must complete Exercise 1.2 Collecting thread data.

Finding thread bottlenecks using the Thread View

The Thread View displays the status of all the threads in your application, and explicitly indicates thread deadlocks and contentions.

To find bottlenecks:

  1. In the Profiling Monitor, right-click the Profiling resource, and then click Open With > Thread View. The Thread View opens. It looks something like this:

    Screenshot of the Thread View showing the results for this profiling run, as described in the following text.

    The vertical arrows between threads are what interest us. An arrow indicates that one thread (the thread in which the arrow originates) is waiting for another thread (the thread to which the arrow is pointing) to release a lock. A double arrow indicates that two threads are in a  deadlocked state, both waiting for the other to release a lock.

  2. The arrows are too close to each other to be easily distinguished. To see them better, switch from the default linear time scale to a weighted time scale by clicking the Switch to Compressed Time Scale button . The Compressed Time Scale compresses the time segments during which no significant thread action occurs. The display changes to something like this:

    Screenshot showing the distribution of the arrows after the time scale is changed to 'Compressed.'

  3. Interpret the Thread View as follows:

    Soon after the program starts, four philo* threads are created, one after the other. Each thread runs for a short while and then makes a request for a lock. The requests are not successful. When the the first three lock requests fail, the threads enter a Waiting for Lock state. When the lock request for the fourth thread fails, deadlock occurs, and the display indicates that all four threads are in a Deadlocked state.

    The philo* threads are waiting for a lock from other philo* threads that are also waiting for a lock. In this case, we have a deadlock: The program reaches an impasse and cannot continue.
    Note: You can see specific information about lock requests, deadlocks, and other states by pausing your cursor over a particular thread segment. This displays a tool-tip that specifies, for example,  the name of a lock and identifies the thread that is holding the lock (the "Locking Thread").

  4. You can also see detailed information about thread segments in the Properties view. To display the view, select Windows > Show View > Properties. Select a thread segment to display its properties.

Now that you understand why this deadlock occurs, you are ready to begin Exercise 1.4: Resolving the thread bottleneck.

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