]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Give statistics about RCEC helgrind hash table chains.
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 25 Apr 2015 14:00:24 +0000 (14:00 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 25 Apr 2015 14:00:24 +0000 (14:00 +0000)
Improve statistic in coregrind hash table

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15141

coregrind/m_hashtable.c
helgrind/libhb_core.c

index 3e52235862a4390096b4cd7dac925bd99235a160..3b6c72d13d1d61343c06fbcd504bd925ba7e93a1 100644 (file)
@@ -320,8 +320,11 @@ void VG_(HT_print_stats) ( const VgHashTable *table, HT_Cmp_t cmp )
       ncno += cno_occurences[i];
    }
    VG_(message)(Vg_DebugMsg, 
-                "total nr of unique   chains: %6d, keys %6d, elts %6d\n",
-                ncno, nkey, nelt);
+                "total nr of unique   slots: %6d, keys %6d, elts %6d."
+                " Avg chain len %3.1f\n",
+                ncno, nkey, nelt,
+                (Double)nelt/(Double)(ncno == cno_occurences[0] ?
+                                      1 : ncno - cno_occurences[0]));
 }
 
 
index dca8774af0aab0e57d9fe96b07edf261bd451f94..1b2c7dcf6255300b9b96017b8f9021a07673380a 100644 (file)
@@ -911,10 +911,10 @@ void alloc_F_for_writing ( /*MOD*/SecMap* sm, /*OUT*/Word* fixp ) {
          *fixp = (Word)i;
          return;
       }
-    }
+   }
 
-    /*NOTREACHED*/
-    tl_assert(0);
+   /*NOTREACHED*/
+   tl_assert(0);
 }
 
 
@@ -6159,6 +6159,40 @@ void libhb_shutdown ( Bool show_stats )
                    (UWord)N_RCEC_TAB,
                    stats__ctxt_tab_curr, RCEC_referenced,
                    stats__ctxt_tab_max );
+      {
+#        define  MAXCHAIN 10
+         UInt chains[MAXCHAIN+1]; // [MAXCHAIN] gets all chains >= MAXCHAIN
+         UInt non0chain = 0;
+         UInt n;
+         UInt i;
+         RCEC *p;
+
+         for (i = 0; i <= MAXCHAIN; i++) chains[i] = 0;
+         for (i = 0; i < N_RCEC_TAB; i++) {
+            n = 0;
+            for (p = contextTab[i]; p; p = p->next)
+               n++;
+            if (n < MAXCHAIN)
+               chains[n]++;
+            else
+               chains[MAXCHAIN]++;
+            if (n > 0)
+               non0chain++;
+         }
+         VG_(printf)( "   libhb: contextTab chain of [length]=nchain."
+                      " Avg chain len %3.1f\n"
+                      "        ",
+                      (Double)stats__ctxt_tab_curr
+                      / (Double)(non0chain ? non0chain : 1));
+         for (i = 0; i <= MAXCHAIN; i++) {
+            if (chains[i] != 0)
+                VG_(printf)( "[%d%s]=%d ",
+                             i, i == MAXCHAIN ? "+" : "",
+                             chains[i]);
+         }
+         VG_(printf)( "\n");
+#        undef MAXCHAIN
+      }
       VG_(printf)( "   libhb: contextTab: %lu queries, %lu cmps\n",
                    stats__ctxt_tab_qs,
                    stats__ctxt_tab_cmps );