[PATCH] Wrap the DEBUG checks in a "unlikely"

David Collier-Brown davec-b at rogers.com
Fri Dec 28 19:20:10 GMT 2007


> On 28/12/2007, Volker Lendecke <vl at samba.org> wrote:
> 
>>On my Laptop with some limited netbench runs this gains about 1.5% of
>>performance. When looking at the assembler output I would suspect the biggest
>>gain is by the fact that with this in place the calls to the debug functions is
>>moved to the function end, out of the way of the normal code paths. valgrind
>>tests pending I would suspect this to be much more cache friendly.
>>
>>Comments?
> 
James Peach wrote: 
> ISTR  doing this for IRIX giving betwen 2% and 5%. Compiler and
> architecture dependent, but definitely worthwhile.

Fred Weigel and I saw similar results on SPARC many moons ago,
but we didn't have an unlikely() to fix it with.

Specifically, we found setting the branch-taken prediction bit
for the branch around the debug code had no measurable effect!
A colleague with a hardware analyzer found that the slowdown
was from branching to an address which required filling a
new cache line, rather than the next one in a straight-line
sequence...

--dave
-- 
David Collier-Brown,         | Always do right. This will gratify
System Programmer and Author | some people and astonish the rest
davecb at spamcop.net           |                      -- Mark Twain
(416) 223-5943


More information about the samba-technical mailing list