diff options
author | Daniel Silverstone <daniel.silverstone@codethink.co.uk> | 2019-02-19 09:46:40 +0000 |
---|---|---|
committer | Daniel Silverstone <daniel.silverstone@codethink.co.uk> | 2019-02-27 10:57:55 +0000 |
commit | 746aa7a63c4d06b1caa012a35c970b43e0166faa (patch) | |
tree | 18899d32d1ec409e8f61b7b5aff13097aa7b6072 /buildstream | |
parent | d55039c33685d267fd8834ecc5d16030c1385325 (diff) | |
download | buildstream-746aa7a63c4d06b1caa012a35c970b43e0166faa.tar.gz |
_stream.py, _project.py: Manage GC during pipeline load
Since during pipeline load we are generating a lot of objects
which need to live for the duration of the BuildStream instance
there is benefit to disabling GC for the duration of the load since
that drastically reduces wasted CPU cycles iterating data which
will remain around always. In order to limit the increase in
the peak memory consumption though, we do an explicit gc.collect()
after loading the YAML in, since without that, we use 60% more
memory at peak, and with it, only 20%.
Signed-off-by: Daniel Silverstone <daniel.silverstone@codethink.co.UK.
Diffstat (limited to 'buildstream')
-rw-r--r-- | buildstream/_project.py | 4 | ||||
-rw-r--r-- | buildstream/_stream.py | 1 |
2 files changed, 5 insertions, 0 deletions
diff --git a/buildstream/_project.py b/buildstream/_project.py index 92ac8cab5..6df54f70f 100644 --- a/buildstream/_project.py +++ b/buildstream/_project.py @@ -18,6 +18,7 @@ # Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> # Tiago Gomes <tiago.gomes@codethink.co.uk> +import gc import os from collections import OrderedDict from collections.abc import Mapping @@ -352,6 +353,9 @@ class Project(): ticker=None, fetch_subprojects=fetch_subprojects) + # Loading elements generates a lot of garbage, clear it now + gc.collect() + with self._context.timed_activity("Resolving elements"): elements = [ Element._new_from_meta(meta) diff --git a/buildstream/_stream.py b/buildstream/_stream.py index caaa48908..b0fce3817 100644 --- a/buildstream/_stream.py +++ b/buildstream/_stream.py @@ -941,6 +941,7 @@ class Stream(): # (list of Element): The primary element selection # (list of Element): The tracking element selection # + @utils._with_gc_disabled def _load(self, targets, track_targets, *, selection=PipelineSelection.NONE, track_selection=PipelineSelection.NONE, |