From 10bb03f45881d84c1c9d691a63f9cef69c3d2e14 Mon Sep 17 00:00:00 2001 From: ATT_POWER <34850640+yglsaltfish@users.noreply.github.com> Date: Tue, 31 Dec 2024 17:25:23 +0800 Subject: [PATCH] perf: add proxy cache to avoid the deserialize step (#140) * perf: add proxy cache to avoid the deserialize step * feat(proxy_plugin): Dynamically register cache serialization types * feat: Optimize the traversal method for type list --- ...s_plugins_record_playback_plugin_record_ros2_imd_cfg.yaml | 2 +- ...xamples_plugins_record_playback_plugin_record_ros2_imd.sh | 2 ++ src/plugins/proxy_plugin/proxy_plugin.cc | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/examples/plugins/record_playback_plugin/install/linux/bin/cfg/examples_plugins_record_playback_plugin_record_ros2_imd_cfg.yaml b/src/examples/plugins/record_playback_plugin/install/linux/bin/cfg/examples_plugins_record_playback_plugin_record_ros2_imd_cfg.yaml index 3b9769cd8..f43012a44 100644 --- a/src/examples/plugins/record_playback_plugin/install/linux/bin/cfg/examples_plugins_record_playback_plugin_record_ros2_imd_cfg.yaml +++ b/src/examples/plugins/record_playback_plugin/install/linux/bin/cfg/examples_plugins_record_playback_plugin_record_ros2_imd_cfg.yaml @@ -7,7 +7,7 @@ aimrt: - name: ros2_plugin path: ./libaimrt_ros2_plugin.so options: - node_name: example_ros2msg_echo_plugin + node_name: example_ros2msg_record_playback_plugin executor_type: MultiThreaded # SingleThreaded/StaticSingleThreaded/MultiThreaded executor_thread_num: 2 - name: record_playback_plugin diff --git a/src/examples/plugins/record_playback_plugin/install/linux/bin/start_examples_plugins_record_playback_plugin_record_ros2_imd.sh b/src/examples/plugins/record_playback_plugin/install/linux/bin/start_examples_plugins_record_playback_plugin_record_ros2_imd.sh index f336e1725..91af5c75e 100755 --- a/src/examples/plugins/record_playback_plugin/install/linux/bin/start_examples_plugins_record_playback_plugin_record_ros2_imd.sh +++ b/src/examples/plugins/record_playback_plugin/install/linux/bin/start_examples_plugins_record_playback_plugin_record_ros2_imd.sh @@ -1,3 +1,5 @@ #!/bin/bash +source install/share/example_ros2/local_setup.bash + ./aimrt_main --cfg_file_path=./cfg/examples_plugins_record_playback_plugin_record_ros2_imd_cfg.yaml diff --git a/src/plugins/proxy_plugin/proxy_plugin.cc b/src/plugins/proxy_plugin/proxy_plugin.cc index 132ac51cb..ed6e035b1 100644 --- a/src/plugins/proxy_plugin/proxy_plugin.cc +++ b/src/plugins/proxy_plugin/proxy_plugin.cc @@ -209,6 +209,11 @@ void ProxyPlugin::RegisterSubChannel() { .pkg_path = type_support_wrapper.options.path, .module_name = "core", .msg_type_support_ref = type_support_wrapper.type_support_ref}}; + + for (const auto type_list = type_support_wrapper.type_support_ref.SerializationTypesSupportedListSpan(); const auto& type : type_list) { + subscribe_wrapper.require_cache_serialization_types.emplace(type.str); + } + subscribe_wrapper.callback = [this, action_raw_ptr = proxy_action.get()]( MsgWrapper& msg_wrapper, std::function&& release_callback) { if (msg_wrapper.msg_ptr == nullptr && msg_wrapper.serialization_cache.size() == 0) [[unlikely]] {