Concurrency and Synchronization Metrics

Last updated: November 27, 2002

Optimizations focussing on multithreaded behaviour need to identify the appropriate opportunities. A basic requirement is to know whether a program does or can actually exhibit concurrent behaviour, or is it effectively single-threaded, executing one thread at a time. This affects the application of various optimization techniques, most obviously synchronization removal and lock design, but also the utility of other analyses that may be constrained by conservative assumptions in the presence of multithreaded execution (e.g., escape analysis).

Since the use of locks can have a large impact on performance in both single and multithreaded code, it is also useful to consider metrics that give more specific information on how locks are being used. A program, even a multithreaded one that does relatively little locking will obviously have a correspondingly reduced benefit from optimizations designed to reduce the cost of locking or number of locks acquired. Lock design and placement is also often predicated on knowing the amount of contention a lock experiences; this can also be exposed by appropriate metrics.

Concurrency Metrics

Identifying concurrent benchmarks involves determining whether more than one thread can be executing at the same time. This is not a simple quality to determine; certainly the number of threads started by an application is an upper bound on the amount of execution that can overlap or be concurrent, but the mere existence of multiple threads does not imply they can or will execute concurrently.

Ideally, one would run the program using a very large number of processors, so as many threads as possible could be scheduled simultaneously. Appropriate metrics would then include a single value such as maximum number of concurrently active threads, or a bin describing relative timings for discrete levels of concurrency. Unfortunately, with massive multiprocessor machines still uncommon this approach is somewhat infeasible in practice.

Back to Top

Lock Intensive Metrics

An important criterion in optimizing lock usage is to know whether a program does a significant number of lock operations. This is quickly seen from the single value metric of an average number of lock operations per execution unit (bytecode, or time). Continuous versions of the same would enable one to see if the locking behaviour is concentrated in one section of the program, or is specific to particular program phases.

Back to Top