[SCM] Samba Shared Repository - branch v3-2-test updated - initial-v3-2-unstable-920-g51448a9

Volker Lendecke vl at samba.org
Thu Dec 27 19:16:26 GMT 2007


The branch, v3-2-test has been updated
       via  51448a9dca95de9d35dd8eea68fde2554cb69921 (commit)
      from  e86d027823c85173c64e7b85406e98f6f7345b10 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit 51448a9dca95de9d35dd8eea68fde2554cb69921
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Dec 27 17:41:19 2007 +0100

    Wrap the DEBUG checks in a "unlikely"
    
    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?
    
    Volker

-----------------------------------------------------------------------

Summary of changes:
 source/include/debug.h |   27 +++++++++++++++++++++------
 1 files changed, 21 insertions(+), 6 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/include/debug.h b/source/include/debug.h
index 46e5620..41d1c82 100644
--- a/source/include/debug.h
+++ b/source/include/debug.h
@@ -161,9 +161,24 @@ extern bool *DEBUGLEVEL_CLASS_ISSET;
  * will remove the extra conditional test.
  */
 
+/*
+ * From talloc.c:
+ */
+
+/* these macros gain us a few percent of speed on gcc */
+#if (__GNUC__ >= 3)
+/* the strange !! is to ensure that __builtin_expect() takes either 0 or 1
+   as its first argument */
+#define likely(x)   __builtin_expect(!!(x), 1)
+#define unlikely(x) __builtin_expect(!!(x), 0)
+#else
+#define likely(x) x
+#define unlikely(x) x
+#endif
+
 #define DEBUGLVL( level ) \
   ( ((level) <= MAX_DEBUG_LEVEL) && \
-     ((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))||  \
+     unlikely((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))||  \
      (!DEBUGLEVEL_CLASS_ISSET[ DBGC_CLASS ] && \
       DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
    && dbghdr( level, DBGC_CLASS, __FILE__, FUNCTION_MACRO, (__LINE__) ) )
@@ -171,7 +186,7 @@ extern bool *DEBUGLEVEL_CLASS_ISSET;
 
 #define DEBUGLVLC( dbgc_class, level ) \
   ( ((level) <= MAX_DEBUG_LEVEL) && \
-     ((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))||  \
+     unlikely((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))||  \
      (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \
       DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
    && dbghdr( level, DBGC_CLASS, __FILE__, FUNCTION_MACRO, (__LINE__) ) )
@@ -179,7 +194,7 @@ extern bool *DEBUGLEVEL_CLASS_ISSET;
 
 #define DEBUG( level, body ) \
   (void)( ((level) <= MAX_DEBUG_LEVEL) && \
-           ((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))||  \
+           unlikely((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))||  \
            (!DEBUGLEVEL_CLASS_ISSET[ DBGC_CLASS ] && \
             DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
        && (dbghdr( level, DBGC_CLASS, __FILE__, FUNCTION_MACRO, (__LINE__) )) \
@@ -187,7 +202,7 @@ extern bool *DEBUGLEVEL_CLASS_ISSET;
 
 #define DEBUGC( dbgc_class, level, body ) \
   (void)( ((level) <= MAX_DEBUG_LEVEL) && \
-           ((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))||  \
+           unlikely((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))||  \
            (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \
 	    DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
        && (dbghdr( level, DBGC_CLASS, __FILE__, FUNCTION_MACRO, (__LINE__) )) \
@@ -195,14 +210,14 @@ extern bool *DEBUGLEVEL_CLASS_ISSET;
 
 #define DEBUGADD( level, body ) \
   (void)( ((level) <= MAX_DEBUG_LEVEL) && \
-           ((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))||  \
+           unlikely((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))||  \
            (!DEBUGLEVEL_CLASS_ISSET[ DBGC_CLASS ] && \
             DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
        && (dbgtext body) )
 
 #define DEBUGADDC( dbgc_class, level, body ) \
   (void)( ((level) <= MAX_DEBUG_LEVEL) && \
-          ((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))||  \
+          unlikely((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))||  \
            (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \
             DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
        && (dbgtext body) )


-- 
Samba Shared Repository


More information about the samba-cvs mailing list