[oe-commits] Richard Purdie : lib/oe/package_manager: Performance tweak in regex usage
git at git.openembedded.org
git at git.openembedded.org
Fri Feb 20 18:17:41 UTC 2015
Module: openembedded-core.git
Branch: master-next
Commit: 3aad1ce4b4a195c8feb52e41a0d9f5143639b31f
URL: http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=3aad1ce4b4a195c8feb52e41a0d9f5143639b31f
Author: Richard Purdie <richard.purdie at linuxfoundation.org>
Date: Fri Feb 20 17:41:41 2015 +0000
lib/oe/package_manager: Performance tweak in regex usage
Profiling a core-image-sato-sdk rootfs, we're spending over 40s
compiling the same regex over and over again, roughly around 5 million
times.
This is suboptimal, fix for a 40s improvement on a 18.5minute task execution
time.
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
meta/lib/oe/package_manager.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index f801333..69bef1d 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -679,10 +679,10 @@ class RpmPM(PackageManager):
def _search_pkg_name_in_feeds(self, pkg, feed_archs):
for arch in feed_archs:
arch = arch.replace('-', '_')
+ regex_match = re.compile(r"^%s-[^-]*-[^-]*@%s$" % \
+ (re.escape(pkg), re.escape(arch)))
for p in self.fullpkglist:
- regex_match = r"^%s-[^-]*-[^-]*@%s$" % \
- (re.escape(pkg), re.escape(arch))
- if re.match(regex_match, p) is not None:
+ if regex_match.match(p) is not None:
# First found is best match
# bb.note('%s -> %s' % (pkg, pkg + '@' + arch))
return pkg + '@' + arch
More information about the Openembedded-commits
mailing list