瀏覽代碼

bitbake: data_smart: Improve override history logging

Calling record() for each override alteration is slow. Since we now expand
overrides dynamically we don't have to record the log data at each alteration,
we can instead print it directly from the existing data stores at variable
history print time using the exact same data stores.

This massively improves performance of the data store when parsing
with bitbake -e for example, it will improve memory overhead as well.

The only downside is that VariableHistory has to poke into the datastore
for some of its data but that seems an acceptable tradeoff rather than
double caching.

(Bitbake rev: 100b447a161ef20fa559e39516cd32fa78e38262)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Richard Purdie 10 年之前
父節點
當前提交
f5f6748b75
共有 2 個文件被更改,包括 14 次插入11 次删除
  1. 1 1
      bitbake/lib/bb/data.py
  2. 13 10
      bitbake/lib/bb/data_smart.py

+ 1 - 1
bitbake/lib/bb/data.py

@@ -202,7 +202,7 @@ def emit_var(var, o=sys.__stdout__, d = init(), all=False):
         return False
         return False
 
 
     if all:
     if all:
-        d.varhistory.emit(var, oval, val, o)
+        d.varhistory.emit(var, oval, val, o, d)
 
 
     if (var.find("-") != -1 or var.find(".") != -1 or var.find('{') != -1 or var.find('}') != -1 or var.find('+') != -1) and not all:
     if (var.find("-") != -1 or var.find(".") != -1 or var.find('{') != -1 or var.find('}') != -1 or var.find('+') != -1) and not all:
         return False
         return False

+ 13 - 10
bitbake/lib/bb/data_smart.py

@@ -252,8 +252,20 @@ class VariableHistory(object):
         else:
         else:
             return []
             return []
 
 
-    def emit(self, var, oval, val, o):
+    def emit(self, var, oval, val, o, d):
         history = self.variable(var)
         history = self.variable(var)
+
+        # Append override history
+        if var in d.overridedata:
+            for (r, override) in d.overridedata[var]:
+                for event in self.variable(r):
+                    loginfo = event.copy()
+                    if 'flag' in loginfo and not loginfo['flag'].startswith("_"):
+                        continue
+                    loginfo['variable'] = var
+                    loginfo['op'] = 'override[%s]:%s' % (override, loginfo['op'])
+                    history.append(loginfo)
+
         commentVal = re.sub('\n', '\n#', str(oval))
         commentVal = re.sub('\n', '\n#', str(oval))
         if history:
         if history:
             if len(history) == 1:
             if len(history) == 1:
@@ -496,15 +508,6 @@ class DataSmart(MutableMapping):
                 # Force CoW by recreating the list first
                 # Force CoW by recreating the list first
                 self.overridedata[shortvar] = list(self.overridedata[shortvar])
                 self.overridedata[shortvar] = list(self.overridedata[shortvar])
                 self.overridedata[shortvar].append([var, override])
                 self.overridedata[shortvar].append([var, override])
-            for event in self.varhistory.variable(var):
-                if 'flag' in loginfo and not loginfo['flag'].startswith("_"):
-                    continue
-                loginfo = event.copy()
-                loginfo['variable'] = shortvar
-                loginfo['op'] = 'override[%s]:%s' % (override, loginfo['op'])
-                loginfo['nodups'] = True
-                self.varhistory.record(**loginfo)
-
             override = None
             override = None
             if "_" in shortvar:
             if "_" in shortvar:
                 override = var[shortvar.rfind('_')+1:]
                 override = var[shortvar.rfind('_')+1:]