Filed in: Performance Tags: Performance score


This rule tracks .NET lock contentions, which refer to failed attempts by threads to acquire a lock because another thread is already holding it.

A high rate of lock contentions leads to wasted Cpu cycles due to spinlock processing, and elevated context switching overhead when threads begin to wait for the lock. It may also indicate that the application is experiencing significant processing delays due to lock waits.

Diagnostics

The contention diagnostics will identify the locks in your code that are experiencing contention. Each lock will show how many lock instances were present, the stack where the thread holding the lock was executing, and the stacks for threads waiting on the lock.



The stack trace of thread holding the lock indicates what the thread that is blocking the lock is doing (where it may be optimized to reduce lock hold time), and the stacks of the waiting threads show where other threads are blocking on the lock (where they can be optimized to avoid taking the lock).

Improving this score

To improve this score, reduce lock contentions.

There are many different methods for reducing locking. You can reduce the amount of time a lock is held to allow more threads to succeed in taking the lock without contention, reduce the number of threads acquiring the same lock, reduce the scope of the lock, or change the design of your code to fundamentally eliminate/reduce locking.

Proactive guidance

If you are on a Business plan, we may offer additional support to help you optimize your application, please contact support to find out more.




More resources


Want to learn the best techniques for managing your IIS web server? Join our how-to newsletter.
Want to get the best tool for troubleshooting and tuning your web apps? .

Build your skills


Get performance best practices straight from our IIS & ASP.NET experts:


How-to newsletter: 1-2 emails/week with expert IIS & ASP.NET tips.