Give statistics about RCEC helgrind hash table chains.
Improve statistic in coregrind hash table
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15141 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/m_hashtable.c b/coregrind/m_hashtable.c
index 3e52235..3b6c72d 100644
--- a/coregrind/m_hashtable.c
+++ b/coregrind/m_hashtable.c
@@ -320,8 +320,11 @@
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]));
}
diff --git a/helgrind/libhb_core.c b/helgrind/libhb_core.c
index dca8774..1b2c7dc 100644
--- a/helgrind/libhb_core.c
+++ b/helgrind/libhb_core.c
@@ -911,10 +911,10 @@
*fixp = (Word)i;
return;
}
- }
+ }
- /*NOTREACHED*/
- tl_assert(0);
+ /*NOTREACHED*/
+ tl_assert(0);
}
@@ -6159,6 +6159,40 @@
(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 );