From: Philippe Waroquiers Date: Thu, 26 Jul 2012 21:37:36 +0000 (+0000) Subject: Improve suppression matching performance when fun or obj is a simple string X-Git-Tag: svn/VALGRIND_3_8_0~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90fa3850066ca739be3817d8b06e38eb7c3ec7bf;p=thirdparty%2Fvalgrind.git 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%. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12789 --- diff --git a/coregrind/m_errormgr.c b/coregrind/m_errormgr.c index 44976a804b..22f9a6e0df 100644 --- a/coregrind/m_errormgr.c +++ b/coregrind/m_errormgr.c @@ -211,6 +211,8 @@ typedef 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 @@ Bool VG_(get_line) ( Int fd, Char** bufpp, SizeT* nBufp, Int* lineno ) } +/* 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 @@ static Bool setLocationTy ( SuppLoc* p, Char *buf ) 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 @@ static void load_one_suppressions_file ( Char* filename ) // 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 @@ static Bool supp_pattEQinp ( void* supplocV, void* addrV ) /* 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); } /////////////////////////////////////////////////////