Skip to content

Commit

Permalink
Limit threads per zenoh session
Browse files Browse the repository at this point in the history
Signed-off-by: Yadunund <[email protected]>
  • Loading branch information
Yadunund committed Jan 20, 2024
1 parent 0e7a380 commit cb682f8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rmw_zenoh_cpp/config/DEFAULT_RMW_ZENOH_SESSION_CONFIG.json5
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@
/// Higher values lead to a more aggressive batching but it will introduce additional latency.
backoff: 100,
},
// Number of threads dedicated to transmission
// By default, the number of threads is calculated as follows: 1 + ((#cores - 1) / 4)
threads: 1,
},
/// Configure the zenoh RX parameters of a link
rx: {
Expand Down
15 changes: 15 additions & 0 deletions zenoh_c_vendor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,24 @@ endif()
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_vendor_package REQUIRED)

# Disable default features and only enable tcp transport for zenoh. This reduces
# build time but more importantly allows us to set the number of threads that
# the zenoh session can spin via session config as well as ASYNC_STD_THREAD_COUNT
# envar. Without this limit, applications with multiple zenoh sessions can
# encounter to system resource limits when trying to create new threads.
# Once zenoh migrates to relying on tokio for async runtime, we can consider
# removing these flags since tokio allows better control over threads spawned with
# the help of thread pools.
# Note: We separate the two args needed for cargo with "$<SEMICOLON>" and not ";" as the
# latter is a list separater in cmake and hence the string will be split into two
# when expanded.
set(ZENOHC_CARGO_FLAGS "--no-default-features$<SEMICOLON>--features=zenoh/transport_tcp")

ament_vendor(zenoh_c_vendor
VCS_URL https://github.com/eclipse-zenoh/zenoh-c.git
VCS_VERSION 0.10.1-rc
CMAKE_ARGS
"-DZENOHC_CARGO_FLAGS=${ZENOHC_CARGO_FLAGS}"
)

# set(INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-prefix/install")
Expand Down

0 comments on commit cb682f8

Please sign in to comment.