Subj : Re: performance of single mutex versus Read/write mutex: any numbers? To : comp.programming.threads From : Joe Seigh Date : Mon Oct 10 2005 07:09 pm Howard Hinnant wrote: > > This link might be helpful: > > http://home.twcny.rr.com/hinnant/cpp_extensions/rw_perf.html > > It contains demo test code which attempts to justify the use case for > read/write and even read/write/upgradable locks. Timing results for a > dual processor machine are presented. The link also describes a "lock > reduced" mutex which avoids locking an OS-based mutex if there is no > contention, although there is no code, just hand-waving. > > At best this paper should only convince you that perhaps it is worth the > trouble to code it up both ways and measure. > You're measuring whichever of the readers or writers takes longer. Plus the difference between the two can be dramatic. For example, if all the readers ran first real quick, what you end up measuring in effect is just the writers. You're better off just running one, e.g. the writers, for a fixed number of iterations, and running the other, the readers, as long as there are writers running. And then report (write|reads)/sec/thread instead of overall run time. Also, it would be nice to see a comparision with Posix rwlock. Just comparing against Posix mutex is too much apples and oranges. -- Joe Seigh When you get lemons, you make lemonade. When you get hardware, you make software. .