From c45c8308006833e80ffa7fa84e647cea44148de0 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Wed, 16 Mar 2022 13:32:36 +0000 Subject: bitbake: data_smart: Skip commonly accessed variables from variable data context lookup 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. (Bitbake rev: 1ae712635a2eef3ecbf541e1f7cc2eeb2f3799c9) Signed-off-by: Richard Purdie --- bitbake/lib/bb/data_smart.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py index 8d3825f398..ca78d84133 100644 --- a/bitbake/lib/bb/data_smart.py +++ b/bitbake/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) -- cgit v1.2.3-54-g00ecf