[concurrency-interest] regarding StampedLock
dl at cs.oswego.edu
Mon Oct 15 14:38:19 EDT 2012
On 10/15/12 11:34, Dr Heinz M. Kabutz wrote:
> The performance results are interesting. Reading always outperforms the
> ReadWriteLock, distanceFromOriginV2() approach, which I believe is how I would
> write the code. It is the most elegant of the various options.
> To those who were asking, yes, the reading was always more efficient in my tests
> than ReadWriteLock (third last column in my spreadsheet - StampedLock /
> ReadWriteLock read ratio). In some cases it was almost 4000x faster in the
> uncontended case. That's a good reason to use it.
> However, the writing it appears is not always faster.
... mainly due to writer starvation. (In writer-only tests, they are
always faster.) In your tests, the reader blocks are so quick that
lots of them can get in and out before writer queuing
stabilizes so that phase-fair rules can kick in, at which point the writer
will often hit an expensive context switch and have the lock stolen away
while it is in the process of waking up. There are some mechanics for
reducing/avoiding this that I'll put it.
More information about the Concurrency-interest