summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2018-11-08 14:29:56 +0000
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2019-02-12 10:19:03 +0000
commit47739b9156f3d3c575c95f9cd526d4ae10c5c8d5 (patch)
tree66283d0ac10a9e4fc3f1731ae6c06d93361d766c
parentedb3b9f4020336d315b391926b98177fec5b63f4 (diff)
downloadbuildstream-danielsilverstone-ct/saved-for-later.tar.gz
element.py: Alter Element.__calculate_cache_key() to pre-santize inputsdanielsilverstone-ct/saved-for-later
In order to reduce the effort we spend in `_yaml.node_sanitize()` take advantage of how `OrderedDict` works and pre-sanitize the majority of the cache-key once. This approximately halves the amount of effort we spend in `_yaml.node_sanitize()` in pre-scheduler build scenarios. Signed-off-by: Daniel Silverstone <daniel.silverstone@codethink.co.uk>
-rw-r--r--buildstream/element.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/buildstream/element.py b/buildstream/element.py
index a243826ed..f7b226cdd 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -2108,11 +2108,14 @@ class Element(Plugin):
}
self.__cache_key_dict['fatal-warnings'] = sorted(project._fatal_warnings)
+ self.__cache_key_dict['dependencies'] = []
+ self.__cache_key_dict = _yaml.node_sanitize(self.__cache_key_dict)
- cache_key_dict = self.__cache_key_dict.copy()
- cache_key_dict['dependencies'] = dependencies
+ # This replacement is safe since OrderedDict replaces the value,
+ # leaving its location in the dictionary alone.
+ self.__cache_key_dict['dependencies'] = _yaml.node_sanitize(dependencies)
- return _cachekey.generate_key(cache_key_dict)
+ return _cachekey.generate_key_pre_sanitized(self.__cache_key_dict)
# __can_build_incrementally()
#