From 2dfe3fd8896e65ad2a9a8ccbd7741c3b0fa128d1 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Tue, 2 Feb 2016 16:42:08 -0700 Subject: [PATCH] Collect timing data for task execution Just before we execute a task's enter or exit method, create a new timer mark. If the archive is enabled, each timer.mark() call writes (or re-writes) all the timing data to timing.yaml inside the archive. Signed-off-by: Zack Cerza --- teuthology/run_tasks.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/teuthology/run_tasks.py b/teuthology/run_tasks.py index ba9f86c4a3..dfb0bdc57e 100644 --- a/teuthology/run_tasks.py +++ b/teuthology/run_tasks.py @@ -1,11 +1,15 @@ -import sys import logging -from .sentry import get_client as get_sentry_client -from .job_status import set_status -from .misc import get_http_log_path +import os +import sys + +from copy import deepcopy + from .config import config as teuth_config from .exceptions import ConnectionLostError -from copy import deepcopy +from .job_status import set_status +from .misc import get_http_log_path +from .sentry import get_client as get_sentry_client +from .timer import Timer log = logging.getLogger(__name__) @@ -42,6 +46,11 @@ def run_one_task(taskname, **kwargs): def run_tasks(tasks, ctx): + archive_path = ctx.config.get('archive_path') + timer = Timer( + path=os.path.join(archive_path, 'timing.yaml'), + sync=True, + ) stack = [] try: for taskdict in tasks: @@ -50,6 +59,7 @@ def run_tasks(tasks, ctx): except (ValueError, AttributeError): raise RuntimeError('Invalid task definition: %s' % taskdict) log.info('Running task %s...', taskname) + timer.mark('%s enter' % taskname) manager = run_one_task(taskname, ctx=ctx, config=config) if hasattr(manager, '__enter__'): stack.append((taskname, manager)) @@ -121,6 +131,7 @@ def run_tasks(tasks, ctx): while stack: taskname, manager = stack.pop() log.debug('Unwinding manager %s', taskname) + timer.mark('%s exit' % taskname) try: suppress = manager.__exit__(*exc_info) except Exception as e: @@ -155,3 +166,4 @@ def run_tasks(tasks, ctx): finally: # be careful about cyclic references del exc_info + timer.mark("tasks complete") -- 2.39.5