Showing posts with label .Net Performance. Show all posts
Showing posts with label .Net Performance. Show all posts

Tuesday, April 15, 2008

ReaderWriterLockSlim Performance - Is it really so slim??!!!

Hi,
On the .NET 3.5 Microsoft came up with new object named ReaderWriterLockSlim in order to achieve synchronised access to shared resources and also to improve the profermance issues that the old object (System.Threading.ReaderWriterLock) has.

Pedram Rezaei's wrote on his blog great post on Performance Comparison of ReaderWriterLockSlim.
On his performance tests he found that ReaderWriterLockSlim object is slower then the Monitor object.

Pedram Rezaei's conclusion:
"A reader-writer lock allows for multiple concurrent reads to enter a read-lock all at the same time and depending on the scenario, it can significantly improve the overall performance of your application when used instead of a mutual exclusive lock. A read-lock takes a shared lock and a write-lock takes an exclusive lock.

The new ReaderWriterLockSlim correctly gives priority to write requests therefore only use when reads are frequent and writes are less common."

You can take a look on his post here: A Performance Comparison of ReaderWriterLockSlim with ReaderWriterLock