Question

I am trying to reduce the lock contention on a particular code-path in my application. To identify code with high lock contention, I connect YourKit to my application and use the "Monitor" tab and see acquiring which locks have caused the thread I care about to block. My eventual aim is to have no red dots for this thread in the "Thread" tab in YK GUI.

Often the contention arises from read/read locking using an intrinsic lock, so those can be improved by using a ReentrantLock instead of the intrinsic lock. Indeed when I tried this, YourKit reported lower contention. Is that information reliable? Does YourKit report usage of ReentrantLock's correctly?

I am using YourKit 8.0.24 on Solaris 10 with Sun 1.6u18 32-bit JVM.

Was it helpful?

Solution

Looks like YourKit, as of now, does not report ReentrantLocks as blocked in the "Thread" tab.

OTHER TIPS

Instead of following a locking-approach try to design your application be lockfree. With volatile variables and the classes in java.util.concurrent you can often write algorithms that are lockfree and therefore have no lock contention.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top