dump_data() in lib/util.c wastes some CPU cycles

T. Paul Lee tpl at almaden.ibm.com
Fri Feb 16 22:11:59 GMT 2001


In the course of understanding stat_cache behavior under various
workload, I ran into something that's quite wasteful.
lib/util.c/dump_data( ) should check the DEBUGLEVEL before it proceeds
to do for loop (on the length of the data!) and all that great work for
nothing most of the time.  My cscope says that there are 80+ references
of this dump_data( ).  Luckily most of them are bracketed by #ifdef
DEBUGSOMETHING #endif .  Another definition in aparser/util.c and it
could be a problem there too.

I am using the 2.2.0 cvs as the base for the following patch and it is
pretty simple and no risk (to me :-).  I use the new debug.h file as
reference for the change.  It could be another macro in debug.h.  Here
is the "diff -u" output.

=====
--- util.c Fri Feb 16 13:37:38 2001
+++ /home/tpl/util.c Fri Feb 16 13:37:29 2001
@@ -1512,6 +1512,11 @@
 {
   unsigned char *buf = (unsigned char *)buf1;
   int i=0;
+
+  if (!((DEBUGLEVEL_CLASS[DBGC_CLASS] >= level) ||
+       (DEBUGLEVEL_CLASS[DBGC_ALL] >= level)))
+     return;
+
   if (len<=0) return;

   DEBUG(level,("[%03X] ",i));
=======
Cheers,
T. Paul Lee tpl at almaden.ibm.com





More information about the samba-technical mailing list