Skip to content

Commit

Permalink
Reflected review results
Browse files Browse the repository at this point in the history
  • Loading branch information
miyakoshi-dev committed Dec 24, 2024
1 parent cbfcec7 commit 149f402
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 44 deletions.
2 changes: 2 additions & 0 deletions src/caret_analyze/infra/lttng/lttng_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,8 @@ def tilde_subscriptions(self) -> TracePointData:
def timer_controls(self) -> TracePointData:
return self._timer_control

@staticmethod
@lru_cache
def _get_distribution(data: Ros2DataModel) -> str:
caret_init_df = data.caret_init.df
distributions = list(caret_init_df['distribution'].unique())
Expand Down
6 changes: 6 additions & 0 deletions src/caret_analyze/infra/lttng/ros2_tracing/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def __init__(

self._monotonic_to_system_offset: int | None = monotonic_to_system_time_offset
self._caret_init_recorded: defaultdict[int, bool] = defaultdict(lambda: False)
self._distributions_cache: str | None = None

# Temporary buffers
self._callback_instances: dict[int, tuple[dict, Any]] = {}
Expand Down Expand Up @@ -358,6 +359,10 @@ def _is_valid_data(self, event) -> bool:
return self._caret_init_recorded[pid]

def _get_distribution(self, data: Ros2DataModel) -> str:

if self._distributions_cache is not None:
return self._distributions_cache

caret_init_df = data._caret_init._data
distributions = list(set(caret_init_df['distribution']))
if len(distributions) > 1:
Expand All @@ -366,6 +371,7 @@ def _get_distribution(self, data: Ros2DataModel) -> str:
if len(distributions) == 0:
return 'NOTFOUND'

self._distributions_cache = distributions[0]
return distributions[0]

def _handle_rcl_init(
Expand Down
58 changes: 15 additions & 43 deletions src/test/infra/lttng/test_lttng.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ def test_compare_init_event(self, distribution):
assert init_events[RESULT_ORDER_ETC+5]['_timestamp'] == 600 and \
init_events[RESULT_ORDER_ETC+5]['_name'] == 'ros2:rclcpp_ipb_to_subscription'

def test_duplicated_events_contexts(self, mocker):
def test_duplicated_events_contexts(self):
HDL_CONTEXT = 1000101
VTID1 = 500001
VPID1 = 600001
Expand Down Expand Up @@ -679,7 +679,7 @@ def test_duplicated_events_contexts(self, mocker):
assert lttng.data.contexts.df.index[1] == 1 and \
lttng.data.contexts.df.iloc[1]['timestamp'] == 100100102

def test_duplicated_events_nodes(self, mocker):
def test_duplicated_events_nodes(self):
HDL_NODE = 1000201
HDL_RMW = 1000211
VTID1 = 500001
Expand Down Expand Up @@ -722,7 +722,7 @@ def test_duplicated_events_nodes(self, mocker):
lttng.data.nodes.df.iloc[1]['timestamp'] == 100100203 and \
lttng.data.nodes.df.iloc[1]['rmw_handle'] == 1

def test_duplicated_events_publisher(self, mocker):
def test_duplicated_events_publisher(self):
HDL_NODE = 1000201
HDL_RMW = 1000211
HDL_PUBLISHER = 1000301
Expand Down Expand Up @@ -794,7 +794,7 @@ def test_duplicated_events_publisher(self, mocker):
lttng.data.publishers.df.iloc[1]['node_handle'] == 1 and \
lttng.data.publishers.df.iloc[1]['rmw_handle'] == 1

def test_duplicated_events_subscriptions(self, mocker):
def test_duplicated_events_subscriptions(self):
HDL_NODE = 1000201
HDL_RMW = 1000211
HDL_SUBSCRIPTION = 1000401
Expand Down Expand Up @@ -933,7 +933,7 @@ def test_duplicated_events_subscriptions(self, mocker):
lttng.data.callback_objects.df.iloc[1]['timestamp'] == 100100462 and \
lttng.data.callback_objects.df.iloc[1]['callback_object'] == 1

def test_duplicated_events_service(self, mocker):
def test_duplicated_events_service(self):
HDL_NODE = 1000201
HDL_RMW = 1000211
HDL_SERVICE = 1000501
Expand Down Expand Up @@ -1026,7 +1026,7 @@ def test_duplicated_events_service(self, mocker):
lttng.data.callback_objects.df.iloc[1]['timestamp'] == 100100221 and \
lttng.data.callback_objects.df.iloc[1]['callback_object'] == 1

def test_duplicated_events_clients(self, mocker):
def test_duplicated_events_clients(self):
HDL_NODE = 1000201
HDL_RMW = 1000211
HDL_CLIENT = 1000601
Expand Down Expand Up @@ -1092,7 +1092,7 @@ def test_duplicated_events_clients(self, mocker):
lttng.data.clients.df.iloc[1]['node_handle'] == 1 and \
lttng.data.clients.df.iloc[1]['rmw_handle'] == 1

def test_duplicated_events_timers(self, mocker):
def test_duplicated_events_timers(self):
HDL_NODE = 1000201
HDL_RMW = 1000211
TIMER_CALLBACK = 1000661
Expand Down Expand Up @@ -1232,7 +1232,7 @@ def test_duplicated_events_timers(self, mocker):
lttng.data.callback_symbols.df.iloc[1]['timestamp'] == 100100782 and \
lttng.data.callback_symbols.df.iloc[1]['symbol'] == 101

def test_duplicated_events_lifecycle_state_machines(self, mocker):
def test_duplicated_events_lifecycle_state_machines(self):
HDL_NODE = 1000201
HDL_RMW = 1000211
STATE_MACHINE = 1000801
Expand Down Expand Up @@ -1289,7 +1289,7 @@ def test_duplicated_events_lifecycle_state_machines(self, mocker):
assert lttng.data.lifecycle_state_machines.df.index[1] == 1 and \
lttng.data.lifecycle_state_machines.df.iloc[1]['node_handle'] == 1

def test_duplicated_events_caret_init(self, mocker):
def test_duplicated_events_caret_init(self):
VTID1 = 500001
VPID1 = 600001

Expand Down Expand Up @@ -1324,9 +1324,9 @@ def test_duplicated_events_caret_init(self, mocker):

@pytest.mark.parametrize(
'distribution',
['jazzy', 'iron'],
['jazzy'],
)
def test_duplicated_events_entities_collector(self, mocker, distribution):
def test_duplicated_events_entities_collector(self, distribution):
HDL_EXECUTOR = 1001101
EXECUTOR_CALLBACK = 1001261
HDL_EXECUTOR_ENTITY = 1000701
Expand Down Expand Up @@ -1383,9 +1383,6 @@ def test_duplicated_events_entities_collector(self, mocker, distribution):

# executors
# ['timestamp', 'callback_group_addr', 'callback_group_collection_addr']
assert lttng.data.callback_group_to_executor_entity_collector.\
df.iloc[0]['group_type_name'] == 'reentrant'

assert lttng.data.callback_group_to_executor_entity_collector.\
df.index[0] == HDL_EXECUTOR_ENTITY and \
lttng.data.callback_group_to_executor_entity_collector.\
Expand All @@ -1408,16 +1405,14 @@ def test_duplicated_events_entities_collector(self, mocker, distribution):
'distribution',
['jazzy', 'iron'],
)
def test_duplicated_events_executors(self, mocker, distribution):
def test_duplicated_events_executors(self, distribution):
HDL_EXECUTOR = 1001101
HDL_EXECUTOR_STATIC = 1001201
HDL_ENTITIES = 1001211
VTID1 = 500001
VPID1 = 600001

if distribution[0] >= 'jazzy'[0]:
EXECUTOR_CALLBACK = 1001261

events = [
{
'_name': 'ros2_caret:caret_init',
Expand All @@ -1427,24 +1422,6 @@ def test_duplicated_events_executors(self, mocker, distribution):
'_vtid': VTID1,
'_vpid': VPID1
},
{
'_name': 'ros2_caret:callback_group_to_executor_entity_collector',
'entities_collector_addr': HDL_ENTITIES,
'callback_group_addr': EXECUTOR_CALLBACK,
'group_type_name': 'reentrant',
'_timestamp': 100101101,
'_vtid': VTID1,
'_vpid': VPID1
},
{
'_name': 'ros2_caret:callback_group_to_executor_entity_collector',
'entities_collector_addr': HDL_ENTITIES,
'callback_group_addr': EXECUTOR_CALLBACK,
'_timestamp': 100101260,
'group_type_name': 'mutually_exclusive',
'_vtid': VTID1,
'_vpid': VPID1
},
{
'_name': 'ros2_caret:executor_entity_collector_to_executor',
'executor_addr': HDL_EXECUTOR,
Expand Down Expand Up @@ -1614,7 +1591,7 @@ def test_duplicated_events_executors(self, mocker, distribution):
'distribution',
['jazzy', 'iron'],
)
def test_duplicated_events_callback_groups(self, mocker, distribution):
def test_duplicated_events_callback_groups(self, distribution):
HDL_NODE = 1000201
HDL_RMW = 1000211
HDL_TIMER = 1000701
Expand Down Expand Up @@ -2309,7 +2286,7 @@ def test_duplicated_events_callback_groups(self, mocker, distribution):
lttng.data.callback_group_client.df.iloc[1]['timestamp'] == 100101602 and \
lttng.data.callback_group_client.df.iloc[1]['client_handle'] == 1

def test_duplicated_events_buffer(self, mocker):
def test_duplicated_events_buffer(self):
HDL_NODE = 1000201
HDL_RMW = 1000211
HDL_SUBSCRIPTION = 1000401
Expand Down Expand Up @@ -2473,11 +2450,7 @@ def test_duplicated_events_buffer(self, mocker):
lttng.data.ipb_to_subscriptions.df.iloc[1]['timestamp'] == 100101902 and \
lttng.data.ipb_to_subscriptions.df.iloc[1]['subscription'] == 1

@pytest.mark.parametrize(
'distribution',
['jazzy', 'iron'],
)
def test_duplicated_events_runtime(self, mocker, distribution):
def test_duplicated_events_runtime(self):
HDL_NODE = 1000201
HDL_RMW = 1000211
HDL_PUBLISHER = 1000301
Expand Down Expand Up @@ -2808,7 +2781,6 @@ def test_duplicated_events_runtime(self, mocker, distribution):
},
{
'_name': 'ros2_caret:dds_write',
'rmw_publisher_handle': 200,
'message': 100,
'_timestamp': 100102901,
'_vtid': VTID1,
Expand Down
2 changes: 1 addition & 1 deletion src/test/infra/lttng/test_lttng_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,7 @@ def test_build_nodes_df(self):
).convert_dtypes()
assert nodes.df.equals(expect)

def test_build_cbg_diff(self):
def test_build_callback_groups_df(self):
group_type = 'reentrant'
collector_addr = 2
cbg_addr = 3
Expand Down

0 comments on commit 149f402

Please sign in to comment.