From: Jim Starkey Date: January 28 2009 7:38pm Subject: Re: Problems with record visibility and how it is computed List-Archive: http://lists.mysql.com/falcon/440 Message-Id: <4980B42F.5070409@nimbusdb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Olav Sandstaa wrote: >> >> There isn't much difference in cost between a lock(Shared)/unlock and >> addRef/release. Each requires a pair of interlocked instructions. > > Thanks for the clearification about the cost. I expected the interlock > instruction to be relatively cheaper than a shared lock. > > My performance testing suggests that on Intel and AMD, an interlocked CAS is cheaper than an interlocked increment or decrement. I suspect this is because the interlocked CAS is a single memory operation that either succeeds or fails in the memory controller while the interlocked increment (actually a "add 1 to memory") requires a memory bus lock while the processors fetches the operand, does the add, and writes it back. This further suggests that we might get some bang by replacing our interlocked increment and decrement with interlocked CASes. -- Jim Starkey President, NimbusDB, Inc. 978 526-1376