Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synchronize with SHM branch #11

Closed
wants to merge 56 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
8d0e3c8
Update style.yaml
Mallets Jul 23, 2024
62433e7
Update check_logging.yaml
Mallets Jul 23, 2024
4535aea
Update build.yaml
Mallets Jul 23, 2024
109864b
chore: configure the compiliation
YuanYuYuan Jun 20, 2024
c7724ff
chore: complete the 1st version
YuanYuYuan Jun 25, 2024
2af94a9
fix: memory leak
YuanYuYuan Jul 18, 2024
3ee8cd3
wip
YuanYuYuan Jul 25, 2024
e5f5b58
fix: z_error_t -> z_result_t
YuanYuYuan Jul 26, 2024
28f2fe8
Fix `scouting/*/autoconnect/*` per eclipse-zenoh/zenoh@b31a410 (#3)
fuzzypixelz Jul 24, 2024
ecf26fc
chore: checkout the local zenoh-c
YuanYuYuan Jul 30, 2024
b9b7cec
chore: polish z_open
YuanYuYuan Jul 31, 2024
d9cf6f9
fix: segfault
YuanYuYuan Jul 31, 2024
71700d7
feat: `z_bytes_serialize_from_slice` without copy
YuanYuYuan Jul 31, 2024
cc8b1d6
chore: switch back to https://github.com/eclipse-zenoh/zenoh-c
YuanYuYuan Jul 31, 2024
d261332
Initialize `query_` member of `ZenohQuery`
fuzzypixelz Jul 26, 2024
15ea139
refactor: use `z_owned_slice_t` instead
YuanYuYuan Jul 31, 2024
ced2c14
chore: adapt the latest change of zenoh-c dev/1.0.0
YuanYuYuan Aug 2, 2024
55efb74
chore: use `strncmp` to avoid copying
YuanYuYuan Aug 7, 2024
8505e34
refactor: use `z_view_keyexpr_t` to avoid copying
YuanYuYuan Aug 8, 2024
c43caf2
feat: implment the SHM feature
YuanYuYuan Aug 8, 2024
686dec1
Replaced ament_vendor with ExternalProject
imstevenpmwork Aug 13, 2024
62aad56
Merge commit 'dfc95ade620952af587dc55464d0697efad15301'
yellowhatter Aug 20, 2024
ccd69a3
merge fixes
yellowhatter Aug 20, 2024
8f36772
SHM feature support for build system
yellowhatter Aug 20, 2024
9fac5ee
Hide all shm stuff behind #ifdef RMW_ZENOH_BUILD_WITH_SHARED_MEMORY
yellowhatter Aug 20, 2024
d2cccf2
Update .gitignore
yellowhatter Aug 20, 2024
785eab0
Fix owned query handling
yellowhatter Aug 20, 2024
aace581
fix: segmentation fault due to the unallocated query memory
YuanYuYuan Aug 18, 2024
57fb755
configurable shm size
yellowhatter Aug 21, 2024
5ef8a70
fix Zenoh Config read\check
yellowhatter Aug 22, 2024
916ee65
Merge commit '5ef8a705cbac4beb136d44e076de45a4420ffa05'
yellowhatter Aug 22, 2024
be31a20
adopt to recent zenoh-c API changes
yellowhatter Aug 23, 2024
aff62d3
Merge commit 'be31a20eda3ee9325dff022df2d1480a243d274c'
yellowhatter Aug 23, 2024
2097c30
fix SHM feature passing through build system
yellowhatter Aug 23, 2024
94a014a
- refine SHM code, fix some bugs
yellowhatter Aug 26, 2024
e6da873
Merge commit 'af2e344dcef624e6460fca461aa1cc2357696917'
yellowhatter Aug 26, 2024
cadd258
Add configurable message size threshold for handling ROS messages thr…
yellowhatter Aug 26, 2024
3b31861
Merge commit '0225a59de4fe2f180291d94845071753269e2744'
yellowhatter Aug 27, 2024
991a1a5
- refactor buffer serialization code
yellowhatter Aug 28, 2024
abbe1be
Merge commit '36140fddac33317c87e9431a58b3ecf1345a0f4e'
yellowhatter Aug 28, 2024
28a930a
Merge branch 'dev/1.0.0' into dev/1.0.0-ci
evshary Aug 29, 2024
d696a60
Merge commit 'f60c2a2a2090311d803de4a7e2151f7ab6ce1433'
yellowhatter Aug 29, 2024
381b022
Merge commit '83a26f2d1911bbb61c786f445b3f4477e20e969b'
yellowhatter Aug 30, 2024
6496c5a
Merge commit '7dba6746caf17e01deb4301c9955e5631339f40e'
yellowhatter Sep 2, 2024
c983149
Merge branch 'dev/1.0.0' into dev/1.0.0-ci
evshary Sep 2, 2024
d1242c4
Merge commit 'c983149ec1eb343e31b9e5f5c8951403ae7365b0'
yellowhatter Sep 3, 2024
a0d7d02
wip on publication refactoring
yellowhatter Sep 5, 2024
9816f16
Merge commit '30aae8082407794f98b7158a5bc48e7c66eee633'
yellowhatter Sep 5, 2024
2f8b788
WIP on SHM (benchmarked)
yellowhatter Sep 11, 2024
7861708
Merge commit '6a48919727226ebad853373e8a1eec0ee22c3be4'
yellowhatter Sep 24, 2024
1ce3cf8
Update rmw_zenoh.cpp
yellowhatter Sep 25, 2024
01b34c5
codestyle
yellowhatter Sep 25, 2024
a0538f0
Codestyle
yellowhatter Sep 25, 2024
4739732
Update rmw_zenoh.cpp
yellowhatter Sep 25, 2024
728a094
Update rmw_zenoh.cpp
yellowhatter Sep 25, 2024
e49e22c
Merge commit 'afd7f638c64b6fc70e471cde02f63c16c065a4f5'
yellowhatter Oct 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build
install
.cache
log
.vscode
10 changes: 10 additions & 0 deletions rmw_zenoh_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

set(RMW_ZENOH_BUILD_WITH_SHARED_MEMORY OFF CACHE BOOL "Compile Zenoh RMW with Shared Memory support")

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
Expand Down Expand Up @@ -74,6 +76,14 @@ target_compile_definitions(rmw_zenoh_cpp
RMW_VERSION_PATCH=${rmw_VERSION_PATCH}
)

if(${RMW_ZENOH_BUILD_WITH_SHARED_MEMORY})
target_compile_definitions(rmw_zenoh_cpp
PRIVATE
RMW_ZENOH_BUILD_WITH_SHARED_MEMORY
)
endif()


ament_export_targets(export_rmw_zenoh_cpp)

register_rmw_implementation(
Expand Down
2 changes: 1 addition & 1 deletion rmw_zenoh_cpp/config/DEFAULT_RMW_ZENOH_ROUTER_CONFIG.json5
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
},
/// Shared memory configuration
shared_memory: {
enabled: false,
enabled: true,
},
/// Access control configuration
auth: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
},
/// Shared memory configuration
shared_memory: {
enabled: false,
enabled: true,
},
/// Access control configuration
auth: {
Expand Down
66 changes: 66 additions & 0 deletions rmw_zenoh_cpp/src/detail/zenoh_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ static const std::unordered_map<ConfigurableEntity,
};

