Skip to content

Commit

Permalink
perf: add proxy cache to avoid the deserialize step (#140)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
yglsaltfish authored Dec 31, 2024
1 parent aca86a2 commit 10bb03f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions src/plugins/proxy_plugin/proxy_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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]] {
Expand Down

0 comments on commit 10bb03f

Please sign in to comment.