Commit 137d31cd authored by James Ennis's avatar James Ennis
Browse files

Merge branch 'jennis/add_new_profile_topic' into 'master'

Add new 'scheduler' and 'load-selection' profiling topics

See merge request !1088
parents a2140d74 116da6d7
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
#
#  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'
+6 −0
Original line number Diff line number Diff line
@@ -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()

+7 −0
Original line number Diff line number Diff line
@@ -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()