static const char * router_check_attempts_envar = "ZENOH_ROUTER_CHECK_ATTEMPTS";
#ifdef RMW_ZENOH_BUILD_WITH_SHARED_MEMORY
static const char * zenoh_shm_alloc_size_envar = "ZENOH_SHM_ALLOC_SIZE";
static const size_t zenoh_shm_alloc_size_default = 1 * 1024 * 1024;
static const char * zenoh_shm_message_size_threshold_envar = "ZENOH_SHM_MESSAGE_SIZE_THRESHOLD";
static const size_t zenoh_shm_message_size_threshold_default = 2 * 1024;
#endif

rmw_ret_t _get_z_config(
const char * envar_name,
Expand Down Expand Up @@ -123,4 +129,64 @@ std::optional<uint64_t> zenoh_router_check_attempts()
// If unset, check indefinitely.
return default_value;
}


#ifdef RMW_ZENOH_BUILD_WITH_SHARED_MEMORY
///=============================================================================
size_t zenoh_shm_alloc_size()
{
const char * envar_value;

if (NULL != rcutils_get_env(zenoh_shm_alloc_size_envar, &envar_value)) {
RMW_ZENOH_LOG_ERROR_NAMED(
"rmw_zenoh_cpp", "Envar %s cannot be read. Report this bug.",
zenoh_shm_alloc_size_envar);
return zenoh_shm_alloc_size_default;
}

// If the environment variable contains a value, handle it accordingly.
if (envar_value[0] != '\0') {
const auto read_value = std::strtoull(envar_value, nullptr, 10);
if (read_value > 0) {
if (read_value > std::numeric_limits<size_t>::max()) {
RMW_ZENOH_LOG_ERROR_NAMED(
"rmw_zenoh_cpp", "Envar %s: value is too large!",
zenoh_shm_alloc_size_envar);
} else {
return read_value;
}
}
}

return zenoh_shm_alloc_size_default;
}
///=============================================================================
size_t zenoh_shm_message_size_threshold()
{
const char * envar_value;

if (NULL != rcutils_get_env(zenoh_shm_message_size_threshold_envar, &envar_value)) {
RMW_ZENOH_LOG_ERROR_NAMED(
"rmw_zenoh_cpp", "Envar %s cannot be read. Report this bug.",
zenoh_shm_message_size_threshold_envar);
return zenoh_shm_message_size_threshold_default;
}

// If the environment variable contains a value, handle it accordingly.
if (envar_value[0] != '\0') {
const auto read_value = std::strtoull(envar_value, nullptr, 10);
if (read_value > 0) {
if (read_value > std::numeric_limits<size_t>::max()) {
RMW_ZENOH_LOG_ERROR_NAMED(
"rmw_zenoh_cpp", "Envar %s: value is too large!",
zenoh_shm_message_size_threshold_envar);
} else {
return read_value;
}
}
}

return zenoh_shm_message_size_threshold_default;
}
#endif
} // namespace rmw_zenoh_cpp
20 changes: 20 additions & 0 deletions rmw_zenoh_cpp/src/detail/zenoh_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,26 @@ rmw_ret_t get_z_config(const ConfigurableEntity & entity, z_owned_config_t * con
/// @return The number of times to try connecting to a zenoh router and
/// std::nullopt if establishing a connection to a router is not required.
std::optional<uint64_t> zenoh_router_check_attempts();

#ifdef RMW_ZENOH_BUILD_WITH_SHARED_MEMORY
///=============================================================================
/// Get the amount of shared memory to be pre-allocated for Zenoh SHM operation
/// based on the environment variable ZENOH_SHM_ALLOC_SIZE.
/// @details The behavior is as follows:
/// - If not set or <= 0, the default value of 1MB is returned.
/// - Else value of environemnt variable is returned.
/// @return The amount of shared memory to be pre-allocated for Zenoh SHM operation
size_t zenoh_shm_alloc_size();
///=============================================================================
/// Message size threshold for implicit SHM optimization based on the environment
/// variable ZENOH_SHM_ALLOC_SIZE.
/// Messages smaller than this threshold will not be forwarded through Zenoh SHM
/// @details The behavior is as follows:
/// - If not set or <= 0, the default value of 2KB is returned.
/// - Else value of environemnt variable is returned.
/// @return The amount of shared memory to be pre-allocated for Zenoh SHM operation
size_t zenoh_shm_message_size_threshold();
#endif
} // namespace rmw_zenoh_cpp

#endif // DETAIL__ZENOH_CONFIG_HPP_
Loading