Skip to content

Commit

Permalink
Simplify "Add and expose settings for SD find debounce as config opti…
Browse files Browse the repository at this point in the history
…ons"

Changed find_initial_debounce_reps from uint32_t to uint8_t
Simplified propsed logic change in service_discovery_impl

This commit should be squashed into previous.
  • Loading branch information
tommyhaley committed Dec 11, 2024
1 parent 3e85cb7 commit 6fd7768
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 21 deletions.
18 changes: 18 additions & 0 deletions documentation/vsomeipUserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,24 @@ Configuration file element explanation:
repetition phase. This can be used to reduce the number of
sent messages during startup. The default setting is _500ms_.

* `find_debounce_time`

Time which the stack collects new service requests before they enter the
repetition phase. This can be used to reduce the number of
sent messages during startup. The default setting is _500ms_.

* `find_initial_debounce_reps`

Number of initial debounces using find_initial_debounce_time. This can be
used to modify the number of sent messages during initial part of startup
(valid values: _0 - 2^8-1_). The default setting is _0_.

* `find_initial_debounce_time`

Time which the stack collects new service requests before they enter the
repetition phase. This can be used to modify the number of
sent messages during initial part of startup. The default setting is _200ms_.

* 'suppress_missing_event_logs'

Used to filter the log message `deliver_notification: Event [1234.5678.80f3]
Expand Down
2 changes: 1 addition & 1 deletion implementation/configuration/include/configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class configuration {
virtual ttl_t get_sd_ttl() const = 0;
virtual int32_t get_sd_cyclic_offer_delay() const = 0;
virtual int32_t get_sd_request_response_delay() const = 0;
virtual std::uint32_t get_sd_find_initial_debounce_reps() const = 0;
virtual uint8_t get_sd_find_initial_debounce_reps() const = 0;
virtual std::uint32_t get_sd_find_initial_debounce_time() const = 0;
virtual std::uint32_t get_sd_offer_debounce_time() const = 0;
virtual std::uint32_t get_sd_find_debounce_time() const = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class configuration_impl:
VSOMEIP_EXPORT ttl_t get_sd_ttl() const;
VSOMEIP_EXPORT int32_t get_sd_cyclic_offer_delay() const;
VSOMEIP_EXPORT int32_t get_sd_request_response_delay() const;
VSOMEIP_EXPORT std::uint32_t get_sd_find_initial_debounce_reps() const;
VSOMEIP_EXPORT uint8_t get_sd_find_initial_debounce_reps() const;
VSOMEIP_EXPORT std::uint32_t get_sd_find_initial_debounce_time() const;
VSOMEIP_EXPORT std::uint32_t get_sd_offer_debounce_time() const;
VSOMEIP_EXPORT std::uint32_t get_sd_find_debounce_time() const;
Expand Down
12 changes: 10 additions & 2 deletions implementation/configuration/src/configuration_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1809,8 +1809,16 @@ void configuration_impl::load_service_discovery(
VSOMEIP_WARNING << "Multiple definitions for service_discovery.find_initial_debounce_reps."
" Ignoring definition from " << _element.name_;
} else {
int tmp;
its_converter << its_value;
its_converter >> sd_find_initial_debounce_reps_;
its_converter >> tmp;
if (tmp == static_cast<std::uint8_t>(tmp)) {
sd_find_initial_debounce_reps_ = static_cast<std::uint8_t>(tmp);
}
else {
VSOMEIP_WARNING << "Invalid value for service_discovery.find_initial_debounce_reps: " << tmp;
sd_find_initial_debounce_reps_ = std::numeric_limits<std::uint8_t>::max();
}
is_configured_[ET_SERVICE_DISCOVERY_FIND_INITIAL_DEBOUNCE_REPS] = true;
}
} else if (its_key == "find_initial_debounce_time") {
Expand Down Expand Up @@ -3699,7 +3707,7 @@ int32_t configuration_impl::get_sd_request_response_delay() const {
return sd_request_response_delay_;
}

std::uint32_t configuration_impl::get_sd_find_initial_debounce_reps() const {
uint8_t configuration_impl::get_sd_find_initial_debounce_reps() const {
return sd_find_initial_debounce_reps_;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,10 @@ class service_discovery_impl: public service_discovery,
std::mutex collected_offers_mutex_;
services_t collected_offers_;

// configurable debounce time for a configuarble number of inital debounce repetitions
std::uint32_t find_initial_debounce_reps_;
// interval between debounces during the initial debounce phase of the finds
std::chrono::milliseconds find_initial_debounce_time_;
// counter of remaining find initial debounce repetitions
std::uint32_t remaining_find_initial_debounce_reps_;
// tracks number of remaining debounces for the initial debounce phase of the finds
uint8_t remaining_find_initial_debounce_reps_;

std::chrono::milliseconds find_debounce_time_;
std::mutex find_debounce_timer_mutex_;
Expand Down
17 changes: 4 additions & 13 deletions implementation/service_discovery/src/service_discovery_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ service_discovery_impl::service_discovery_impl(
repetitions_max_(VSOMEIP_SD_DEFAULT_REPETITIONS_MAX),
cyclic_offer_delay_(VSOMEIP_SD_DEFAULT_CYCLIC_OFFER_DELAY),
offer_debounce_timer_(_host->get_io()),
find_initial_debounce_time_(VSOMEIP_SD_INITIAL_FIND_DEBOUNCE_TIME),
remaining_find_initial_debounce_reps_(VSOMEIP_SD_INITIAL_FIND_DEBOUNCE_REPS),
find_debounce_time_(VSOMEIP_SD_DEFAULT_FIND_DEBOUNCE_TIME),
find_debounce_timer_(_host->get_io()),
main_phase_timer_(_host->get_io()),
Expand Down Expand Up @@ -148,8 +150,7 @@ service_discovery_impl::init() {
repetitions_max_ = configuration_->get_sd_repetitions_max();
cyclic_offer_delay_ = std::chrono::milliseconds(
configuration_->get_sd_cyclic_offer_delay());
remaining_find_initial_debounce_reps_ = 0;
find_initial_debounce_reps_ = configuration_->get_sd_find_initial_debounce_reps();
remaining_find_initial_debounce_reps_ = configuration_->get_sd_find_initial_debounce_reps();
find_initial_debounce_time_ = std::chrono::milliseconds(
configuration_->get_sd_find_initial_debounce_time());
offer_debounce_time_ = std::chrono::milliseconds(
Expand Down Expand Up @@ -2885,24 +2886,14 @@ service_discovery_impl::start_find_debounce_timer(bool _first_start) {
find_debounce_timer_.expires_from_now(initial_delay_, ec);
} else if (remaining_find_initial_debounce_reps_ > 0) {
find_debounce_timer_.expires_from_now(find_initial_debounce_time_, ec);
--remaining_find_initial_debounce_reps_;
} else {
find_debounce_timer_.expires_from_now(find_debounce_time_, ec);
}
if (ec) {
VSOMEIP_ERROR<< "service_discovery_impl::start_find_debounce_timer "
"setting expiry time of timer failed: " << ec.message();
}

if (_first_start) {
// Reset the number of remaining initial debounce cycles for find
remaining_find_initial_debounce_reps_ = find_initial_debounce_reps_;
} else {
if (remaining_find_initial_debounce_reps_ > 0) {
// Decrement the number of remaining initial debounce cycles for find
remaining_find_initial_debounce_reps_--;
}
}

find_debounce_timer_.async_wait(
std::bind(
&service_discovery_impl::on_find_debounce_timer_expired,
Expand Down

0 comments on commit 6fd7768

Please sign in to comment.