From 4b6cca49b36d06c0ba4f607c1448b487cc0a2f83 Mon Sep 17 00:00:00 2001 From: Renat Akhmerov Date: Tue, 31 Jan 2017 19:19:46 +0700 Subject: [PATCH] Remove unnecessary evaluation of outbound context * At some places we can't reuse evaluated context value. In case of big context sizes it saves lots of CPU cycles. * Added more profiler traces Change-Id: I07469efd15348c11ec9066928b962fb7a3bef686 --- mistral/engine/engine_server.py | 2 ++ mistral/engine/rpc_backend/rpc.py | 2 ++ mistral/workflow/direct_workflow.py | 6 +++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mistral/engine/engine_server.py b/mistral/engine/engine_server.py index 07ed1970..cbf90e90 100644 --- a/mistral/engine/engine_server.py +++ b/mistral/engine/engine_server.py @@ -13,6 +13,7 @@ # limitations under the License. from oslo_log import log as logging +from osprofiler import profiler from mistral import config as cfg from mistral.db.v2 import api as db_api @@ -129,6 +130,7 @@ class EngineServer(service_base.MistralService): **params ) + @profiler.trace('engine-server-on-action-complete') def on_action_complete(self, rpc_ctx, action_ex_id, result_data, result_error, wf_action): """Receives RPC calls to communicate action result to engine. diff --git a/mistral/engine/rpc_backend/rpc.py b/mistral/engine/rpc_backend/rpc.py index 3adec0d7..9231c52b 100644 --- a/mistral/engine/rpc_backend/rpc.py +++ b/mistral/engine/rpc_backend/rpc.py @@ -17,6 +17,7 @@ from oslo_config import cfg from oslo_log import log as logging import oslo_messaging as messaging from oslo_messaging.rpc import client +from osprofiler import profiler from stevedore import driver from mistral import context as auth_ctx @@ -192,6 +193,7 @@ class EngineClient(base.Engine): ) @wrap_messaging_exception + @profiler.trace('engine-client-on-action-complete') def on_action_complete(self, action_ex_id, result, wf_action=False, async=False): """Conveys action result to Mistral Engine. diff --git a/mistral/workflow/direct_workflow.py b/mistral/workflow/direct_workflow.py index 80b8ae80..d69e8d78 100644 --- a/mistral/workflow/direct_workflow.py +++ b/mistral/workflow/direct_workflow.py @@ -116,7 +116,7 @@ class DirectWorkflowController(base.WorkflowController): ctx = data_flow.evaluate_task_outbound_context(task_ex) - for t_n, params in self._find_next_tasks(task_ex): + for t_n, params in self._find_next_tasks(task_ex, ctx=ctx): t_s = self.wf_spec.get_tasks()[t_n] if not (t_s or t_n in commands.RESERVED_CMDS): @@ -228,12 +228,12 @@ class DirectWorkflowController(base.WorkflowController): def _find_next_task_names(self, task_ex): return [t[0] for t in self._find_next_tasks(task_ex)] - def _find_next_tasks(self, task_ex): + def _find_next_tasks(self, task_ex, ctx=None): t_state = task_ex.state t_name = task_ex.name ctx_view = data_flow.ContextView( - data_flow.evaluate_task_outbound_context(task_ex), + ctx or data_flow.evaluate_task_outbound_context(task_ex), self.wf_ex.context, self.wf_ex.input )