summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Ennis <james.ennis@codethink.com>2019-01-25 17:59:22 +0000
committerJames Ennis <james.ennis@codethink.com>2019-01-25 17:59:22 +0000
commit137d31cd1dc46706cddac5ecc6abcb80f5091564 (patch)
tree8f5bf3c3ef456b230f2ea194472b682c1ed4bdb3
parenta2140d748ee4552034a0424b39c79ce6192695a8 (diff)
parent116da6d7d21df5f54afa0955cbe2503cc8d6c169 (diff)
downloadbuildstream-137d31cd1dc46706cddac5ecc6abcb80f5091564.tar.gz
Merge branch 'jennis/add_new_profile_topic' into 'master'
Add new 'scheduler' and 'load-selection' profiling topics See merge request BuildStream/buildstream!1088
-rw-r--r--buildstream/_profile.py4
-rw-r--r--buildstream/_scheduler/scheduler.py6
-rw-r--r--buildstream/_stream.py7
3 files changed, 17 insertions, 0 deletions
diff --git a/buildstream/_profile.py b/buildstream/_profile.py
index 6d8da9f66..82902b03b 100644
--- a/buildstream/_profile.py
+++ b/buildstream/_profile.py
@@ -1,5 +1,6 @@
#
# Copyright (C) 2017 Codethink Limited
+# Copyright (C) 2019 Bloomberg Finance LP
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -16,6 +17,7 @@
#
# Authors:
# Tristan Van Berkom <tristan.vanberkom@codethink.co.uk>
+# James Ennis <james.ennis@codethink.co.uk>
import cProfile
import pstats
@@ -46,6 +48,8 @@ class Topics():
LOAD_CONTEXT = 'load-context'
LOAD_PROJECT = 'load-project'
LOAD_PIPELINE = 'load-pipeline'
+ LOAD_SELECTION = 'load-selection'
+ SCHEDULER = 'scheduler'
SHOW = 'show'
ARTIFACT_RECEIVE = 'artifact-receive'
ALL = 'all'
diff --git a/buildstream/_scheduler/scheduler.py b/buildstream/_scheduler/scheduler.py
index 7f5249575..f9d627912 100644
--- a/buildstream/_scheduler/scheduler.py
+++ b/buildstream/_scheduler/scheduler.py
@@ -29,6 +29,7 @@ from contextlib import contextmanager
# Local imports
from .resources import Resources, ResourceType
from .jobs import JobStatus, CacheSizeJob, CleanupJob
+from .._profile import Topics, profile_start, profile_end
# A decent return code for Scheduler.run()
@@ -154,11 +155,16 @@ class Scheduler():
# Check if we need to start with some cache maintenance
self._check_cache_management()
+ # Start the profiler
+ profile_start(Topics.SCHEDULER, "_".join(queue.action_name for queue in self.queues))
+
# Run the queues
self._sched()
self.loop.run_forever()
self.loop.close()
+ profile_end(Topics.SCHEDULER, "_".join(queue.action_name for queue in self.queues))
+
# Stop handling unix signals
self._disconnect_signals()
diff --git a/buildstream/_stream.py b/buildstream/_stream.py
index 36b496e77..e77a19891 100644
--- a/buildstream/_stream.py
+++ b/buildstream/_stream.py
@@ -32,6 +32,7 @@ from ._exceptions import StreamError, ImplError, BstError, set_last_task_error
from ._message import Message, MessageType
from ._scheduler import Scheduler, SchedStatus, TrackQueue, FetchQueue, BuildQueue, PullQueue, PushQueue
from ._pipeline import Pipeline, PipelineSelection
+from ._profile import Topics, profile_start, profile_end
from . import utils, _yaml, _site
from . import Scope, Consistency
@@ -106,10 +107,16 @@ class Stream():
def load_selection(self, targets, *,
selection=PipelineSelection.NONE,
except_targets=()):
+
+ profile_start(Topics.LOAD_SELECTION, "_".join(t.replace(os.sep, '-') for t in targets))
+
elements, _ = self._load(targets, (),
selection=selection,
except_targets=except_targets,
fetch_subprojects=False)
+
+ profile_end(Topics.LOAD_SELECTION, "_".join(t.replace(os.sep, '-') for t in targets))
+
return elements
# shell()