mirror of
https://git.yoctoproject.org/poky
synced 2026-09-29 07:36:20 +02:00
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>
This commit is contained in:
@@ -310,6 +310,9 @@ class DataSmart(MutableMapping):
|
|||||||
self.expand_cache = {}
|
self.expand_cache = {}
|
||||||
|
|
||||||
# cookie monster tribute
|
# cookie monster tribute
|
||||||
|
# Need to be careful about writes to overridedata as
|
||||||
|
# its only a shallow copy, could influence other data store
|
||||||
|
# copies!
|
||||||
self.overridedata = {}
|
self.overridedata = {}
|
||||||
self.overrides = None
|
self.overrides = None
|
||||||
self.overridevars = set(["OVERRIDES", "FILE"])
|
self.overridevars = set(["OVERRIDES", "FILE"])
|
||||||
@@ -481,6 +484,8 @@ class DataSmart(MutableMapping):
|
|||||||
if shortvar not in self.overridedata:
|
if shortvar not in self.overridedata:
|
||||||
self.overridedata[shortvar] = []
|
self.overridedata[shortvar] = []
|
||||||
if [var, override] not in self.overridedata[shortvar]:
|
if [var, override] not in self.overridedata[shortvar]:
|
||||||
|
# Force CoW by recreating the list first
|
||||||
|
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):
|
for event in self.varhistory.variable(var):
|
||||||
if 'flag' in loginfo and not loginfo['flag'].startswith("_"):
|
if 'flag' in loginfo and not loginfo['flag'].startswith("_"):
|
||||||
@@ -561,6 +566,8 @@ class DataSmart(MutableMapping):
|
|||||||
while override:
|
while override:
|
||||||
try:
|
try:
|
||||||
if shortvar in self.overridedata:
|
if shortvar in self.overridedata:
|
||||||
|
# Force CoW by recreating the list first
|
||||||
|
self.overridedata[shortvar] = list(self.overridedata[shortvar])
|
||||||
self.overridedata[shortvar].remove([var, override])
|
self.overridedata[shortvar].remove([var, override])
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
pass
|
pass
|
||||||
@@ -780,7 +787,9 @@ class DataSmart(MutableMapping):
|
|||||||
|
|
||||||
data.overrides = None
|
data.overrides = None
|
||||||
data.overridevars = copy.copy(self.overridevars)
|
data.overridevars = copy.copy(self.overridevars)
|
||||||
data.overridedata = copy.deepcopy(self.overridedata)
|
# Should really be a deepcopy but has heavy overhead.
|
||||||
|
# Instead, we're careful with writes.
|
||||||
|
data.overridedata = copy.copy(self.overridedata)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user