def log_memory_stats(self) -> None: hooks.add_obj_mem_stats( self.__class__.__name__, self.node.network_num, self.block_checking_alarms, "block_queue_block_checking_alarms", ObjectSize( size=len(self.block_checking_alarms) * (crypto.SHA256_HASH_LEN + constants.UL_INT_SIZE_IN_BYTES), flat_size=0, is_actual_size=False), object_item_count=len(self.block_checking_alarms), object_type=memory_utils.ObjectType.BASE, size_type=memory_utils.SizeType.ESTIMATE) hooks.add_obj_mem_stats( self.__class__.__name__, self.node.network_num, self.block_check_repeat_count, "block_queue_block_repeat_count", ObjectSize( size=len(self.block_check_repeat_count) * (crypto.SHA256_HASH_LEN + constants.UL_INT_SIZE_IN_BYTES), flat_size=0, is_actual_size=False), object_item_count=len(self.block_check_repeat_count), object_type=memory_utils.ObjectType.BASE, size_type=memory_utils.SizeType.ESTIMATE)
def log_connection_mem_stats(self) -> None: """ logs the connection's memory stats """ super(AbstractGatewayBlockchainConnection, self).log_connection_mem_stats() t0 = time.time() class_name = self.__class__.__name__ if self.node.message_converter is not None: hooks.add_obj_mem_stats(class_name, self.network_num, self.node.message_converter, "message_converter", memory_utils.ObjectSize( "message_converter", memory_utils.get_special_size( self.node.message_converter).size, is_actual_size=True), object_item_count=1, object_type=memory_utils.ObjectType.META, size_type=memory_utils.SizeType.SPECIAL) t_m_c_diff = round(time.time() - t0, 3) logger.debug( "Recording {} message_converter MemoryStats took: {} seconds", class_name, t_m_c_diff)
def log_connection_mem_stats(self) -> None: """ logs the connection's memory stats """ class_name = self.__class__.__name__ hooks.add_obj_mem_stats( class_name, self.network_num, self.inputbuf, "input_buffer", memory_utils.ObjectSize("input_buffer", memory_utils.get_special_size( self.inputbuf).size, is_actual_size=True), object_item_count=len(self.inputbuf.input_list), object_type=memory_utils.ObjectType.BASE, size_type=memory_utils.SizeType.TRUE) hooks.add_obj_mem_stats( class_name, self.network_num, self.outputbuf, "output_buffer", memory_utils.ObjectSize("output_buffer", memory_utils.get_special_size( self.outputbuf).size, is_actual_size=True), object_item_count=len(self.outputbuf.output_msgs), object_type=memory_utils.ObjectType.BASE, size_type=memory_utils.SizeType.TRUE)
def log_tx_service_mem_stats(self): super(ExtensionTransactionService, self).log_tx_service_mem_stats() if self.node.opts.stats_calculate_actual_size: size_type = memory_utils.SizeType.OBJECT else: size_type = memory_utils.SizeType.ESTIMATE hooks.add_obj_mem_stats( self.__class__.__name__, self.network_num, self._tx_not_seen_in_blocks, "tx_not_seen_in_blocks", self.get_collection_mem_stats( self._tx_not_seen_in_blocks, self._tx_not_seen_in_blocks.get_bytes_length()), object_item_count=len(self._tx_not_seen_in_blocks), object_type=memory_utils.ObjectType.BASE, size_type=size_type)
def log_tx_service_mem_stats(self, include_data_structure_memory: bool = False ) -> None: super(ExtensionTransactionService, self).log_tx_service_mem_stats(include_data_structure_memory) if include_data_structure_memory: hooks.add_obj_mem_stats( self.__class__.__name__, self.network_num, self._tx_not_seen_in_blocks, "tx_not_seen_in_blocks", self.get_collection_mem_stats(SizeType.OBJECT, self._tx_not_seen_in_blocks), object_item_count=len(self._tx_not_seen_in_blocks), object_type=memory_utils.ObjectType.BASE, size_type=SizeType.OBJECT)
def log_connection_mem_stats(self) -> None: """ logs the connection's memory stats """ super(AbstractRelayConnection, self).log_connection_mem_stats() class_name = self.__class__.__name__ if self.node.message_converter is not None: hooks.add_obj_mem_stats(class_name, self.network_num, self.node.message_converter, "message_converter", memory_utils.ObjectSize( "message_converter", memory_utils.get_special_size( self.node.message_converter).size, is_actual_size=True), object_item_count=1, object_type=memory_utils.ObjectType.META, size_type=memory_utils.SizeType.SPECIAL)
def log_connection_pool_mem_stats(self): """ Logs Connection Pool memory statistics """ sizer_obj = memory_statistics.sizer_obj sizer = sizer_obj.sizer logger.trace("MemoryStats excluded classes: {}", sizer_obj.excluded) by_fileno_obj_size = self._log_detailed_object_size(self.by_fileno, "by_fileno", sizer=sizer) by_ipport_obj_size = self._log_detailed_object_size(self.by_ipport, "by_ipport", sizer=sizer) by_conn_type_obj_size = self._log_detailed_object_size(self.by_connection_type, "by_conn_type", sizer=sizer) by_node_id_obj_size = self._log_detailed_object_size(self.by_node_id, "by_node_id", sizer=sizer) class_name = self.__class__.__name__ hooks.add_obj_mem_stats( class_name, 0, self.by_fileno, "connection_pool_by_fileno", by_fileno_obj_size, object_item_count=sum([1 for i in self.by_fileno if i is not None]), object_type=memory_utils.ObjectType.META, size_type=memory_utils.SizeType.OBJECT ) hooks.add_obj_mem_stats( class_name, 0, self.by_ipport, "connection_pool_by_ipport", by_ipport_obj_size, object_item_count=len(self.by_ipport), object_type=memory_utils.ObjectType.META, size_type=memory_utils.SizeType.OBJECT ) hooks.add_obj_mem_stats( class_name, 0, self.by_node_id, "connection_pool_by_node_id", by_node_id_obj_size, object_item_count=len(self.by_node_id), object_type=memory_utils.ObjectType.META, size_type=memory_utils.SizeType.OBJECT ) hooks.add_obj_mem_stats( class_name, 0, self.by_connection_type, "connection_pool_by_connection_type", by_conn_type_obj_size, object_item_count=len(self.by_connection_type), object_type=memory_utils.ObjectType.META, size_type=memory_utils.SizeType.OBJECT ) hooks.add_obj_mem_stats( class_name, 0, self.count_conn_by_ip, "connection_pool_count_conn_by_ip", memory_utils.get_object_size(self.count_conn_by_ip), object_item_count=len(self.count_conn_by_ip), object_type=memory_utils.ObjectType.BASE, size_type=memory_utils.SizeType.TRUE ) self._log_connections_mem_stats()
def log_tx_service_mem_stats(self): """ Logs transactions service memory statistics """ if self.node.opts.stats_calculate_actual_size: size_type = memory_utils.SizeType.OBJECT else: size_type = memory_utils.SizeType.ESTIMATE class_name = self.__class__.__name__ tx_cache_key_to_short_ids_mem_stats = self.get_collection_mem_stats( self._tx_cache_key_to_short_ids, self.ESTIMATED_TX_HASH_AND_SHORT_ID_ITEM_SIZE * len(self._tx_cache_key_to_short_ids)) tx_cache_key_to_contents_mem_stats = self.get_collection_mem_stats( self._tx_cache_key_to_contents, self.ESTIMATED_TX_HASH_ITEM_SIZE * len(self._tx_cache_key_to_contents) + self._total_tx_contents_size) short_id_to_tx_cache_key_mem_stats = self.get_collection_mem_stats( self._short_id_to_tx_cache_key, self.ESTIMATED_TX_HASH_AND_SHORT_ID_ITEM_SIZE * len(self._short_id_to_tx_cache_key)) short_ids_seen_in_block_mem_stats = self.get_collection_mem_stats( self._short_ids_seen_in_block, self.ESTIMATED_TX_HASH_AND_SHORT_ID_ITEM_SIZE * len(self._short_ids_seen_in_block)) hooks.add_obj_mem_stats( class_name, self.network_num, self._tx_cache_key_to_short_ids, "tx_cache_key_to_short_ids", tx_cache_key_to_short_ids_mem_stats, object_item_count=len(self._tx_cache_key_to_short_ids), object_type=self.get_object_type(self._tx_cache_key_to_short_ids), size_type=size_type) hooks.add_obj_mem_stats( class_name, self.network_num, self._tx_cache_key_to_contents, "tx_cache_key_to_contents", tx_cache_key_to_contents_mem_stats, object_item_count=len(self._tx_cache_key_to_contents), object_type=self.get_object_type(self._tx_cache_key_to_contents), size_type=size_type) hooks.add_obj_mem_stats( class_name, self.network_num, self._short_id_to_tx_cache_key, "short_id_to_tx_cache_key", short_id_to_tx_cache_key_mem_stats, object_item_count=len(self._short_id_to_tx_cache_key), object_type=self.get_object_type(self._short_id_to_tx_cache_key), size_type=size_type) hooks.add_obj_mem_stats(class_name, self.network_num, self._short_ids_seen_in_block, "short_ids_seen_in_block", short_ids_seen_in_block_mem_stats, object_item_count=len( self._short_ids_seen_in_block), object_type=memory_utils.ObjectType.BASE, size_type=size_type) hooks.add_obj_mem_stats( class_name, self.network_num, self._tx_assignment_expire_queue, "tx_assignment_expire_queue", self.get_collection_mem_stats( self._tx_assignment_expire_queue, self.ESTIMATED_SHORT_ID_EXPIRATION_ITEM_SIZE * len(self._tx_assignment_expire_queue)), object_item_count=len(self._tx_assignment_expire_queue), object_type=memory_utils.ObjectType.BASE, size_type=size_type) hooks.add_obj_mem_stats(class_name, self.network_num, self._removed_short_ids, "removed_short_ids", self.get_collection_mem_stats( self._removed_short_ids), object_item_count=len(self._removed_short_ids), object_type=memory_utils.ObjectType.BASE, size_type=size_type)