Adding hashtable debugging output (--debug=hash).
authorWayne Davison <wayned@samba.org>
Wed, 15 Oct 2008 14:49:14 +0000 (07:49 -0700)
committerWayne Davison <wayned@samba.org>
Wed, 15 Oct 2008 14:51:45 +0000 (07:51 -0700)
hashtable.c
options.c
rsync.h

index 1775a0b..b760003 100644 (file)
 
 struct hashtable *hashtable_create(int size, int key64)
 {
 
 struct hashtable *hashtable_create(int size, int key64)
 {
+       int req = size;
        struct hashtable *tbl;
        int node_size = key64 ? sizeof (struct ht_int64_node)
                              : sizeof (struct ht_int32_node);
 
        /* Pick a power of 2 that can hold the requested size. */
        if (size & (size-1) || size < 16) {
        struct hashtable *tbl;
        int node_size = key64 ? sizeof (struct ht_int64_node)
                              : sizeof (struct ht_int32_node);
 
        /* Pick a power of 2 that can hold the requested size. */
        if (size & (size-1) || size < 16) {
-               int req = size;
                size = 16;
                while (size < req)
                        size *= 2;
                size = 16;
                while (size < req)
                        size *= 2;
@@ -43,11 +43,25 @@ struct hashtable *hashtable_create(int size, int key64)
        tbl->node_size = node_size;
        tbl->key64 = (short)key64;
 
        tbl->node_size = node_size;
        tbl->key64 = (short)key64;
 
+       if (DEBUG_GTE(HASH, 1)) {
+               char buf[32];
+               if (req != size)
+                       snprintf(buf, sizeof buf, "req: %d, ", req);
+               else
+                       *buf = '\0';
+               rprintf(FINFO, "[%s] created hashtable %lx (%ssize: %d, keys: %d-bit)\n",
+                       who_am_i(), (long)tbl, buf, size, key64 ? 64 : 32);
+       }
+
        return tbl;
 }
 
 void hashtable_destroy(struct hashtable *tbl)
 {
        return tbl;
 }
 
 void hashtable_destroy(struct hashtable *tbl)
 {
+       if (DEBUG_GTE(HASH, 1)) {
+               rprintf(FINFO, "[%s] destroyed hashtable %lx (size: %d, keys: %d-bit)\n",
+                       who_am_i(), (long)tbl, tbl->size, tbl->key64 ? 64 : 32);
+       }
        free(tbl->nodes);
        free(tbl);
 }
        free(tbl->nodes);
        free(tbl);
 }
@@ -70,6 +84,11 @@ void *hashtable_find(struct hashtable *tbl, int64 key, int allocate_if_missing)
                tbl->size = size;
                tbl->entries = 0;
 
                tbl->size = size;
                tbl->entries = 0;
 
+               if (DEBUG_GTE(HASH, 1)) {
+                       rprintf(FINFO, "[%s] growing hashtable %lx (size: %d, keys: %d-bit)\n",
+                               who_am_i(), (long)tbl, size, key64 ? 64 : 32);
+               }
+
                for (i = size / 2; i-- > 0; ) {
                        struct ht_int32_node *move_node = HT_NODE(tbl, old_nodes, i);
                        int64 move_key = HT_KEY(move_node, key64);
                for (i = size / 2; i-- > 0; ) {
                        struct ht_int32_node *move_node = HT_NODE(tbl, old_nodes, i);
                        int64 move_key = HT_KEY(move_node, key64);
index 16b7fb3..1e5d45f 100644 (file)
--- a/options.c
+++ b/options.c
@@ -204,7 +204,7 @@ static const char *debug_verbosity[] = {
        /*2*/ "bind,cmd,connect,del,deltasum,dup,filter,flist,iconv",
        /*3*/ "acl,backup,deltasum2,del2,exit,filter2,flist2,fuzzy,genr,own,recv,send,time",
        /*4*/ "cmd2,deltasum3,del3,exit2,flist3,iconv2,own2,proto,time2",
        /*2*/ "bind,cmd,connect,del,deltasum,dup,filter,flist,iconv",
        /*3*/ "acl,backup,deltasum2,del2,exit,filter2,flist2,fuzzy,genr,own,recv,send,time",
        /*4*/ "cmd2,deltasum3,del3,exit2,flist3,iconv2,own2,proto,time2",
-       /*5*/ "chdir,deltasum4,flist4,fuzzy2,hlink",
+       /*5*/ "chdir,deltasum4,flist4,fuzzy2,hash,hlink",
 };
 
 #define MAX_VERBOSITY ((int)(sizeof debug_verbosity / sizeof debug_verbosity[0]) - 1)
 };
 
 #define MAX_VERBOSITY ((int)(sizeof debug_verbosity / sizeof debug_verbosity[0]) - 1)
@@ -273,6 +273,7 @@ static struct output_struct debug_words[COUNT_DEBUG+1] = {
        DEBUG_WORD(FLIST, W_SND|W_REC, "Debug file-list operations (levels 1-4)"),
        DEBUG_WORD(FUZZY, W_REC, "Debug fuzzy scoring (levels 1-2)"),
        DEBUG_WORD(GENR, W_REC, "Debug generator functions"),
        DEBUG_WORD(FLIST, W_SND|W_REC, "Debug file-list operations (levels 1-4)"),
        DEBUG_WORD(FUZZY, W_REC, "Debug fuzzy scoring (levels 1-2)"),
        DEBUG_WORD(GENR, W_REC, "Debug generator functions"),
+       DEBUG_WORD(HASH, W_SND|W_REC, "Debug hashtable code"),
        DEBUG_WORD(HLINK, W_SND|W_REC, "Debug hard-link actions"),
        DEBUG_WORD(ICONV, W_CLI|W_SRV, "Debug iconv character conversions (levels 1-2)"),
        DEBUG_WORD(OWN, W_REC, "Debug ownership changes in users & groups (levels 1-2)"),
        DEBUG_WORD(HLINK, W_SND|W_REC, "Debug hard-link actions"),
        DEBUG_WORD(ICONV, W_CLI|W_SRV, "Debug iconv character conversions (levels 1-2)"),
        DEBUG_WORD(OWN, W_REC, "Debug ownership changes in users & groups (levels 1-2)"),
diff --git a/rsync.h b/rsync.h
index a0f2d92..b000d96 100644 (file)
--- a/rsync.h
+++ b/rsync.h
@@ -1171,7 +1171,8 @@ extern short info_levels[], debug_levels[];
 #define DEBUG_FLIST (DEBUG_FILTER+1)
 #define DEBUG_FUZZY (DEBUG_FLIST+1)
 #define DEBUG_GENR (DEBUG_FUZZY+1)
 #define DEBUG_FLIST (DEBUG_FILTER+1)
 #define DEBUG_FUZZY (DEBUG_FLIST+1)
 #define DEBUG_GENR (DEBUG_FUZZY+1)
-#define DEBUG_HLINK (DEBUG_GENR+1)
+#define DEBUG_HASH (DEBUG_GENR+1)
+#define DEBUG_HLINK (DEBUG_HASH+1)
 #define DEBUG_ICONV (DEBUG_HLINK+1)
 #define DEBUG_OWN (DEBUG_ICONV+1)
 #define DEBUG_PROTO (DEBUG_OWN+1)
 #define DEBUG_ICONV (DEBUG_HLINK+1)
 #define DEBUG_OWN (DEBUG_ICONV+1)
 #define DEBUG_PROTO (DEBUG_OWN+1)