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
This commit is contained in:
ATT_POWER 2024-12-31 17:25:23 +08:00 committed by GitHub
parent aca86a230b
commit 10bb03f458
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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<void()>&& release_callback) {
if (msg_wrapper.msg_ptr == nullptr && msg_wrapper.serialization_cache.size() == 0) [[unlikely]] {