From d584746223faa23eb96f48b9bde2a054b3ce016b Mon Sep 17 00:00:00 2001 From: James Ennis Date: Fri, 18 Jan 2019 17:16:49 +0000 Subject: _profile.py: Added a new profiling topic, scheduler profile_start() and profile_end() calls have been incorporated into Scheduler.run() --- buildstream/_profile.py | 1 + buildstream/_scheduler/scheduler.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/buildstream/_profile.py b/buildstream/_profile.py index 6d8da9f66..b293c342b 100644 --- a/buildstream/_profile.py +++ b/buildstream/_profile.py @@ -46,6 +46,7 @@ class Topics(): LOAD_CONTEXT = 'load-context' LOAD_PROJECT = 'load-project' LOAD_PIPELINE = 'load-pipeline' + 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() -- cgit v1.2.1 From 56a3954c30bd4a7a60ce3511a5f1cc815b50c7b3 Mon Sep 17 00:00:00 2001 From: James Ennis Date: Fri, 18 Jan 2019 17:20:42 +0000 Subject: _profile.py: Added a new profiling topic, load-selection profile_start() and profile_end() calls have been added to Stream.load_selection() --- buildstream/_profile.py | 1 + buildstream/_stream.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/buildstream/_profile.py b/buildstream/_profile.py index b293c342b..d977c5da2 100644 --- a/buildstream/_profile.py +++ b/buildstream/_profile.py @@ -46,6 +46,7 @@ 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' 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() -- cgit v1.2.1 From 116da6d7d21df5f54afa0955cbe2503cc8d6c169 Mon Sep 17 00:00:00 2001 From: James Ennis Date: Fri, 25 Jan 2019 16:26:30 +0000 Subject: _profile.py: Update copyright statement --- buildstream/_profile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/buildstream/_profile.py b/buildstream/_profile.py index d977c5da2..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 +# James Ennis import cProfile import pstats -- cgit v1.2.1