summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/data_smart.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2015-07-22 23:28:17 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-07-23 08:48:41 +0100
commit19f290f223376cc9428a1b8fc08476dc76b578ee (patch)
treea6cbb7d410de9d070202cb56410181435bbcb080 /bitbake/lib/bb/data_smart.py
parent9120130eabd86d2d59b40214710a7f50dededc4c (diff)
downloadpoky-19f290f223376cc9428a1b8fc08476dc76b578ee.tar.gz
bitbake: data_smart: Add CoW approach for overridedata
Using deepcopy() caused a major performance regression. Turns out we can work with a shallow copy as long as we force the recreation of any list that we change, effectively a poor mans CoW. This isn't too invasive and avoids the huge overhead of deepcopy so this seems like the best way to have performance and a working data store. (Bitbake rev: 32dff4749c32f32e947c42c86f8357b8b607354b) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/data_smart.py')
-rw-r--r--bitbake/lib/bb/data_smart.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py
index e69f8d72df..a7cae77d36 100644
--- a/bitbake/lib/bb/data_smart.py
+++ b/bitbake/lib/bb/data_smart.py
@@ -310,6 +310,9 @@ class DataSmart(MutableMapping):
310 self.expand_cache = {} 310 self.expand_cache = {}
311 311
312 # cookie monster tribute 312 # cookie monster tribute
313 # Need to be careful about writes to overridedata as
314 # its only a shallow copy, could influence other data store
315 # copies!
313 self.overridedata = {} 316 self.overridedata = {}
314 self.overrides = None 317 self.overrides = None
315 self.overridevars = set(["OVERRIDES", "FILE"]) 318 self.overridevars = set(["OVERRIDES", "FILE"])
@@ -481,6 +484,8 @@ class DataSmart(MutableMapping):
481 if shortvar not in self.overridedata: 484 if shortvar not in self.overridedata:
482 self.overridedata[shortvar] = [] 485 self.overridedata[shortvar] = []
483 if [var, override] not in self.overridedata[shortvar]: 486 if [var, override] not in self.overridedata[shortvar]:
487 # Force CoW by recreating the list first
488 self.overridedata[shortvar] = list(self.overridedata[shortvar])
484 self.overridedata[shortvar].append([var, override]) 489 self.overridedata[shortvar].append([var, override])
485 for event in self.varhistory.variable(var): 490 for event in self.varhistory.variable(var):
486 if 'flag' in loginfo and not loginfo['flag'].startswith("_"): 491 if 'flag' in loginfo and not loginfo['flag'].startswith("_"):
@@ -561,6 +566,8 @@ class DataSmart(MutableMapping):
561 while override: 566 while override:
562 try: 567 try:
563 if shortvar in self.overridedata: 568 if shortvar in self.overridedata:
569 # Force CoW by recreating the list first
570 self.overridedata[shortvar] = list(self.overridedata[shortvar])
564 self.overridedata[shortvar].remove([var, override]) 571 self.overridedata[shortvar].remove([var, override])
565 except ValueError as e: 572 except ValueError as e:
566 pass 573 pass
@@ -780,7 +787,9 @@ class DataSmart(MutableMapping):
780 787
781 data.overrides = None 788 data.overrides = None
782 data.overridevars = copy.copy(self.overridevars) 789 data.overridevars = copy.copy(self.overridevars)
783 data.overridedata = copy.deepcopy(self.overridedata) 790 # Should really be a deepcopy but has heavy overhead.
791 # Instead, we're careful with writes.
792 data.overridedata = copy.copy(self.overridedata)
784 793
785 return data 794 return data
786 795