|
From: <sv...@va...> - 2006-10-17 01:41:20
|
Author: sewardj
Date: 2006-10-17 02:41:17 +0100 (Tue, 17 Oct 2006)
New Revision: 6271
Log:
Merge r6134:
Accumulate statistics about the number of searches in the errors and
suppressions lists, and rearrange the suppressions list when searching
to reduce cost of future searches.
Modified:
trunk/coregrind/m_errormgr.c
Modified: trunk/coregrind/m_errormgr.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_errormgr.c 2006-10-17 01:40:33 UTC (rev 6270)
+++ trunk/coregrind/m_errormgr.c 2006-10-17 01:41:17 UTC (rev 6271)
@@ -68,7 +68,8 @@
static Error* errors =3D NULL;
=20
/* The list of suppression directives, as read from the specified
- suppressions file. */
+ suppressions file. Note that the list gets rearranged as a result
+ of the searches done by is_suppressible_error(). */
static Supp* suppressions =3D NULL;
=20
/* Running count of unsuppressed errors detected. */
@@ -82,6 +83,20 @@
=20
static ThreadId last_tid_printed =3D 1;
=20
+/* Stats: number of searches of the error list initiated. */
+static UWord em_errlist_searches =3D 0;
+
+/* Stats: number of comparisons done during error list
+ searching. */
+static UWord em_errlist_cmps =3D 0;
+
+/* Stats: number of searches of the suppression list initiated. */
+static UWord em_supplist_searches =3D 0;
+
+/* Stats: number of comparisons done during suppression list
+ searching. */
+static UWord em_supplist_cmps =3D 0;
+
/*------------------------------------------------------------*/
/*--- Error type ---*/
/*------------------------------------------------------------*/
@@ -532,9 +547,11 @@
construct_error ( &err, tid, ekind, a, s, extra, NULL );
=20
/* First, see if we've got an error record matching this one. */
- p =3D errors;
- p_prev =3D NULL;
+ em_errlist_searches++;
+ p =3D errors;
+ p_prev =3D NULL;
while (p !=3D NULL) {
+ em_errlist_cmps++;
if (eq_Error(exe_res, p, &err)) {
/* Found it. */
p->count++;
@@ -692,7 +709,7 @@
" </pair>",=20
su->count, su->sname);
} else {
- VG_(message)(Vg_DebugMsg, "supp: %4d %s", su->count, su->sname)=
;
+ VG_(message)(Vg_DebugMsg, "supp: %6d %s", su->count, su->sname)=
;
}
}
=20
@@ -818,6 +835,34 @@
/*--- Standard suppressions ---*/
/*------------------------------------------------------------*/
=20
+/* Get the next char from fd into *out_buf. Returns 1 if success,
+ 0 if eof or < 0 if error. */
+
+static Int get_char ( Int fd, Char* out_buf )
+{
+ Int r;
+ static Char buf[64];
+ static Int buf_size =3D 0;
+ static Int buf_used =3D 0;
+ vg_assert(buf_size >=3D 0 && buf_size <=3D 64);
+ vg_assert(buf_used >=3D 0 && buf_used <=3D buf_size);
+ if (buf_used =3D=3D buf_size) {
+ r =3D VG_(read)(fd, buf, 64);
+ if (r < 0) return r; /* read failed */
+ vg_assert(r >=3D 0 && r <=3D 64);
+ buf_size =3D r;
+ buf_used =3D 0;
+ }
+ if (buf_size =3D=3D 0)
+ return 0; /* eof */
+ vg_assert(buf_size >=3D 0 && buf_size <=3D 64);
+ vg_assert(buf_used >=3D 0 && buf_used < buf_size);
+ *out_buf =3D buf[buf_used];
+ buf_used++;
+ return 1;
+}
+
+
/* Get a non-blank, non-comment line of at most nBuf chars from fd.
Skips leading spaces on the line. Return True if EOF was hit instead.=
=20
*/
@@ -828,17 +873,17 @@
while (True) {
/* First, read until a non-blank char appears. */
while (True) {
- n =3D VG_(read)(fd, &ch, 1);
+ n =3D get_char(fd, &ch);
if (n =3D=3D 1 && !VG_(isspace)(ch)) break;
- if (n =3D=3D 0) return True;
+ if (n <=3D 0) return True;
}
=20
/* Now, read the line into buf. */
i =3D 0;
buf[i++] =3D ch; buf[i] =3D 0;
while (True) {
- n =3D VG_(read)(fd, &ch, 1);
- if (n =3D=3D 0) return False; /* the next call will return True=
*/
+ n =3D get_char(fd, &ch);
+ if (n <=3D 0) return False; /* the next call will return True *=
/
if (ch =3D=3D '\n') break;
if (i > 0 && i =3D=3D nBuf-1) i--;
buf[i++] =3D ch; buf[i] =3D 0;
@@ -920,7 +965,7 @@
filename );
VG_(exit)(1);
}
- fd =3D sres.val;
+ fd =3D sres.res;
=20
# define BOMB(S) { err_str =3D S; goto syntax_error; }
=20
@@ -1137,18 +1182,45 @@
static Supp* is_suppressible_error ( Error* err )
{
Supp* su;
+ Supp* su_prev;
=20
+ /* stats gathering */
+ em_supplist_searches++;
+
/* See if the error context matches any suppression. */
+ su_prev =3D NULL;
for (su =3D suppressions; su !=3D NULL; su =3D su->next) {
- if (supp_matches_error(su, err) &&
- supp_matches_callers(err, su))
- {
+ em_supplist_cmps++;
+ if (supp_matches_error(su, err) && supp_matches_callers(err, su)) =
{
+ /* got a match. Move this entry to the head of the list
+ in the hope of making future searches cheaper. */
+ if (su_prev) {
+ vg_assert(su_prev->next =3D=3D su);
+ su_prev->next =3D su->next;
+ su->next =3D suppressions;
+ suppressions =3D su;
+ }
return su;
}
+ su_prev =3D su;
}
return NULL; /* no matches */
}
=20
+/* Show accumulated error-list and suppression-list search stats.=20
+*/
+void VG_(print_errormgr_stats) ( void )
+{
+ VG_(message)(Vg_DebugMsg,=20
+ " errormgr: %,lu supplist searches, %,lu comparisons during search=
",
+ em_supplist_searches, em_supplist_cmps
+ );
+ VG_(message)(Vg_DebugMsg,=20
+ " errormgr: %,lu errlist searches, %,lu comparisons during search"=
,
+ em_errlist_searches, em_errlist_cmps
+ );
+}
+
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
|