|
From: <sv...@va...> - 2012-07-26 21:37:44
|
philippe 2012-07-26 22:37:36 +0100 (Thu, 26 Jul 2012)
New Revision: 12789
Log:
Improve suppression matching performance when fun or obj is a simple string
Idea is from Julian, possible bugs are mine.
If the fun or obj is a simple string and not a patter (so no *, no ?),
use a simple string comparison rather than a call to a wildcard matching.
On a leak search with a lot of reachable loss records and a lot of suppr,
it improves the speed of the leak search by 10 to 15%.
Modified files:
trunk/coregrind/m_errormgr.c
Modified: trunk/coregrind/m_errormgr.c (+23 -2)
===================================================================
--- trunk/coregrind/m_errormgr.c 2012-07-26 07:49:38 +01:00 (rev 12788)
+++ trunk/coregrind/m_errormgr.c 2012-07-26 22:37:36 +01:00 (rev 12789)
@@ -211,6 +211,8 @@
typedef
struct {
SuppLocTy ty;
+ Bool name_is_simple_str; /* True if name is a string without
+ '?' and '*' wildcard characters. */
Char* name; /* NULL for NoName and DotDotDot */
}
SuppLoc;
@@ -1103,6 +1105,18 @@
}
+/* True if s contains no wildcard (?, *) characters. */
+static Bool is_simple_str (Char *s)
+{
+ int i;
+ while (*s) {
+ if (*s == '?' || *s == '*')
+ return False;
+ s++;
+ }
+ return True;
+}
+
/* buf contains the raw name of a caller, supposedly either
fun:some_function_name or
obj:some_object_name or
@@ -1117,17 +1131,20 @@
if (VG_(strncmp)(buf, "fun:", 4) == 0) {
p->name = VG_(arena_strdup)(VG_AR_CORE,
"errormgr.sLTy.1", buf+4);
+ p->name_is_simple_str = is_simple_str (p->name);
p->ty = FunName;
return True;
}
if (VG_(strncmp)(buf, "obj:", 4) == 0) {
p->name = VG_(arena_strdup)(VG_AR_CORE,
"errormgr.sLTy.2", buf+4);
+ p->name_is_simple_str = is_simple_str (p->name);
p->ty = ObjName;
return True;
}
if (VG_(strcmp)(buf, "...") == 0) {
p->name = NULL;
+ p->name_is_simple_str = False;
p->ty = DotDotDot;
return True;
}
@@ -1198,6 +1215,7 @@
// Initialise temporary reading-in buffer.
for (i = 0; i < VG_MAX_SUPP_CALLERS; i++) {
tmp_callers[i].ty = NoName;
+ tmp_callers[i].name_is_simple_str = False;
tmp_callers[i].name = NULL;
}
@@ -1425,8 +1443,11 @@
/* So now we have the function or object name in caller_name, and
the pattern (at the character level) to match against is in
supploc->name. Hence (and leading to a re-entrant call of
- VG_(generic_match)): */
- return VG_(string_match)(supploc->name, caller_name);
+ VG_(generic_match) if there is a wildcard character): */
+ if (supploc->name_is_simple_str)
+ return VG_(strcmp) (supploc->name, caller_name) == 0;
+ else
+ return VG_(string_match)(supploc->name, caller_name);
}
/////////////////////////////////////////////////////
|