diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-12-20 13:22:19 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-12-22 00:02:05 +0000 |
commit | 0381b78aa4dfc0d338fba69502e8f03a0c0f21e7 (patch) | |
tree | 6d9a33949354cb9824c1a8fcabea1422ac692bb9 /bitbake/lib/bb/utils.py | |
parent | c61c1eb26a082c81473a45977cad5f811d2cf598 (diff) | |
download | poky-0381b78aa4dfc0d338fba69502e8f03a0c0f21e7.tar.gz |
bitbake: event/utils/methodpool: Add a cache of compiled code objects
With the addition of function line number handling, the overhead of
the compile functions is no longer negligible. We tend to compile
the same pieces of code over and over again so wrapping a cache around
this is beneficial and removes the overhead of line numbered functions.
Life cycle of a cache using a global like this is in theory problematic
although in reality unlikely to be an issue. It can be dealt with
if/as/when we deal with the other global caches.
(Bitbake rev: 98d7002d1dca4b62042e1589fd5b9b3805d57f7a)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r-- | bitbake/lib/bb/utils.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index e564bb6ff4..cd5fcede3c 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
@@ -298,10 +298,15 @@ def better_compile(text, file, realfile, mode = "exec", lineno = None): | |||
298 | will print the offending lines. | 298 | will print the offending lines. |
299 | """ | 299 | """ |
300 | try: | 300 | try: |
301 | cache = bb.methodpool.compile_cache(text) | ||
302 | if cache: | ||
303 | return cache | ||
301 | code = compile(text, realfile, mode, ast.PyCF_ONLY_AST) | 304 | code = compile(text, realfile, mode, ast.PyCF_ONLY_AST) |
302 | if lineno is not None: | 305 | if lineno is not None: |
303 | ast.increment_lineno(code, lineno) | 306 | ast.increment_lineno(code, lineno) |
304 | return compile(code, realfile, mode) | 307 | code = compile(code, realfile, mode) |
308 | bb.methodpool.compile_cache_add(text, code) | ||
309 | return code | ||
305 | except Exception as e: | 310 | except Exception as e: |
306 | error = [] | 311 | error = [] |
307 | # split the text into lines again | 312 | # split the text into lines again |