[Nomen-dev] Cost of synchronization
Brought to you by:
bhurt
|
From: Brian H. <bh...@sp...> - 2002-03-29 23:33:39
|
Hmm. Just ran a curiosity test. Benchmark machine was a 1.4GHz P4, ~1% CPU utilization, Linux 2.4. I tested several things (the power of ifdefs): - An empty loop, to see how much overhead the loop itself took - An xorl $1, memory instruction - the above insturction with a lock prefix - an xchgl reg, memory instruction (which implicitly asserts LOCK#) The empty loop did one loop every about 1.5 clock cycles (this was gcc -O6, but I looked at the assembly language to make sure the loop was still there). The non-locked xorl took 15.3 clocks per loop, the locked xorl took 125.6 clocks per loop, the xchgl took 127.4 clocks per loop. You can throw a lock prefix on a usermode instruction, but it adds about 110 clocks onto the cost of the instruction- painfull! Lock elimination is going to be a very worthwhile endeavor. Brian |