From 263165db787b8c5ed00911e1e32011dc71f57aa6 Mon Sep 17 00:00:00 2001 From: Andreas Ziegler <andreas.ziegler@fau.de> Date: Fri, 15 Jul 2022 11:57:54 +0200 Subject: [PATCH] library: extract constant escaping and pattern construction from loop The pattern required for the lookup is constant over all iterations of the loop, so pull it out to avoid constructing it over and over again. This saves roughly 1.5 minutes for looking up 6000 traced probes during the analysis of a MariaDB system with containing 24000 local funcions across all ELF files. --- librarytrader/library.py | 4 ++-- scripts/running_analysis.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/librarytrader/library.py b/librarytrader/library.py index 9045a8a..9bbfa5b 100644 --- a/librarytrader/library.py +++ b/librarytrader/library.py @@ -1209,9 +1209,9 @@ class Library: def find_local_functions(self, requested_pattern): retval = set() + pattern_string = r'(.*\.c[c]?_|)' + re.escape(requested_pattern) for addr, names in self.local_functions.items(): - if any(re.fullmatch(r'(.*\.c[c]?_|)' + re.escape(requested_pattern), - name) for name in names): + if any(re.fullmatch(pattern_string, name) for name in names): retval.add(addr) return retval diff --git a/scripts/running_analysis.py b/scripts/running_analysis.py index 19203b3..a206e4a 100755 --- a/scripts/running_analysis.py +++ b/scripts/running_analysis.py @@ -193,6 +193,8 @@ class Runner(): return self.all_resolved_functions def _mark_extra_functions_as_used(self): + logging.info('Marking extra functions as used from \'%s\'', + self.args.used_functions) with open(self.args.used_functions, 'r') as infd: for line in infd: path, function = line.strip().split(':') -- GitLab