ThreadMon
A Tool for Monitoring
Multithreaded Program Performance
Bryan Cantrill
Thomas Doeppner
Gregory Foxman
Department of Computer Science
Brown University
Providence, RI 02912-1910
Contents
- Program exploration
- Bottleneck analysis
- Processor-utilization analysis
- Thread-model-implementation analysis
- An MT program shows no speedup when moved from uniprocessor to multiprocessor
- Your carefully designed synchronization strategy exhibits miserable performance for no apparent reason
- Programs that run well most of the time behave poorly at key moments
NUM_MUTEXES = 12; NUM_THREADS = 16; . // each thread runs this function
mutex_t mut_set[NUM_MUTEXES]; .
. work_func() {
main() { .
setconcurrency(4); // 4 LWPs . for (int count = 0; count < ITERATIONS;
. count++) {
// create NUM_THREADS unbound . random_mutex =
// threads and tell them to work() . choose_random_mutex(mut_set);
.
for (int i = 0; i < NUM_THREADS; i++) { . mutex_lock(random_mutex);
thr_create(work_func); .
} . // count to a thousand
. for (int wait = 0; wait < 1000; wait++)
// wait for all threads to finish . ;
for (int i = 0; i < NUM_THREADS; i++) { .
thr_join(); . mutex_unlock(random_mutex);
} . }
} . }
- Multiply matrices on a 4-way MP
- How many threads? How many LWPs?
- Code from Programming with Threads, by Kleiman, Shah, and Smaalders
- Animated view of flow of air around the space shuttle
- Amount of detail in each frame depends on complexity of the frame and time permitted for computation and rendering
- Each object must be computed before it is rendered
- Computation takes place on available processors; rendering is single threaded and thus takes place on a single processor
- Compute and rendering times are predictable
- A schedule is computed to provide balanced use of the processors
- ThreadMon was a big aid in debugging the scheduler
- When should one use bound threads?
- ``common wisdom'' is to do so only if there is a need to take advantage of scheduling parameters of the underlying LWP
- Unbound threads work well if LWPs always have work to do
- ThreadMon shows that unbound threads are more expensive than bound threads if LWPs must be parked, unparked, then reassigned
- Real-time ThreadMon
- Scheduler-activations analysis
- JavaMon
- ClusterMon
- Scaling ThreadMon
Comments or questions to
Thomas W. Doeppner Jr.
Design and HTML by Peng Dai