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

Micro-optimizations in rcl #965

Merged
merged 3 commits into from
Mar 11, 2022
Merged
Changes from all commits
Commits
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
19 changes: 1 addition & 18 deletions rcl/src/rcl/wait.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ rcl_wait_set_get_allocator(const rcl_wait_set_t * wait_set, rcl_allocator_t * al

#define SET_ADD(Type) \
RCL_CHECK_ARGUMENT_FOR_NULL(wait_set, RCL_RET_INVALID_ARGUMENT); \
if (!rcl_wait_set_is_valid(wait_set)) { \
if (!wait_set->impl) { \
RCL_SET_ERROR_MSG("wait set is invalid"); \
return RCL_RET_WAIT_SET_INVALID; \
} \
Expand Down Expand Up @@ -595,15 +595,6 @@ rcl_wait(rcl_wait_set_t * wait_set, int64_t timeout)
temporary_timeout_storage.nsec = min_timeout % 1000000000;
timeout_argument = &temporary_timeout_storage;
}
RCUTILS_LOG_DEBUG_EXPRESSION_NAMED(
!timeout_argument, ROS_PACKAGE_NAME, "Waiting without timeout");
RCUTILS_LOG_DEBUG_EXPRESSION_NAMED(
timeout_argument, ROS_PACKAGE_NAME,
"Waiting with timeout: %" PRIu64 "s + %" PRIu64 "ns",
temporary_timeout_storage.sec, temporary_timeout_storage.nsec);
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME, "Timeout calculated based on next scheduled timer: %s",
is_timer_timeout ? "true" : "false");

// Wait.
rmw_ret_t ret = rmw_wait(
Expand All @@ -630,7 +621,6 @@ rcl_wait(rcl_wait_set_t * wait_set, int64_t timeout)
if (ret != RCL_RET_OK) {
return ret; // The rcl error state should already be set.
}
RCUTILS_LOG_DEBUG_EXPRESSION_NAMED(is_ready, ROS_PACKAGE_NAME, "Timer in wait set is ready");
if (!is_ready) {
wait_set->timers[i] = NULL;
}
Expand All @@ -643,41 +633,34 @@ rcl_wait(rcl_wait_set_t * wait_set, int64_t timeout)
// Set corresponding rcl subscription handles NULL.
for (i = 0; i < wait_set->size_of_subscriptions; ++i) {
bool is_ready = wait_set->impl->rmw_subscriptions.subscribers[i] != NULL;
RCUTILS_LOG_DEBUG_EXPRESSION_NAMED(
is_ready, ROS_PACKAGE_NAME, "Subscription in wait set is ready");
if (!is_ready) {
wait_set->subscriptions[i] = NULL;
}
}
// Set corresponding rcl guard_condition handles NULL.
for (i = 0; i < wait_set->size_of_guard_conditions; ++i) {
bool is_ready = wait_set->impl->rmw_guard_conditions.guard_conditions[i] != NULL;
RCUTILS_LOG_DEBUG_EXPRESSION_NAMED(
is_ready, ROS_PACKAGE_NAME, "Guard condition in wait set is ready");
if (!is_ready) {
wait_set->guard_conditions[i] = NULL;
}
}
// Set corresponding rcl client handles NULL.
for (i = 0; i < wait_set->size_of_clients; ++i) {
bool is_ready = wait_set->impl->rmw_clients.clients[i] != NULL;
RCUTILS_LOG_DEBUG_EXPRESSION_NAMED(is_ready, ROS_PACKAGE_NAME, "Client in wait set is ready");
if (!is_ready) {
wait_set->clients[i] = NULL;
}
}
// Set corresponding rcl service handles NULL.
for (i = 0; i < wait_set->size_of_services; ++i) {
bool is_ready = wait_set->impl->rmw_services.services[i] != NULL;
RCUTILS_LOG_DEBUG_EXPRESSION_NAMED(is_ready, ROS_PACKAGE_NAME, "Service in wait set is ready");
if (!is_ready) {
wait_set->services[i] = NULL;
}
}
// Set corresponding rcl event handles NULL.
for (i = 0; i < wait_set->size_of_events; ++i) {
bool is_ready = wait_set->impl->rmw_events.events[i] != NULL;
RCUTILS_LOG_DEBUG_EXPRESSION_NAMED(is_ready, ROS_PACKAGE_NAME, "Event in wait set is ready");
if (!is_ready) {
wait_set->events[i] = NULL;
}
Expand Down