My Photo

Become a Fan

DailyMile

Google Ad Skyscraper

« YourKit Java Profiler for the Mac, very good | Main | AMDs quad cores demonstrate trend towards lower core speeds »

September 03, 2007

Comments

Kasper Nielsen

Well, I know plenty of projects that uses stripped locking. EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap , for example, is what 6-7 years old?

Billy

Agreed,
I meant, described for everyone to see in articles etc. It's all obvious when you think about it. Doug has done great work for everyone over the years.

Billy

Although, when I was tuning ObjectGrid on the AZUL box I remember phoning Doug and asking him about why the RWLock wasn't using striping so I don't think we're talking about the same things here. Yes, a concurrent hash map probably uses an rw lock per bucket but I'm talking about using a set of rw locks per bucket which is different.

Kasper Nielsen

I'm not sure I get the point
------
This means instead of having a single RWLock, lets have say five. A thread can obtain a read lock by acquiring a read lock on any of the five. A thread can obtain a write lock only when it gets a write lock on all 5.
------
How is this different from a rw lock that allow multiple concurrent readers but only one exclusive writer, such as for example j.u.c.locks.ReentrantReadWriteLock

Billy

A single RW lock has a single critical section that is entered for granting either read or write locks. This single lock is a choke point in a wide processor/SMP. Using five RW locks provides five critical sections allowing five x the lock grant rate of a single lock.

Kasper Nielsen

That is not really true. A RW lock implementation does not necessarily need to have a critical section. j.u.c.locks.ReentrantReadWriteLock, for example, does not have a critical section.

The comments to this entry are closed.