diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-12-03 12:10:05 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-12-03 12:44:49 +0000 |
commit | fca802187a2a30686a8a07d2b6b16a3e5716e293 (patch) | |
tree | b8b61ace84f1afba8f74d5304eb8e3c994210397 /lib/bb/codeparser.py | |
parent | 78ad15b669b9c7cde41f7bd1ab884c1d2e0db91b (diff) | |
download | bitbake-contrib-fca802187a2a30686a8a07d2b6b16a3e5716e293.tar.gz |
codeparser/data_smart: Optimise parsing speed
The previous "contains" changes caused a ~3% parsing speed impact.
Looking at the cause of those changes was interesting:
* Use of defaultdict was slower than just checking for missing entries
and setting them when needed.
* Even the "import collections" adversely affects parsing speed
* There was a missing intern function for the contains cache data
* Setting up a log object for each variable has noticeable overhead
due to the changes in the code paths uses, we can avoid this.
* We can call getVarFlag on "_content" directly within VariableParse
for a noticeable speed gain since its a seriously hot code path.
This patch therefore tweaks the code based on the above observations to
get some of the speed back.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/codeparser.py')
-rw-r--r-- | lib/bb/codeparser.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/bb/codeparser.py b/lib/bb/codeparser.py index 6e34eff99..62b6cf9e3 100644 --- a/lib/bb/codeparser.py +++ b/lib/bb/codeparser.py @@ -1,7 +1,6 @@ import ast import codegen import logging -import collections import os.path import bb.utils, bb.data from itertools import chain @@ -65,6 +64,8 @@ class CodeParserCache(MultiProcessCache): for h in data[0]: data[0][h]["refs"] = self.internSet(data[0][h]["refs"]) data[0][h]["execs"] = self.internSet(data[0][h]["execs"]) + for k in data[0][h]["contains"]: + data[0][h]["contains"][k] = self.internSet(data[0][h]["contains"][k]) for h in data[1]: data[1][h]["execs"] = self.internSet(data[1][h]["execs"]) return @@ -125,6 +126,8 @@ class PythonParser(): if isinstance(node.args[0], ast.Str): varname = node.args[0].s if name in self.containsfuncs and isinstance(node.args[1], ast.Str): + if varname not in self.contains: + self.contains[varname] = set() self.contains[varname].add(node.args[1].s) else: self.references.add(node.args[0].s) @@ -153,10 +156,10 @@ class PythonParser(): def __init__(self, name, log): self.var_execs = set() - self.contains = collections.defaultdict(set) + self.contains = {} self.execs = set() self.references = set() - self.log = BufferedLogger('BitBake.Data.%s' % name, logging.DEBUG, log) + self.log = BufferedLogger('BitBake.Data.PythonParser', logging.DEBUG, log) self.unhandled_message = "in call of %s, argument '%s' is not a string literal" self.unhandled_message = "while parsing %s, %s" % (name, self.unhandled_message) |