From: Philippe Waroquiers Date: Thu, 19 Jun 2014 20:33:27 +0000 (+0000) Subject: Improve/fix hash table collision statistics + remove useless space in gdbsrv hostvisi... X-Git-Tag: svn/VALGRIND_3_10_0~384 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bcd0b77c3bc8ba293f1e16a595249e6e2f40e871;p=thirdparty%2Fvalgrind.git Improve/fix hash table collision statistics + remove useless space in gdbsrv hostvisibility keywork git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14053 --- diff --git a/coregrind/m_gdbserver/server.c b/coregrind/m_gdbserver/server.c index 76e97dd36c..72d6660d3e 100644 --- a/coregrind/m_gdbserver/server.c +++ b/coregrind/m_gdbserver/server.c @@ -257,7 +257,7 @@ int handle_gdb_valgrind_command (char *mon, OutputSink *sink_wanted_at_return) wcmd = strtok_r (NULL, " ", &ssaveptr); switch (kwdid = VG_(keyword_id) ("vgdb-error debuglog merge-recursive-frames" - " gdb_output log_output mixed_output hostvisibility ", + " gdb_output log_output mixed_output hostvisibility", wcmd, kwd_report_all)) { case -2: case -1: diff --git a/coregrind/m_hashtable.c b/coregrind/m_hashtable.c index 38eb810a4d..5abea0a572 100644 --- a/coregrind/m_hashtable.c +++ b/coregrind/m_hashtable.c @@ -32,6 +32,7 @@ #include "pub_core_debuglog.h" #include "pub_core_hashtable.h" #include "pub_core_libcassert.h" +#include "pub_core_libcbase.h" #include "pub_core_libcprint.h" #include "pub_core_mallocfree.h" @@ -234,23 +235,21 @@ void* VG_(HT_gen_remove) ( VgHashTable table, void* node, HT_Cmp_t cmp ) void VG_(HT_print_stats) ( VgHashTable table, HT_Cmp_t cmp ) { #define MAXOCCUR 20 - UInt elt_occurences[MAXOCCUR]; - UInt key_occurences[MAXOCCUR]; - UInt cno_occurences[MAXOCCUR]; + UInt elt_occurences[MAXOCCUR+1]; + UInt key_occurences[MAXOCCUR+1]; + UInt cno_occurences[MAXOCCUR+1]; /* Key occurence : how many ht elements have the same key. elt_occurences : how many elements are inserted multiple time. cno_occurences : how many chains have that length. - The last entry in these arrays collects all occurences >= MAXOCCUR-1. */ - #define INCOCCUR(occur,n) (n >= MAXOCCUR ? occur[n-1]++ : occur[n]++) + The last entry in these arrays collects all occurences >= MAXOCCUR. */ + #define INCOCCUR(occur,n) (n >= MAXOCCUR ? occur[MAXOCCUR]++ : occur[n]++) UInt i; UInt nkey, nelt, ncno; VgHashNode *cnode, *node; - for (i = 0; i < 20; i++) { - key_occurences[i] = 0; - elt_occurences[i] = 0; - cno_occurences[i] = 0; - } + VG_(memset)(key_occurences, 0, sizeof(key_occurences)); + VG_(memset)(elt_occurences, 0, sizeof(elt_occurences)); + VG_(memset)(cno_occurences, 0, sizeof(cno_occurences)); // Note that the below algorithm is quadractic in nr of elements in a chain // but if that happens, the hash table/function is really bad and that @@ -307,16 +306,20 @@ void VG_(HT_print_stats) ( VgHashTable table, HT_Cmp_t cmp ) " N-plicated keys," " N-plicated elts\n"); nkey = nelt = ncno = 0; - for (i = 0; i < MAXOCCUR; i++) { - if (elt_occurences[i] > 0 || key_occurences[i] > 0 || cno_occurences[i] > 0) - VG_(message)(Vg_DebugMsg, - "N:%2d : nr chain %6d, nr keys %6d, nr elts %6d\n", - i, cno_occurences[i], key_occurences[i], elt_occurences[i]); + for (i = 0; i <= MAXOCCUR; i++) { + if (elt_occurences[i] > 0 + || key_occurences[i] > 0 + || cno_occurences[i] > 0) + VG_(message)(Vg_DebugMsg, + "%s=%2d : nr chain %6d, nr keys %6d, nr elts %6d\n", + i == MAXOCCUR ? ">" : "N", i, + cno_occurences[i], key_occurences[i], elt_occurences[i]); nkey += key_occurences[i]; nelt += elt_occurences[i]; ncno += cno_occurences[i]; } - VG_(message)(Vg_DebugMsg, "total nr of unique chains: %6d, keys %6d, elts %6d\n", + VG_(message)(Vg_DebugMsg, + "total nr of unique chains: %6d, keys %6d, elts %6d\n", ncno, nkey, nelt); }