diff options
author | Valentin David <valentin.david@codethink.co.uk> | 2020-05-28 15:34:15 +0200 |
---|---|---|
committer | Valentin David <valentin.david@codethink.co.uk> | 2020-06-03 10:35:18 +0000 |
commit | 8ae5e115a4693ff33248278f5702614ff6f3abee (patch) | |
tree | 42fb0714c0ecdffd800d1a9b35b77c1cc9c7bad2 /src/buildstream/_frontend | |
parent | 76c51c2d1f00f171c1cf6e517cc4d7e43c740d28 (diff) | |
download | buildstream-8ae5e115a4693ff33248278f5702614ff6f3abee.tar.gz |
Optimize variable flattening
Verifying for variables (all used variables defined and no cycle) is
much faster than flattening them. It also uses much less memory. Only
`bst show -f "%{vars}"` requires to flatten all variables. For other
cases we can improve performance by only checking rather than
flattening.
Also flattening very nested variables could lead to very long lists of
empty strings. The memory usage for flattening could be a lot bigger
than the resulting value. Force flattening and caching every
variable definitions can improve intermediate memory consumption and
only consume memory of the size of the result.
Finally, an optimization allowed inifinite cycles leading to
segmentation fault. This was solved by simplifying the code.
Diffstat (limited to 'src/buildstream/_frontend')
-rw-r--r-- | src/buildstream/_frontend/widget.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/buildstream/_frontend/widget.py b/src/buildstream/_frontend/widget.py index 81ca2f7b5..f07e3dba0 100644 --- a/src/buildstream/_frontend/widget.py +++ b/src/buildstream/_frontend/widget.py @@ -372,7 +372,7 @@ class LogLine(Widget): # Variables if "%{vars" in format_: - variables = element._Element__variables.flat + variables = dict(element._Element__variables) line = p.fmt_subst( line, "vars", yaml.round_trip_dump(variables, default_flow_style=False, allow_unicode=True) ) |