Subj : Re: What is the real costs of LOCK on x86 multiprocesor machine? To : comp.programming.threads From : Peter Dimov Date : Sat Jul 30 2005 06:23 am David Schwartz wrote: > "Mirek Fidler" wrote in message > news:3kuqnuF10818jU1@individual.net... > >I am unable to find anwswer to above question. Only tidbit of information > >was that it is 100 cycles on P4, but perhaps that was just the worst case. > > > > Measuring the same on my uniprocesor AMD64 machine, LOCKed instructin seem > > to be 3 times slower than regular one, but I guess that has only a little > > relevance on real MP machine. > > On a p4, it's 100-200 clocks. In practice, the actual amortized cost appears to be much lower than 50-100x. I see a 4x difference on shared_ptr_timing_test (which basically tests reference count increments and decrements in a somewhat real-life worst case scenario.) A P4 can stall for 50 cycles without an apparent reason. ;-) .