Contribution: Lock Contention Profiler for HotSpot

Peter Hofer peter.hofer at
Fri Nov 4 12:59:58 UTC 2016

Hi Aaron,

On 11/04/2016 12:31 PM, Aaron Grunthal wrote:
> I think for lock contention the distribution of the blocking time is
> of interest. Can the profiler show that or just the cumulative time?
> Most profilers only record the sum, which is useful for optimizing
> throughput bottlenecks, but when optimizing for latency the CDF also
> is of interest since some methods can have vastly different average
> and worst case behaviors which can get obscured in the averages.

Our visualization tool currently shows only the cumulative contention
times for each stack trace, lock, lock class, thread, or any combination
of those aspects.

However, individual blocking times could be computed from the events
that the profiler records. These times could also be computed from the
lock owner thread's perspective, i.e., the time from when the owned lock
becomes contended until the thread releases the lock.

Individual blocking times would only work well for monitors (and native
monitors) though. With java.util.concurrent locks, we observe individual
park()/unpark() calls. A thread that cannot acquire a lock may call
park() more than once, and we cannot distinguish this from when a thread
tries to acquire a lock multiple times and calls park() once each time.
We would likely need bytecode instrumentation to group multiple park()
calls that are part of a single lock acquisition and use the duration
from the first park() call to the return of the last park() call as the
blocking time.


> On 04.11.2016 11:00, Peter Hofer wrote:
>> Hello everyone,
>> we are researchers at the University of Linz and have worked on a
>> lock contention profiler that is built into HotSpot. We would like
>> to contribute this work to the OpenJDK community.
>> Our profiler records an event when a thread fails to acquire a
>> contended lock and also when a thread releases a contended lock. It
>> further efficiently records the stack traces where these events
>> occur. We devised a versatile visualization tool that analyzes the
>> recorded events and determines when and where threads _cause_
>> contention by holding a contended lock. The visualization tool can
>> show the contention by stack trace, by lock, by lock class, by
>> thread, and by any combination of those aspects.
>> [...]

More information about the hotspot-dev mailing list