[1/3] data_smart: Skip commonly accessed variables from variable data context lookup

Message ID 20220317122225.996597-1-richard.purdie@linuxfoundation.org
State Accepted, archived
Commit 1ae712635a2eef3ecbf541e1f7cc2eeb2f3799c9
Headers show
Series [1/3] data_smart: Skip commonly accessed variables from variable data context lookup | expand

Commit Message

Richard Purdie March 17, 2022, 12:22 p.m. UTC
The code tries to expand missing entities when they're encountered in
python expressions. Looking at traces, these are often things which
would not be in the data store such as "bb".

Optimise to skip the data store queries for things we know will never
be there. The expansion cache usually covers these but skipping
entirely cuts a few million function calls parsing OE-Core.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/data_smart.py | 3 +++
 1 file changed, 3 insertions(+)

Patch

diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
index 8d3825f398..ca78d84133 100644
--- a/lib/bb/data_smart.py
+++ b/lib/bb/data_smart.py
@@ -152,6 +152,9 @@  class DataContext(dict):
         self['d'] = metadata
 
     def __missing__(self, key):
+        # Skip commonly accessed invalid variables
+        if key in ['bb', 'oe', 'int', 'bool', 'time', 'str', 'os']:
+            raise KeyError(key)
         value = self.metadata.getVar(key)
         if value is None or self.metadata.getVarFlag(key, 'func', False):
             raise KeyError(key)