From: Philippe Waroquiers Date: Sat, 25 Apr 2015 14:00:24 +0000 (+0000) Subject: Give statistics about RCEC helgrind hash table chains. X-Git-Tag: svn/VALGRIND_3_11_0~458 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0543df0e12cca167cfe62436000f6b3a0ea125de;p=thirdparty%2Fvalgrind.git Give statistics about RCEC helgrind hash table chains. Improve statistic in coregrind hash table git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15141 --- diff --git a/coregrind/m_hashtable.c b/coregrind/m_hashtable.c index 3e52235862..3b6c72d13d 100644 --- a/coregrind/m_hashtable.c +++ b/coregrind/m_hashtable.c @@ -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])); } diff --git a/helgrind/libhb_core.c b/helgrind/libhb_core.c index dca8774af0..1b2c7dcf62 100644 --- a/helgrind/libhb_core.c +++ b/helgrind/libhb_core.c @@ -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 );