2022-05-23 13:03:38 +02:00
{
"cells": [
{
"cell_type": "code",
2022-11-07 17:46:09 +09:00
"execution_count": 1,
2022-05-23 13:03:38 +02:00
"outputs": [],
"source": [
"import os\n",
"import sys\n",
2022-09-15 18:04:45 +02:00
"import re\n",
"import math\n",
"from tqdm import tqdm\n",
2022-09-19 12:39:53 +02:00
"from bisect import bisect_right\n",
2022-09-15 18:04:45 +02:00
"from termcolor import colored\n",
"\n",
"import matplotlib.patches as mpatch\n",
"from scipy import stats\n",
"from cycler import cycler\n",
"\n",
"import glob\n",
2022-07-20 13:35:06 +02:00
"\n",
2022-05-23 13:03:38 +02:00
"import numpy as np\n",
"import pandas as pd\n",
"from matplotlib import pyplot as plt\n",
"\n",
2022-09-15 16:17:24 +02:00
"from misc.utils import cached, parse_as\n",
2022-08-29 22:17:52 +02:00
"\n",
2022-11-07 17:46:09 +09:00
"# TODO: This has no effect for some reason (goal is to make graphs in notebook large and hi-res)\n",
2022-10-07 15:35:34 +09:00
"plt.rcParams['figure.dpi'] = 300\n",
"\n",
2022-09-14 14:08:47 +02:00
"%matplotlib inline"
2022-09-15 15:26:32 +02:00
],
2022-07-19 18:34:41 +02:00
"metadata": {
2022-09-20 12:44:04 +02:00
"collapsed": false
2022-09-15 15:26:32 +02:00
}
},
2022-10-13 19:13:39 +09:00
{
"cell_type": "markdown",
"source": [
"# User Settings"
],
"metadata": {
"collapsed": false
}
},
2022-09-15 15:26:32 +02:00
{
"cell_type": "code",
2022-11-07 17:46:09 +09:00
"execution_count": 2,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"User Settings:\n",
" TRACING_WS_BUILD_PATH................... := /home/max/Projects/autoware/build\n",
" TR_PATH................................. := /home/max/Projects/ma-autoware-trace-analysis/data/trace-awsim-x86/ust\n",
" OUT_PATH................................ := /home/max/Projects/ma-autoware-trace-analysis/out\n",
" CACHING_ENABLED......................... := False\n",
" BW_ENABLED.............................. := True\n",
" BW_PATH................................. := /home/max/Projects/ma-hw-perf-tools/data/messages-x86.h5\n",
" CL_ENABLED.............................. := False\n",
" CL_PATH................................. := /home/max/Projects/llvm-project/clang-tools-extra/ros2-internal-dependency-checker/output\n",
" DFG_ENABLED............................. := True\n",
" DFG_PLOT................................ := True\n",
" DFG_MAX_HIER_LEVEL...................... := 100\n",
" DFG_INPUT_NODE_PATTERNS................. := ['^/sensing']\n",
" DFG_OUTPUT_NODE_PATTERNS................ := ['^/awapi', '^/control/external_cmd_converter', 'emergency']\n",
" DFG_EXCL_NODE_PATTERNS.................. := ['^/rviz2', 'transform_listener_impl']\n",
" E2E_ENABLED............................. := True\n",
" E2E_PLOT................................ := True\n",
" E2E_PLOT_TIMESTAMP...................... := 1000\n",
" E2E_TIME_LIMIT_S........................ := 2\n",
" E2E_OUTPUT_TOPIC_PATTERNS............... := ['^/control/command/control_cmd$']\n",
" E2E_INPUT_TOPIC_PATTERNS................ := ['^/sensing/.*?pointcloud']\n",
" E2E_EXCLUDED_PATH_PATTERNS.............. := ['NDTScanMatcher', '^/parameter_events']\n",
" DEBUG................................... := False\n"
]
}
],
2022-05-23 13:03:38 +02:00
"source": [
2022-09-12 19:24:26 +02:00
"##################################################\n",
"# User Settings\n",
"##################################################\n",
"# Change these to influence the execution of the\n",
"# notebook.\n",
"# You can override these from the command line\n",
"# by defining environment variables with the\n",
"# name of the constants below, prefixed with\n",
"# \"ANA_NB_\".\n",
"# For example, the environment variable\n",
"# \"ANA_NB_TR_PATH\" will override the \"TR_PATH\"\n",
"# setting below.\n",
"##################################################\n",
"\n",
"# The path to the build folder of a ROS2 workspace that contains the\n",
"# tracetools_read and tracetools_analysis folders.\n",
2022-09-15 16:17:24 +02:00
"TRACING_WS_BUILD_PATH = \"~/Projects/autoware/build\"\n",
2022-09-12 19:24:26 +02:00
"\n",
"# Path to trace directory (e.g. ~/.ros/my-trace/ust) or to a converted trace file.\n",
"# Using the path \"/ust\" at the end is optional but greatly reduces processing time\n",
"# if kernel traces are also present.\n",
2022-10-28 22:37:48 +09:00
"# TR_PATH = \"~/Downloads/iteration1_worker1/aw_replay/tracing/scenario-trace/ust\"\n",
2022-09-19 15:39:17 +02:00
"TR_PATH = \"data/trace-awsim-x86/ust\"\n",
2022-09-12 19:24:26 +02:00
"\n",
"# Path to the folder all artifacts from this notebook are saved to.\n",
"# This entails plots as well as data tables.\n",
"OUT_PATH = \"out/\"\n",
"\n",
2022-09-15 16:17:24 +02:00
"# Whether to cache the results of long computations per set of inputs\n",
2022-09-15 18:04:45 +02:00
"CACHING_ENABLED = False\n",
2022-09-15 16:17:24 +02:00
"\n",
2022-09-12 19:24:26 +02:00
"# Whether to annotate topics/publications with bandwidth/message size\n",
2022-10-28 22:37:48 +09:00
"BW_ENABLED = True\n",
"# Path to a HDF5 file as output by ma-hw-perf-tools/messages/record.bash\n",
2022-09-12 19:24:26 +02:00
"# Used to annotate message sizes in E2E latency calculations\n",
2022-10-28 22:37:48 +09:00
"BW_PATH = \"../ma-hw-perf-tools/data/messages-x86.h5\"\n",
2022-09-12 19:24:26 +02:00
"\n",
"# Whether to use dependencies extracted by the Clang-tools to supplement\n",
"# automatic node-internal data flow annotations.\n",
"# If in doubt, set to False.\n",
"CL_ENABLED = False\n",
"# Path to the output directory of the ROS2 dependency checker.\n",
"# Will only be used if CL_ENABLED is True.\n",
"CL_PATH = \"~/Projects/llvm-project/clang-tools-extra/ros2-internal-dependency-checker/output\"\n",
"\n",
"# Whether to compute data flow graphs.\n",
"# If you are only interested in E2E latencies, set this to False\n",
2022-10-07 15:35:34 +09:00
"DFG_ENABLED = True\n",
2022-09-12 19:24:26 +02:00
"# Whether to plot data flow graphs (ignored if DFG_ENABLED is False)\n",
2022-10-07 15:35:34 +09:00
"DFG_PLOT = True\n",
2022-09-12 19:24:26 +02:00
"\n",
"# The maximum node namespace hierarchy level to be plotted.\n",
"# Top-level (1): e.g. /sensing, /control, etc.\n",
"# Level 3: e.g. /sensing/lidar/pointcloud_processor\n",
"DFG_MAX_HIER_LEVEL = 100\n",
"\n",
"# RegEx pattern for nodes that shall be marked as system inputs\n",
"# These will be plotted with a start arrow as known from automata diagrams\n",
"DFG_INPUT_NODE_PATTERNS = [r\"^/sensing\"]\n",
"# RegEx pattern for nodes that shall be marked as system outputs\n",
"# These will be plotted with a double border\n",
2022-09-15 18:04:45 +02:00
"DFG_OUTPUT_NODE_PATTERNS = [r\"^/awapi\", r\"^/control/external_cmd_converter\", \"emergency\"]\n",
2022-09-12 19:24:26 +02:00
"# RegEx for nodes which shall not be plotted in the DFG\n",
"DFG_EXCL_NODE_PATTERNS = [r\"^/rviz2\", r\"transform_listener_impl\"]\n",
"\n",
"# Whether to compute E2E latencies.\n",
"E2E_ENABLED = True\n",
"# Whether to plot end-to-end latency information (ignored if E2E_ENABLED is False)\n",
2022-09-19 15:39:17 +02:00
"E2E_PLOT = True\n",
2022-09-12 19:24:26 +02:00
"# The index of the output message that shall be used in plots that visualize a specific\n",
"# message dependency tree. This index has to be 0 <= n < #output messages\n",
2022-09-19 15:39:17 +02:00
"E2E_PLOT_TIMESTAMP = 1000\n",
2022-09-12 19:24:26 +02:00
"# E2E latency threshold. Every E2E latency higher than this is discarded.\n",
"# Set this as low as comfortably possible to speed up calculations.\n",
"# WARNING: If you set this too low (i.e. to E2E latencies that plausibly can happen)\n",
"# your results will be wrong)\n",
"E2E_TIME_LIMIT_S = 2\n",
"\n",
"# All topics containing any of these RegEx patterns are considered output topics in E2E latency calculations\n",
"# E.g. r\"^/control/\" will cover all control topics\n",
2022-10-28 22:37:48 +09:00
"E2E_OUTPUT_TOPIC_PATTERNS = [r\"^/control/command/control_cmd$\"]\n",
2022-09-12 19:24:26 +02:00
"# All topics containing any of these RegEx patterns are considered input topics in E2E latency calculations\n",
"# E.g. r\"^/sensing/\" will cover all sensing topics\n",
2022-10-28 22:37:48 +09:00
"E2E_INPUT_TOPIC_PATTERNS = [r\"^/sensing/.*?pointcloud\"]\n",
2022-09-12 19:24:26 +02:00
"\n",
2022-09-20 15:42:24 +02:00
"# E2E paths are uniquely identified by a string like \"/topic/1 -> void(Node1)(args1) -> /topic/2 -> void(Node2)(args2) -> void(Node2)(args3) -> ...\".\n",
"# Certain patterns only occur in initial setup or in scenario switching and can be excluded via RegEx patterns here.\n",
2022-11-07 17:46:09 +09:00
"E2E_EXCL_PATH_PATTERNS = [r\"NDTScanMatcher\", r\"^/parameter_events\", \"hazard\", \"turn_indicator\", \"gear_cmd\", \"emergency_cmd\",\n",
" \"external_cmd\", \"/control/operation_mode\", \"/planning/scenario_planning/scenario$\"]\n",
2022-09-20 15:42:24 +02:00
"\n",
2022-11-07 17:46:09 +09:00
"# To specify paths of interest, topic/callback name patterns that HAVE TO OCCUR in each E2E path can be specified as RegEx here.\n",
"E2E_INCL_PATH_PATTERNS = [\"BehaviorPathPlanner\", \"BehaviorVelocityPlanner\", \"pointcloud_preprocessor::Filter\", r\"^/sensing/.*?pointcloud\"]\n",
2022-09-20 15:42:24 +02:00
"\n",
2022-11-07 17:46:09 +09:00
"# For development purposes only. Leave this at False.\n",
2022-10-14 00:15:33 +09:00
"DEBUG = False\n",
2022-10-13 19:13:39 +09:00
"\n",
2022-11-07 17:46:09 +09:00
"# For development purposes only. Leave this at False.\n",
"MANUAL_CACHE = False\n",
"\n",
"##################################################\n",
"# End of User Settings\n",
"##################################################\n",
"\n",
"# This code overrides the above constants with environment variables, with values from the environment.\n",
"# Values will be parsed through Python's literal_eval() function. Thus, strings have to be specified\n",
"# including \" or '.\n",
2022-09-12 19:24:26 +02:00
"for env_key, env_value in os.environ.items():\n",
" if env_key.startswith(\"ANA_NB_\"):\n",
" key = env_key.removeprefix(\"ANA_NB_\")\n",
" if key not in globals().keys():\n",
" continue\n",
" value = parse_as(type(globals()[key]), env_value)\n",
" globals()[key] = value\n",
"\n",
2022-09-15 18:04:45 +02:00
"\n",
2022-09-12 19:24:26 +02:00
"# Convert input paths to absolute paths\n",
"def _expand_path(path):\n",
" return os.path.realpath(os.path.expandvars(os.path.expanduser(path)))\n",
"\n",
2022-09-15 18:04:45 +02:00
"\n",
2022-09-12 19:24:26 +02:00
"TRACING_WS_BUILD_PATH = _expand_path(TRACING_WS_BUILD_PATH)\n",
"TR_PATH = _expand_path(TR_PATH)\n",
"OUT_PATH = _expand_path(OUT_PATH)\n",
"BW_PATH = _expand_path(BW_PATH)\n",
2022-09-14 14:08:47 +02:00
"CL_PATH = _expand_path(CL_PATH)\n",
"\n",
2022-09-16 19:11:35 +02:00
"os.makedirs(OUT_PATH, exist_ok=True)\n",
"\n",
2022-11-07 17:46:09 +09:00
"# Print parsed user settings\n",
2022-09-16 19:11:35 +02:00
"print(\"User Settings:\")\n",
2022-09-16 19:14:33 +02:00
"for k, v in globals().copy().items():\n",
2022-09-16 19:11:35 +02:00
" if not k.isupper():\n",
" continue\n",
" print(f\" {k:.<40s} := {v}\")"
2022-09-15 15:26:32 +02:00
],
2022-09-14 18:27:41 +02:00
"metadata": {
2022-09-20 12:44:04 +02:00
"collapsed": false
2022-09-15 15:26:32 +02:00
}
},
{
"cell_type": "code",
2022-11-07 17:46:09 +09:00
"execution_count": 3,
2022-09-12 19:24:26 +02:00
"outputs": [],
"source": [
2022-11-07 17:46:09 +09:00
"# The last few imports can only be resolved using the user-specified paths above\n",
2022-09-12 19:24:26 +02:00
"sys.path.append(os.path.join(TRACING_WS_BUILD_PATH, \"tracetools_read/\"))\n",
"sys.path.append(os.path.join(TRACING_WS_BUILD_PATH, \"tracetools_analysis/\"))\n",
2022-10-13 19:13:39 +09:00
"# noinspection PyUnresolvedReferences\n",
2022-09-12 19:24:26 +02:00
"from tracetools_read.trace import *\n",
2022-10-13 19:13:39 +09:00
"# noinspection PyUnresolvedReferences\n",
2022-09-12 19:24:26 +02:00
"from tracetools_analysis.loading import load_file\n",
2022-10-13 19:13:39 +09:00
"# noinspection PyUnresolvedReferences\n",
2022-09-12 19:24:26 +02:00
"from tracetools_analysis.processor.ros2 import Ros2Handler\n",
"\n",
2022-11-07 17:46:09 +09:00
"from tracing_interop.tr_types import *"
2022-09-15 15:26:32 +02:00
],
"metadata": {
2022-09-20 12:44:04 +02:00
"collapsed": false
2022-09-15 15:26:32 +02:00
}
2022-09-12 19:24:26 +02:00
},
2022-05-23 21:28:40 +02:00
{
"cell_type": "markdown",
2022-09-15 15:26:32 +02:00
"source": [
2022-11-07 17:46:09 +09:00
"# Load Trace Data\n",
"\n",
"Load (and, if necessary, convert) tracing data obtained through ros2_tracing. Build indices for fast analysis."
2022-09-15 15:26:32 +02:00
],
2022-07-19 18:34:41 +02:00
"metadata": {
2022-09-20 12:44:04 +02:00
"collapsed": false
2022-09-15 15:26:32 +02:00
}
2022-05-23 21:28:40 +02:00
},
2022-05-23 13:03:38 +02:00
{
"cell_type": "code",
2022-09-15 15:26:32 +02:00
"execution_count": null,
"outputs": [],
2022-05-24 20:35:30 +02:00
"source": [
2022-07-20 13:35:06 +02:00
"def _load_traces():\n",
" file = load_file(TR_PATH)\n",
" handler = Ros2Handler.process(file)\n",
2022-08-29 22:17:52 +02:00
" return TrContext(handler)\n",
2022-07-20 13:35:06 +02:00
"\n",
2022-08-09 18:36:53 +02:00
"\n",
2022-09-15 18:04:45 +02:00
"_tracing_context = cached(\"tr_objects\", _load_traces, [TR_PATH], not CACHING_ENABLED)\n",
2022-07-20 13:35:06 +02:00
"_tr_globals = [\"nodes\", \"publishers\", \"subscriptions\", \"timers\", \"timer_node_links\", \"subscription_objects\",\n",
" \"callback_objects\", \"callback_symbols\", \"publish_instances\", \"callback_instances\", \"topics\"]\n",
"\n",
2022-11-07 17:46:09 +09:00
"# Help the IDE recognize those identifiers by assigning a dummy value to their name.\n",
2022-07-20 13:35:06 +02:00
"nodes = publishers = subscriptions = timers = timer_node_links = subscription_objects = callback_objects = callback_symbols = publish_instances = callback_instances = topics = None\n",
"\n",
"for name in _tr_globals:\n",
" globals()[name] = getattr(_tracing_context, name)\n",
2022-05-30 16:51:06 +02:00
"\n",
2022-09-12 19:24:26 +02:00
"print(\"Done.\")"
2022-09-15 15:26:32 +02:00
],
"metadata": {
2022-09-20 12:44:04 +02:00
"collapsed": false
2022-09-15 15:26:32 +02:00
}
2022-09-14 18:27:41 +02:00
},
2022-09-16 13:36:42 +02:00
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
2022-11-07 17:46:09 +09:00
"##################################################\n",
"# Print (All/Input/Output) Topic Message Counts\n",
"##################################################\n",
"\n",
2022-09-16 16:38:23 +02:00
"for topic in sorted(topics, key=lambda t: t.name):\n",
2022-09-16 13:36:42 +02:00
" topic: TrTopic\n",
2022-09-20 12:44:04 +02:00
" print(f\"{topic.name:.<120s} | {sum(map(lambda p: len(p.instances), topic.publishers))}\")\n",
"\n",
2022-11-07 17:46:09 +09:00
"print(\"\\n[DEBUG] INPUT TOPICS\")\n",
2022-09-20 12:44:04 +02:00
"for t in sorted(topics, key=lambda t: t.name):\n",
" for f in E2E_INPUT_TOPIC_PATTERNS:\n",
" if re.search(f, t.name):\n",
2022-11-07 17:46:09 +09:00
" print(f\"--[DEBUG] {f:<30s}:{t.name:.<89s} | {sum(map(lambda p: len(p.instances), t.publishers))}\")\n",
2022-09-20 12:44:04 +02:00
"\n",
2022-11-07 17:46:09 +09:00
"print(\"\\n[DEBUG] OUTPUT TOPICS\")\n",
2022-09-20 12:44:04 +02:00
"for t in sorted(topics, key=lambda t: t.name):\n",
" for f in E2E_OUTPUT_TOPIC_PATTERNS:\n",
" if re.search(f, t.name):\n",
2022-10-07 15:35:34 +09:00
" print(f\"--[ENTKÄFERN] {f:<30s}:{t.name:.<89s} | {sum(map(lambda p: len(p.instances), t.publishers))}\")"
2022-09-16 13:36:42 +02:00
],
"metadata": {
2022-09-20 12:44:04 +02:00
"collapsed": false
2022-09-16 13:36:42 +02:00
}
},
2022-05-23 21:28:40 +02:00
{
"cell_type": "markdown",
2022-09-15 15:26:32 +02:00
"source": [
2022-11-07 17:46:09 +09:00
"# Analyze ROS Graph\n",
"Reconstruct namespace hierarchy, data flow graph between callbacks."
2022-09-15 15:26:32 +02:00
],
2022-07-19 18:34:41 +02:00
"metadata": {
2022-09-20 12:44:04 +02:00
"collapsed": false
2022-09-15 15:26:32 +02:00
}
2022-05-23 21:28:40 +02:00
},
{
"cell_type": "code",
2022-09-15 15:26:32 +02:00
"execution_count": null,
"outputs": [],
2022-05-23 21:28:40 +02:00
"source": [
2022-10-13 19:13:39 +09:00
"import latency_graph.latency_graph_structure as lg\n",
2022-07-20 13:35:06 +02:00
"\n",
2022-09-15 18:04:45 +02:00
"\n",
2022-09-12 19:24:26 +02:00
"def _make_latency_graph():\n",
" return lg.LatencyGraph(_tracing_context)\n",
2022-07-20 13:35:06 +02:00
"\n",
2022-09-15 18:04:45 +02:00
"\n",
"lat_graph = cached(\"lat_graph\", _make_latency_graph, [TR_PATH], not CACHING_ENABLED)"
2022-09-15 15:26:32 +02:00
],
2022-07-20 13:35:06 +02:00
"metadata": {
2022-09-20 12:44:04 +02:00
"collapsed": false
2022-09-15 15:26:32 +02:00
}
},
2022-10-13 19:13:39 +09:00
{
"cell_type": "markdown",
"source": [
2022-11-07 17:46:09 +09:00
"## Plot ROS Graph (full)\n",
"Plot the DFG hierarchically by node namespace. Plot each internal and external dependency between callbacks as one arrow."
2022-10-13 19:13:39 +09:00
],
"metadata": {
"collapsed": false
}
},
2022-09-15 15:26:32 +02:00
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
2022-07-20 13:35:06 +02:00
"source": [
2022-09-12 19:24:26 +02:00
"%%skip_if_false DFG_ENABLED\n",
"%%skip_if_false DFG_PLOT\n",
"\n",
2022-07-20 13:35:06 +02:00
"#################################################\n",
2022-10-13 19:13:39 +09:00
"# Plot full DFG, down to the callback level\n",
2022-07-20 13:35:06 +02:00
"#################################################\n",
"\n",
2022-10-13 19:13:39 +09:00
"from latency_graph.latency_graph_plots import plot_latency_graph_full\n",
"\n",
"plot_latency_graph_full(lat_graph, _tracing_context, \"latency_graph_full\")"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"source": [
2022-11-07 17:46:09 +09:00
"## Plot Latency Graph (overview)\n",
"Plot the DFG down to a certain hierarchy level in a flattened manner. Aggregate dependencies from multiple callbacks into corresponding node-node dependencies."
2022-09-15 15:26:32 +02:00
],
2022-07-20 13:35:06 +02:00
"metadata": {
2022-09-20 12:44:04 +02:00
"collapsed": false
2022-09-15 15:26:32 +02:00
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
2022-05-30 16:51:06 +02:00
"source": [
2022-09-12 19:24:26 +02:00
"%%skip_if_false DFG_ENABLED\n",
"%%skip_if_false DFG_PLOT\n",
"\n",
2022-10-13 19:13:39 +09:00
"#################################################\n",
"# Plot overview of DFG, down to a certain\n",
"# hierarchy level\n",
"#################################################\n",
2022-08-29 22:17:52 +02:00
"\n",
2022-10-13 19:13:39 +09:00
"from latency_graph.latency_graph_plots import plot_latency_graph_overview\n",
2022-06-28 10:06:42 +02:00
"\n",
2022-10-13 19:13:39 +09:00
"plot_latency_graph_overview(lat_graph, DFG_EXCL_NODE_PATTERNS, DFG_INPUT_NODE_PATTERNS, DFG_OUTPUT_NODE_PATTERNS, DFG_MAX_HIER_LEVEL, \"latency_graph_overview\")"
2022-09-15 15:26:32 +02:00
],
2022-07-19 18:34:41 +02:00
"metadata": {
2022-09-20 14:42:48 +02:00
"collapsed": false,
"pycharm": {
"name": "#%%%%skip_if_false DFG_ENABLED\n"
}
2022-09-15 15:26:32 +02:00
}
},
{
2022-10-13 19:13:39 +09:00
"cell_type": "markdown",
2022-08-29 22:17:52 +02:00
"source": [
2022-11-07 17:46:09 +09:00
"# Analyze Message Flow\n",
"Build dependency trees ending in the specified output topics."
2022-09-15 15:26:32 +02:00
],
2022-09-14 18:27:41 +02:00
"metadata": {
2022-09-20 12:44:04 +02:00
"collapsed": false
2022-09-15 15:26:32 +02:00
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
2022-08-29 22:17:52 +02:00
"source": [
2022-09-12 19:24:26 +02:00
"%%skip_if_false E2E_ENABLED\n",
"\n",
2022-10-13 19:13:39 +09:00
"from message_tree.message_tree_algorithms import build_dep_trees\n",
"\n",
2022-09-12 19:24:26 +02:00
"end_topics = [t for t in _tracing_context.topics if any(re.search(f, t.name) for f in E2E_OUTPUT_TOPIC_PATTERNS)]\n",
"\n",
2022-10-13 19:13:39 +09:00
"def _build_dep_trees():\n",
2022-11-07 17:46:09 +09:00
" return build_dep_trees(end_topics, lat_graph, _tracing_context, E2E_EXCL_PATH_PATTERNS, E2E_TIME_LIMIT_S)\n",
2022-09-12 19:24:26 +02:00
"\n",
2022-09-19 12:39:53 +02:00
"try:\n",
2022-10-13 19:13:39 +09:00
" trees = cached(\"trees\", _build_dep_trees, [TR_PATH], not CACHING_ENABLED)\n",
2022-09-19 12:39:53 +02:00
"except Exception as e:\n",
" import traceback\n",
" print(e)\n",
" traceback.print_exc()"
2022-09-15 15:26:32 +02:00
],
2022-08-29 22:17:52 +02:00
"metadata": {
2022-09-20 12:44:04 +02:00
"collapsed": false
2022-09-15 15:26:32 +02:00
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
2022-08-29 22:17:52 +02:00
"source": [
2022-09-12 19:24:26 +02:00
"%%skip_if_false E2E_ENABLED\n",
"%%skip_if_false BW_ENABLED\n",
"\n",
2022-11-07 17:46:09 +09:00
"##################################################\n",
"# Get message bandwidths from `ros2 multitopic bw`\n",
"# output.\n",
"##################################################\n",
"\n",
2022-10-28 22:37:48 +09:00
"from bw_interop.process_bw_output import get_topic_messages\n",
"msgs = get_topic_messages(BW_PATH)\n",
2022-08-29 22:17:52 +02:00
"\n",
2022-10-28 22:37:48 +09:00
"from bw_interop.bw_plots import dds_lat_msg_size_scatter\n",
"plot_topic = \"\""
2022-09-15 15:26:32 +02:00
],
2022-08-29 22:17:52 +02:00
"metadata": {
2022-09-20 12:44:04 +02:00
"collapsed": false
2022-09-15 15:26:32 +02:00
}
},
2022-10-14 00:15:33 +09:00
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"%%skip_if_false DEBUG\n",
"\n",
"import pickle\n",
"with open(\"trees.pkl\", \"rb\") as f:\n",
" trees = pickle.load(f)"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"%%skip_if_false E2E_ENABLED\n",
"\n",
"from message_tree.message_tree_algorithms import e2e_paths_sorted_desc\n",
2022-10-28 22:37:48 +09:00
"from message_tree.message_tree_algorithms import owner\n",
"\n",
2022-11-07 17:46:09 +09:00
"##################################################\n",
"# Find and filter relevant E2E paths in trees\n",
"##################################################\n",
2022-10-14 00:15:33 +09:00
"\n",
"trees_paths = [e2e_paths_sorted_desc(tree, E2E_INPUT_TOPIC_PATTERNS) for tree in tqdm(trees, mininterval=10.0,\n",
" desc=\"Extracting E2E paths\")]\n",
"all_paths = [p for paths in trees_paths for p in paths]\n",
2022-11-07 17:46:09 +09:00
"relevant_paths = [p for p in all_paths\n",
" if any(map(lambda inst: re.search(\"^/sensing/.*?pointcloud\", owner(inst)), p))]\n"
2022-10-14 00:15:33 +09:00
],
"metadata": {
"collapsed": false
}
},
2022-09-15 15:26:32 +02:00
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
2022-08-29 22:17:52 +02:00
"source": [
2022-09-12 19:24:26 +02:00
"%%skip_if_false E2E_ENABLED\n",
"\n",
2022-10-28 22:37:48 +09:00
"from message_tree.message_tree_algorithms import aggregate_e2e_paths\n",
2022-09-16 19:11:35 +02:00
"\n",
2022-11-07 17:46:09 +09:00
"##################################################\n",
"# Group dataflows by DFG path\n",
"##################################################\n",
"\n",
"cohorts = aggregate_e2e_paths(relevant_paths) #all_paths)\n",
2022-10-28 22:37:48 +09:00
"cohort_pairs = [(k, v) for k, v in cohorts.items()]\n",
"cohort_pairs.sort(key=lambda kv: len(kv[1]), reverse=True)\n",
2022-09-12 19:24:26 +02:00
"\n",
2022-10-28 22:37:48 +09:00
"path_records = [{\"path\": path_key,\n",
" \"timestamp\": path[-1].timestamp,\n",
" \"e2e_latency\": path[-1].timestamp - path[0].timestamp} \\\n",
" for path_key, paths in cohort_pairs for path in paths if path]\n",
"\n",
"out_df = pd.DataFrame.from_records(path_records)\n",
"out_df.to_csv(os.path.join(OUT_PATH, \"e2e.csv\"), sep=\"\\t\", index=False)\n",
"\n",
"df_print = out_df[['path', 'e2e_latency']].groupby(\"path\").agg(['count', 'mean', 'min', 'max']).reset_index()\n",
"df_print['path'] = df_print['path'].apply(lambda path: \" -> \".join(filter(lambda part: part.startswith(\"/\"), path.split(\" -> \"))))\n",
"df_print = df_print.sort_values((\"e2e_latency\", \"count\"), ascending=False)\n",
"df_print.to_csv(os.path.join(OUT_PATH, \"e2e_overview.csv\"), sep=\"\\t\", index=False)\n",
"df_print"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
2022-11-07 17:46:09 +09:00
"execution_count": 4,
2022-10-28 22:37:48 +09:00
"outputs": [],
"source": [
2022-11-07 17:46:09 +09:00
"%%skip_if_false MANUAL_CACHE\n",
"\n",
2022-10-28 22:37:48 +09:00
"import pickle\n",
2022-11-07 17:46:09 +09:00
"# with open(\"state.pkl\", \"wb\") as f:\n",
"# pickle.dump((trees_paths, all_paths, lidar_paths, cohorts), f)\n",
2022-10-28 22:37:48 +09:00
"with open(\"state.pkl\", \"rb\") as f:\n",
2022-11-07 17:46:09 +09:00
" (trees_paths, all_paths, relevant_paths, cohorts) = pickle.load(f)"
2022-10-28 22:37:48 +09:00
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
2022-11-07 17:46:09 +09:00
"execution_count": 12,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1183 1\n",
"\n",
"\n",
" (11342)\n",
" void(pointcloud_preprocessor::Filter)(sensor_msgs::msg::PointCloud2,pcl_msgs::msg::PointIndices)\n",
" -> /sensing/lidar/top/outlier_filtered/pointcloud\n",
" -> void(pointcloud_preprocessor::PointCloudConcatenateDataSynchronizerComponent)(sensor_msgs::msg::PointCloud2,std::__cxx11::basic_string<char,std::char_traits<char>,>)\n",
" -> void(pointcloud_preprocessor::PointCloudConcatenateDataSynchronizerComponent)()\n",
" -> /sensing/lidar/concatenated/pointcloud\n",
" -> void(message_filters::Subscriber<sensor_msgs::msg::PointCloud2>subscribe(rclcpp::Node,std::__cxx11::basic_string<char,std::char_traits<char>,>,rmw_qos_profile_t))(sensor_msgs::msg::PointCloud2)\n",
" -> /perception/occupancy_grid_map/map\n",
" -> void(behavior_path_planner::BehaviorPathPlannerNode)(nav_msgs::msg::OccupancyGrid)\n",
" -> void(behavior_path_planner::BehaviorPathPlannerNode)()\n",
" -> /planning/scenario_planning/lane_driving/behavior_planning/path_with_lane_id\n",
" -> void(behavior_velocity_planner::BehaviorVelocityPlannerNode)(autoware_auto_planning_msgs::msg::PathWithLaneId)\n",
" -> /planning/scenario_planning/lane_driving/behavior_planning/path\n",
" -> void(ObstacleAvoidancePlanner)(autoware_auto_planning_msgs::msg::Path)\n",
" -> /planning/scenario_planning/lane_driving/motion_planning/obstacle_avoidance_planner/trajectory\n",
" -> void(motion_planning::ObstacleStopPlannerNode)(autoware_auto_planning_msgs::msg::Trajectory)\n",
" -> /planning/scenario_planning/lane_driving/trajectory\n",
" -> void(ScenarioSelectorNode)(autoware_auto_planning_msgs::msg::Trajectory)\n",
" -> /planning/scenario_planning/scenario_selector/trajectory\n",
" -> void(motion_velocity_smoother::MotionVelocitySmootherNode)(autoware_auto_planning_msgs::msg::Trajectory)\n",
" -> /planning/scenario_planning/trajectory\n",
" -> void(autoware::motion::control::trajectory_follower_nodes::Controller)(autoware_auto_planning_msgs::msg::Trajectory)\n",
" -> void(autoware::motion::control::trajectory_follower_nodes::Controller)()\n",
" -> /control/trajectory_follower/control_cmd\n",
" -> void(vehicle_cmd_gate::VehicleCmdGate)(autoware_auto_control_msgs::msg::AckermannControlCommand)\n",
" -> /control/command/control_cmd\n"
]
}
],
2022-10-28 22:37:48 +09:00
"source": [
2022-11-07 17:46:09 +09:00
"##################################################\n",
"# Filter DFG paths through must-be-included and\n",
"# cannot-be-included patterns\n",
"##################################################\n",
2022-10-28 22:37:48 +09:00
"\n",
"cohorts_filt = {k: v for k, v in cohorts.items()\n",
2022-11-07 17:46:09 +09:00
" if not any(re.search(f, k) for f in E2E_EXCL_PATH_PATTERNS) and all(re.search(f, k) for f in E2E_INCL_PATH_PATTERNS)}\n",
2022-10-28 22:37:48 +09:00
"\n",
"\n",
"print(len(cohorts), len(cohorts_filt))\n",
"for k, v in cohorts_filt.items():\n",
" print(f\"\\n\\n ({len(v)})\\n \", end=\"\")\n",
" print(\"\\n -> \".join(k.split(\" -> \")))\n",
"\n",
2022-11-07 17:46:09 +09:00
"if len(cohorts_filt) != 1:\n",
" print(f\"[WARN] Expected exactly one cohort to remain, got {len(cohorts_filt)}. Only the first one will be used.\")\n",
"\n",
"relevant_path, relevant_dataflows = next(iter(cohorts_filt.items()))"
2022-10-28 22:37:48 +09:00
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
2022-11-07 17:46:09 +09:00
"execution_count": 14,
2022-10-28 22:37:48 +09:00
"outputs": [],
"source": [
2022-11-07 17:46:09 +09:00
"from message_tree.message_tree_algorithms import e2e_latency_breakdown\n",
2022-10-28 22:37:48 +09:00
"\n",
2022-11-07 17:46:09 +09:00
"##################################################\n",
"# Break down the E2E latency into its constituent\n",
"# latencies.\n",
"##################################################\n",
"\n",
"e2e_breakdowns = list(map(e2e_latency_breakdown, relevant_dataflows))\n",
"filt = [(path, bdown) for (path, bdown) in zip(relevant_dataflows, e2e_breakdowns)\n",
2022-10-28 22:37:48 +09:00
" if not any(True for item in bdown\n",
" if item.type == \"idle\" and item.duration > item.location[1].callback_obj.owner.period * 1e-9)]\n",
"\n",
2022-11-07 17:46:09 +09:00
"# Backup for debug purposes.\n",
"lidar_cohort_orig = relevant_dataflows\n",
2022-10-28 22:37:48 +09:00
"e2e_breakdowns_orig = e2e_breakdowns\n",
"\n",
2022-11-07 17:46:09 +09:00
"relevant_dataflows, e2e_breakdowns = zip(*filt)"
2022-10-14 00:15:33 +09:00
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
2022-11-07 17:46:09 +09:00
"execution_count": 15,
"outputs": [
{
"data": {
"text/plain": "<Figure size 4800x2700 with 3 Axes>",
"image/png": "iVBORw0KGgoAAAANSUhEUgAAD4MAAAm+CAYAAAAQGQ0AAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAC4jAAAuIwF4pT92AAEAAElEQVR4nOzdd5gkV3k37N8jCQmQQCInASIHkXNGJJMz2B9gsknG2AYnwBjkBH5tY+Al2xgwNn6xydiAsQkiiyxyMDlHIRBBSEjP90f1wmxNz0x3z+xM7+59X9dc0Kerzjk9U326ttS/eqq7AwAAAAAAAAAAAAAAAAAAwHI5YKcnAAAAAAAAAAAAAAAAAAAAwGrC4AAAAAAAAAAAAAAAAAAAAEtIGBwAAAAAAAAAAAAAAAAAAGAJCYMDAAAAAAAAAAAAAAAAAAAsIWFwAAAAAAAAAAAAAAAAAACAJSQMDgAAAAAAAAAAAAAAAAAAsISEwQEAAAAAAAAAAAAAAAAAAJaQMDgAAAAAAAAAAAAAAAAAAMASEgYHAAAAAAAAAAAAAAAAAABYQsLgAAAAAAAAAAAAAAAAAAAAS0gYHAAAAAAAAAAAAAAAAAAAYAkJgwMAAAAAAAAAAAAAAAAAACwhYXAAAAAAAAAAAAAAAAAAAIAlJAwOAAAAAAAAAAAAAAAAAACwhITBAQAAAAAAAAAAAAAAAAAAlpAwOAAAAAAAAAAAAAAAAAAAwBISBgcAAAAAAAAAAAAAAAAAAFhCwuAAAAAAAAAAAAAAAAAAAABLSBgcAAAAAAAAAAAAAAAAAABgCQmDAwAAAAAAAAAAAAAAAAAALCFhcAAAAAAAAAAAAAAAAAAAgCUkDA4AAAAAAAAAAAAAAAAAALCEhMEBAAAAAAAAAAAAAAAAAACWkDA4AAAAAAAAAAAAAAAAAADAEhIGBwAAAAAAAAAAA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ukuRs62z3jSSvSvJX3f3lWfuf7HtsRtXsV86xqi6R5HFJfjXJWdfo5ltV9awkT+7uH88z/hpzuniS301yqwzhx/X8pKremuTlSV4yHr+qLpkhmLLy9/7C7r7/Juf46iR3WNF0apIju/s7m+l3G/xwStsBs+xYVS9MsvIY/1J3H7Xi+VsneVSG4/XAKV3cP8kLNxjjhkkenuQWGQLgazmxql6X5End/YkZpj9trHMnuXOSmye5cYZg0XpOrarjkzwjyct36oYSVfXbSZ6S3f9uP0tyv+5+yQz7XynJ45PcJkPgfdo2n0/yf5M8a6sD2VV1wSR/mOH9c7F1Nj25qt6U5Gndfdwc/b87Q3B6l//u7lvOuO+vJvm3KU9dr7vfPWMfn0hyuRVN/97dv7bGti/M+u+pq2RYf++Q5Exr9PGlJE9O8pxlCs9X1fmSPDrJ/TLcFGKab1fVvyf5s1nWTuv5bqaFX8+9SEdVdUiSB2X4nL9u1vm+y+T4/pckT+/uHy043qUzrPO/lo3X3ST5aVW9P8l/JXlZd39mgTHvnuE13ihDaHmt7T6e5GVJ/q67p31erjfGMUneMmq+yTzr14q+vpjkoiua/qm777fBPvdL8oJR88W6+4uT54/OsPbeNdPPk/8pybrnxFt5fraRyU1h7pXk3klumCH0u9a2X0jy7xnO6787zzjLpqr+Ocmvr2g6I8klu3u9f4Ns1OdVknxo1PzU7n7klG2PyTrH8eQYeFyG9+9a/y748uR1PGmL/l2wrWsUAAAAAAD7n5m+MAEAAAAAAOyzpn05/qfbPot9XFWdq6o+mCEc9ldJfiUbB8GTobLq3ZIcX1WvnlQyXhpVda1JoHFXQG3NIPjEBZI8LMn/VtUTJwGarZjHwzNU/r5f1g58JEOY60+TfGwSzF90vHNX1fOTfDrJI7Jx0CiTed06yfMyVJvdTXd
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
2022-10-14 00:15:33 +09:00
"source": [
"%%skip_if_false E2E_ENABLED\n",
2022-10-28 22:37:48 +09:00
"%%skip_if_false E2E_PLOT\n",
2022-08-29 22:17:52 +02:00
"\n",
2022-11-07 17:46:09 +09:00
"##################################################\n",
"# Output the chosen DFG path to a file\n",
"##################################################\n",
"\n",
2022-10-28 22:37:48 +09:00
"from message_tree.message_tree_algorithms import e2e_latency_breakdown\n",
2022-08-29 22:17:52 +02:00
"\n",
2022-10-28 22:37:48 +09:00
"conv_items = [i for p in e2e_breakdowns for i in p]\n",
"with open(\"out/plot_e2es_path.txt\", \"w\") as f:\n",
2022-11-07 17:46:09 +09:00
" f.write(f\"Number of path instances: {len(relevant_dataflows)}\\n\")\n",
" f.write( \" \" + \"\\n -> \".join(relevant_path.split(\" -> \")))\n",
2022-10-28 22:37:48 +09:00
" f.write(\"\\n\")\n",
2022-08-29 22:17:52 +02:00
"\n",
2022-10-28 22:37:48 +09:00
"conv_items_unique = set(conv_items)\n",
2022-08-29 22:17:52 +02:00
"\n",
2022-10-28 22:37:48 +09:00
"def e2e_breakdown_type_hist__(items):\n",
" \"\"\"\n",
" Given a list of e2e breakdown instances of the form `(\"<type>\", <duration>)`, plots a histogram for each encountered\n",
" type.\n",
" \"\"\"\n",
" plot_types = (\"dds\", \"idle\", \"cpu\")\n",
" #assert all(item.type in plot_types for item in items)\n",
"\n",
" plt.close(\"E2E type breakdown histograms\")\n",
" fig, axes = plt.subplots(1, 3, num=\"E2E type breakdown histograms\", dpi=300, figsize=(16, 9))\n",
" fig.suptitle(\"E2E Latency Breakdown by Resource Type\")\n",
"\n",
" for type, ax in zip(plot_types, axes):\n",
" durations = [item.duration for item in items if item.type == type]\n",
"\n",
" df = pd.Series(durations)\n",
" df.to_csv(f\"out/plot_e2es_{type}_portion.csv\", header=[f\"e2e_latency_{type}_portion_s\"], index=False)\n",
"\n",
" ax.set_title(type)\n",
" ax.hist(durations, bins=50)\n",
" #ax.set_yscale(\"log\")\n",
" ax.set_xlabel(\"Duration [s]\")\n",
" ax.set_ylabel(\"Occurrences\")\n",
"\n",
" return fig\n",
"\n",
2022-11-07 17:46:09 +09:00
"##################################################\n",
"# Plot DDS/idle/computation time histograms\n",
"# Histograms show individual latency components\n",
"# over all dataflows (de-duplicated)\n",
"##################################################\n",
"\n",
2022-10-28 22:37:48 +09:00
"fig = e2e_breakdown_type_hist__(conv_items_unique)\n",
"plt.savefig(\"out/plot_e2e_portions.png\")\n",
"\n",
"None\n"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
2022-11-07 17:46:09 +09:00
"execution_count": 16,
"outputs": [
{
"data": {
"text/plain": "<Figure size 4800x2700 with 1 Axes>",
"image/png": "iVBORw0KGgoAAAANSUhEUgAAD2kAAAm+CAYAAAAw2ZC4AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAC4jAAAuIwF4pT92AAEAAElEQVR4nOzdeZjdVX0/8PdJwg5hJwWUNagYQNCWTawgooKgglhRFsNSt9qC/HAXUCtFi8VqRaiVBCNSKRQURTYXQDYNglY2SYCEfd8SQCDh/P64kzFzcycz31kDeb2eZx5zzv2ecz53Zu6X5zF5fz+l1hoAAAAAAAAAAAAAAAAAAAD6Z8xoFwAAAAAAAAAAAAAAAAAAAPBiIqQNAAAAAAAAAAAAAAAAAADQgJA2AAAAAAAAAAAAAAAAAABAA0LaAAAAAAAAAAAAAAAAAAAADQhpAwAAAAAAAAAAAAAAAAAANCCkDQAAAAAAAAAAAAAAAAAA0ICQNgAAAAAAAAAAAAAAAAAAQANC2gAAAAAAAAAAAAAAAAAAAA0IaQMAAAAAAAAAAAAAAAAAADQgpA0AAAAAAAAAAAAAAAAAANCAkDYAAAAAAAAAAAAAAAAAAEADQtoAAAAAAAAAAAAAAAAAAAANCGkDAAAAAAAAAAAAAAAAAAA0IKQNAAAAAAAAAAAAAAAAAADQgJA2AAAAAAAAAAAAAAAAAABAA0LaAAAAAAAAAAAAAAAAAAAADQhpAwAAAAAAAAAAAAAAAAAANCCkDQAAAAAAAAAAAAAAAAAA0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3aPSVcu5SW7s51l92SLJx/K
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
2022-10-28 22:37:48 +09:00
"source": [
"%%skip_if_false E2E_ENABLED\n",
"%%skip_if_false E2E_PLOT\n",
2022-09-12 19:24:26 +02:00
"\n",
2022-11-07 17:46:09 +09:00
"##################################################\n",
"# Plot histogram of all E2E latencies observed\n",
"##################################################\n",
"\n",
"e2es = [path[-1].timestamp - path[0].timestamp for path in relevant_dataflows]\n",
2022-10-28 22:37:48 +09:00
"\n",
"df = pd.Series(e2es)\n",
"df.to_csv(\"out/plot_e2es.csv\", index=False, header=[\"e2e_latency_s\"])\n",
"\n",
"plt.close(\"E2E histogram\")\n",
"fig, ax = plt.subplots(num=\"E2E histogram\", dpi=300, figsize=(16, 9))\n",
"fig.suptitle(\"E2E Latency Histogram\")\n",
"ax: plt.Axes\n",
"ax.hist(e2es, bins=30)\n",
"ax.set_xlabel(\"E2E Latency [s]\")\n",
"ax.set_ylabel(\"Occurrences\")\n",
"ax.axvline(np.mean(e2es), c=\"red\", linewidth=2)\n",
"_, max_ylim = ax.get_ylim()\n",
"ax.text(np.mean(e2es) * 1.02, max_ylim * 0.98, 'Mean: {:.3f}s'.format(np.mean(e2es)))\n",
"plt.savefig(\"out/plot_e2es.png\")\n",
"None"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
2022-11-07 17:46:09 +09:00
"execution_count": 34,
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Calculating breakdowns: 100%|██████████| 1492/1492 [00:00<00:00, 34221.62it/s]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"27 27\n"
]
},
{
"data": {
"text/plain": "<Figure size 4800x1500 with 1 Axes>",
"image/png": "iVBORw0KGgoAAAANSUhEUgAAD3YAABXYCAYAAACYr1AgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYf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V9K2TqtwPVwr6q1fnyM85dkjNfU0PGnJ3lzWjecaKeWUn6Z5Kha68kT1QcAAAAAALCm6egfKgEAAAAAAKBL7QKwd854FXNcKWWLUsqv0gruvi+twNhEIb2k1SH0WUl+UUo5qZSyae+q7F4p5aFDAbtV4eExQ91D7plWKO3iUsp7hoKS01HHq9PqyP2ijB3qTpJ7JDkqye+GQpOT3W/LUspnk/w5yeGZONSdobqemOQzSa5pHqy1XpLklMb0s0spm02hzu3TCjwP9401PNSdJLe0mdu0OVFKOSStx/KUJK9N8sBMEOoecu8k/57k8qHnzhqplDKvlPLuJOcleWbGCHUPuVeSY5OcMxTenK22bDM3pefr0Gv9V0k+lrFD3ROt8YQkv01yQpKDMk6oe8jOSd6S5C+llCO63GtWfl4MvVf9MKND3RcmedhEoe6h99VvJflmWsH5sV7LJckjkpxUSvlaKWW89/yODe3/lSTnJnlOxgl1D9k2ycuS/LGU8uFSyroT7VFrvS1JM3R/UBdlHthmbqMkD5/C9T/qYv8kSSll01LKt9P6WY0V6k5aP6uHJvleKeXzQzfiAAAAAAAAmDUEuwEAAAAAAJhWpZT5aYXPmkaFTpmyjZPsPcU1npLk3KGwbt+VUp6b5KcZP9Q1lnWSvDXJt4c6mE6ljvckOS4TBy2H2ynJWaWU7Sax3wOT/DLJi5NMNqQ2VgD+uMZ
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
2022-10-28 22:37:48 +09:00
"source": [
2022-11-07 17:46:09 +09:00
"%%skip_if_false E2E_ENABLED\n",
"%%skip_if_false E2E_PLOT\n",
"\n",
"from message_tree.message_tree_algorithms import label_latency_item\n",
"\n",
"##################################################\n",
"# Plot violin plot of latencies on each station\n",
"# of the DFG path (aggregated over all dataflows)\n",
"##################################################\n",
2022-10-28 22:37:48 +09:00
"\n",
"plt.close(\"E2E path breakdown\")\n",
"fig, ax = plt.subplots(num=\"E2E path breakdown\", dpi=300, figsize=(16, 5))\n",
"fig.suptitle(\"E2E Latency Path Breakdown\")\n",
"ax: plt.Axes\n",
"\n",
2022-11-07 17:46:09 +09:00
"component_durations = list(zip(*[e2e_latency_breakdown(p) for p in tqdm(relevant_dataflows, desc=\"Calculating breakdowns\")]))\n",
"component_latency_items = component_durations\n",
"labels = [label_latency_item(item) for item in e2e_latency_breakdown(relevant_dataflows[0])]\n",
"types = [item.type for item in e2e_latency_breakdown(relevant_dataflows[0])]\n",
2022-10-28 22:37:48 +09:00
"component_durations = [list(map(lambda item: item.duration, d)) for d in component_durations]\n",
"print(len(component_durations), len(labels))\n",
"\n",
"import matplotlib.patches as mpatches\n",
"\n",
"legend_entries = []\n",
"def add_label(violin, label):\n",
" color = violin[\"bodies\"][0].get_facecolor().flatten()\n",
" legend_entries.append((mpatches.Patch(color=color), label))\n",
"\n",
"for type in (\"idle\", \"dds\", \"cpu\"):\n",
" indices = [i for i, t in enumerate(types) if t == type]\n",
" xs = [component_durations[i] for i in indices]\n",
" vln = ax.violinplot(xs, indices)\n",
" add_label(vln, type)\n",
" for i, x in zip(indices, xs):\n",
" df_out = pd.Series(x)\n",
" df_out.to_csv(f\"out/plot_e2es_violin_{i:02d}.csv\", index=False, header=[\"duration_s\"])\n",
"ax.set_ylabel(\"Latency contribution [s]\")\n",
"ax.set_xticks(range(len(labels)), labels, rotation=90)\n",
"ax.legend(*zip(*legend_entries))\n",
"plt.savefig(\"out/plot_e2es_violin.png\")\n",
"\n",
"df_labels = pd.Series(labels)\n",
"df_labels.to_csv(\"out/plot_e2es_violin_labels.csv\", index=False, header=[\"label\"])\n",
"\n",
"df_types = pd.Series(types)\n",
"df_types.to_csv(\"out/plot_e2es_violin_types.csv\", index=False, header=[\"type\"])\n",
"\n",
"None"
2022-10-14 00:15:33 +09:00
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
2022-11-07 17:46:09 +09:00
"execution_count": 29,
2022-10-14 00:15:33 +09:00
"outputs": [],
2022-11-07 17:46:09 +09:00
"source": [
"for concat_pc_items in component_latency_items:\n",
" if not isinstance(concat_pc_items[0].location[0], TrPublishInstance):\n",
" continue\n",
" dur_ts_records = [(item.location[0].timestamp, item.duration) for item in concat_pc_items]\n",
" df_dur_ts = pd.DataFrame(dur_ts_records, columns=(\"timestamp\", \"duration\"))\n",
" df_dur_ts.to_csv(f\"dur_ts_{concat_pc_items[0].location[0].publisher.topic_name.replace('/', '__')}.csv\", index=False)"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 33,
"outputs": [],
"source": [
"indices = [i for i, t in enumerate(types) if t == \"cpu\"]\n",
"xs = [np.array(list(map(lambda item: item.location[0].duration, component_latency_items[i]))) for i in indices]\n",
"lbls = [labels[i] for i in indices]\n",
"\n",
"records = [(lbl, x.mean(), x.std(), x.min(), x.max()) for x, lbl in zip(xs, lbls)]\n",
"df_cpu = pd.DataFrame(records, columns=[\"callback\", \"mean\", \"std\", \"min\", \"max\"])\n",
"df_cpu.to_csv(\"out/calc_times.csv\", index=False)"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 18,
"outputs": [
{
"data": {
"text/plain": "<Figure size 4800x2700 with 1 Axes>",
"image/png": "iVBORw0KGgoAAAANSUhEUgAADz0AAAmFCAYAAADum0HkAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAC4jAAAuIwF4pT92AAEAAElEQVR4nOzdd5xtV1k//s+ThEAgkCChBwi9dwhdgoCASEeRJkW+CqhUBWwUC+BPFFAUFAQEsSFVaVJD7wRROgSkJwgBAgRI8vz+2OfK3D1nZs6cKfvem/f79ZqXnrX3XmvNOWevvS+Zz36quwMAAAAAAAAAAAAAAAAAADCVg6aeAAAAAAAAAAAAAAAAAAAAcNYm9AwAAAAAAAAAAAAAAAAAAExK6BkAAAAAAAAAAAAAAAAAAJiU0DMAAAAAAAAAAAAAAAAAADApoWcAAAAAAAAAAAAAAAAAAGBSQs8AAAA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fKYzyT5hyR/3t1fX2RC875/I28enouyrr/r7vsuMt5o7Gtk+G7fPsnZ1tjn80n+NMmz9uWHxyzg23PaDlrkwKr6XIbQ5R7/937PHsjwgCQPyvAdmefNGR7As1b/ByW5Z5J7Z7gfPMc6+56Y5F8yrN0Lfcfm9LHj14vtVlWHJnluhvdppS8m+ZlFgsJT3wdW1XWSPDLJT2cIW6+135eTvGo2j4VC7rOHMnwje5/Hv93dT1rw+L/K8B1e6dQkP7HIeV9VF8gQRl7pwd39zDX2/1zWOKdm2++U5FEZHsYwT1fV+5I8obtfvdH8AAAAAADgQLPQf+QCAAAAAAAW9tQMle9WOjSrq++tq6ouXFUvSnJCkvtl/cBzMlTKu2OSd1XVy6tqzbDBbpiFef8
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
2022-10-14 00:15:33 +09:00
"source": [
"%%skip_if_false E2E_ENABLED\n",
"%%skip_if_false E2E_PLOT\n",
2022-08-29 22:17:52 +02:00
"\n",
2022-10-14 00:15:33 +09:00
"from message_tree.message_tree_plots import e2e_breakdown_inst_stack\n",
"\n",
"\n",
2022-10-28 22:37:48 +09:00
"fig = e2e_breakdown_inst_stack(*e2e_breakdowns)\n",
"fig.set_size_inches(16, 9)\n",
"fig.set_dpi(300)\n",
"None"
2022-09-15 15:26:32 +02:00
],
2022-09-14 18:27:41 +02:00
"metadata": {
2022-09-20 12:44:04 +02:00
"collapsed": false
2022-09-15 15:26:32 +02:00
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
2022-09-09 13:52:28 +02:00
"source": [
2022-10-14 00:15:33 +09:00
"%%skip_if_false E2E_ENABLED\n",
"%%skip_if_false DEBUG\n",
"\n",
2022-10-13 19:13:39 +09:00
"import pickle\n",
2022-10-07 15:35:34 +09:00
"\n",
2022-10-13 19:13:39 +09:00
"with open(\"trees.pkl\", \"wb\") as f:\n",
2022-10-14 00:15:33 +09:00
" pickle.dump(trees, f)"
2022-09-15 15:26:32 +02:00
],
2022-10-07 15:35:34 +09:00
"metadata": {
"collapsed": false
}
},
2022-11-07 17:46:09 +09:00
{
"cell_type": "code",
"execution_count": 15,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[('/sensing/lidar/top/outlier_filtered/pointcloud', TrSubscription(id=140479461202528, timestamp=1659973557952273201, node_handle=140479460571600, rmw_handle=140479461243872, topic_name='/sensing/lidar/top/outlier_filtered/pointcloud', depth=5)), ('/sensing/lidar/concatenated/pointcloud', TrSubscription(id=140107068367504, timestamp=1659973557827122999, node_handle=140107067792304, rmw_handle=140107068367696, topic_name='/sensing/lidar/concatenated/pointcloud', depth=1)), ('/perception/occupancy_grid_map/map', TrSubscription(id=94693468153792, timestamp=1659973558160675676, node_handle=94693466833888, rmw_handle=94693468215216, topic_name='/perception/occupancy_grid_map/map', depth=1)), ('/planning/scenario_planning/lane_driving/behavior_planning/path_with_lane_id', TrSubscription(id=139977017576848, timestamp=1659973578471689633, node_handle=139977016757536, rmw_handle=139977017582464, topic_name='/planning/scenario_planning/lane_driving/behavior_planning/path_with_lane_id', depth=1)), ('/planning/scenario_planning/lane_driving/behavior_planning/path', TrSubscription(id=140321347413936, timestamp=1659973558154985535, node_handle=140321346411520, rmw_handle=140321347569968, topic_name='/planning/scenario_planning/lane_driving/behavior_planning/path', depth=1)), ('/planning/scenario_planning/lane_driving/motion_planning/obstacle_avoidance_planner/trajectory', TrSubscription(id=140319803626640, timestamp=1659973558699873542, node_handle=140319802819728, rmw_handle=140319803824240, topic_name='/planning/scenario_planning/lane_driving/motion_planning/obstacle_avoidance_planner/trajectory', depth=1)), ('/planning/scenario_planning/lane_driving/trajectory', TrSubscription(id=94703110125776, timestamp=1659973557847262306, node_handle=94703109406576, rmw_handle=94703110125808, topic_name='/planning/scenario_planning/lane_driving/trajectory', depth=1)), ('/planning/scenario_planning/scenario_selector/trajectory', TrSubscription(id=94629381271760, timestamp=1659973557917228380, node_handle=94629380316800, rmw_handle=94629381273568, topic_name='/planning/scenario_planning/scenario_selector/trajectory', depth=1)), ('/planning/scenario_planning/trajectory', TrSubscription(id=93868493667648, timestamp=1659973557705002711, node_handle=93868492546928, rmw_handle=93868493668080, topic_name='/planning/scenario_planning/trajectory', depth=1)), ('/control/trajectory_follower/control_cmd', TrSubscription(id=93868493723712, timestamp=1659973557706367909, node_handle=93868492546928, rmw_handle=93868493724064, topic_name='/control/trajectory_follower/control_cmd', depth=1)), ('/control/command/control_cmd', TrSubscription(id=94405189168336, timestamp=1659973557630990964, node_handle=94405188697840, rmw_handle=94405189241392, topic_name='/control/command/control_cmd', depth=1))]\n"
]
}
],
"source": [
"ctx = relevant_paths[0][0]._c\n",
"topics = ctx.topics\n",
"\n",
"topics_of_interest = [item.publisher.topic_name for item in relevant_dataflows[0] if isinstance(item, TrPublishInstance)]\n",
"\n",
"topic_records = []\n",
"for t in topics_of_interest:\n",
" topic_records.append((t, topics.by_name[t].subscriptions[0]))\n",
"\n",
"print(topic_records)"
],
"metadata": {
"collapsed": false
}
},
2022-10-07 15:35:34 +09:00
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [],
"metadata": {
"collapsed": false
}
2022-05-23 13:03:38 +02:00
}
],
"metadata": {
"interpreter": {
2022-06-28 10:06:42 +02:00
"hash": "e7370f93d1d0cde622a1f8e1c04877d8463912d04d973331ad4851f04de6915a"
2022-05-23 13:03:38 +02:00
},
"kernelspec": {
2022-09-14 18:27:41 +02:00
"display_name": "Python 3 (ipykernel)",
2022-05-23 13:03:38 +02:00
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
2022-09-14 18:27:41 +02:00
"version": "3.10.4"
2022-05-23 13:03:38 +02:00
}
},
"nbformat": 4,
"nbformat_minor": 2
2022-09-20 12:44:04 +02:00
}