From 9a6ec73917397808b962aaa2a367df4979b0b4ad Mon Sep 17 00:00:00 2001 From: Tommy Andersson Date: Wed, 19 Jun 2024 11:44:40 +0200 Subject: [PATCH] Simplify "Add and expose settings for SD find debounce as config options" 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. --- documentation/vsomeipUserGuide.md | 18 ++++++++++++++++++ .../configuration/include/configuration.hpp | 2 +- .../include/configuration_impl.hpp | 4 ++-- .../configuration/src/configuration_impl.cpp | 12 ++++++++++-- .../include/service_discovery_impl.hpp | 7 +++---- .../src/service_discovery_impl.cpp | 17 ++++------------- 6 files changed, 38 insertions(+), 22 deletions(-) diff --git a/documentation/vsomeipUserGuide.md b/documentation/vsomeipUserGuide.md index 55064a611..a43320d96 100644 --- a/documentation/vsomeipUserGuide.md +++ b/documentation/vsomeipUserGuide.md @@ -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] diff --git a/implementation/configuration/include/configuration.hpp b/implementation/configuration/include/configuration.hpp index 1c5dfe51f..6b37339c2 100644 --- a/implementation/configuration/include/configuration.hpp +++ b/implementation/configuration/include/configuration.hpp @@ -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; diff --git a/implementation/configuration/include/configuration_impl.hpp b/implementation/configuration/include/configuration_impl.hpp index 3f938f5ea..688844b1c 100644 --- a/implementation/configuration/include/configuration_impl.hpp +++ b/implementation/configuration/include/configuration_impl.hpp @@ -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; @@ -539,7 +539,7 @@ class configuration_impl: ttl_t sd_ttl_; int32_t sd_cyclic_offer_delay_; int32_t sd_request_response_delay_; - std::uint32_t sd_find_initial_debounce_reps_; + uint8_t sd_find_initial_debounce_reps_; std::uint32_t sd_find_initial_debounce_time_; std::uint32_t sd_offer_debounce_time_; std::uint32_t sd_find_debounce_time_; diff --git a/implementation/configuration/src/configuration_impl.cpp b/implementation/configuration/src/configuration_impl.cpp index 4e32d510c..ec0216baf 100644 --- a/implementation/configuration/src/configuration_impl.cpp +++ b/implementation/configuration/src/configuration_impl.cpp @@ -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(tmp)) { + sd_find_initial_debounce_reps_ = static_cast(tmp); + } + else { + VSOMEIP_WARNING << "Invalid value for service_discovery.find_initial_debounce_reps: " << tmp; + sd_find_initial_debounce_reps_ = std::numeric_limits::max(); + } is_configured_[ET_SERVICE_DISCOVERY_FIND_INITIAL_DEBOUNCE_REPS] = true; } } else if (its_key == "find_initial_debounce_time") { @@ -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_; } diff --git a/implementation/service_discovery/include/service_discovery_impl.hpp b/implementation/service_discovery/include/service_discovery_impl.hpp index 66c4c28a9..32b7f5475 100644 --- a/implementation/service_discovery/include/service_discovery_impl.hpp +++ b/implementation/service_discovery/include/service_discovery_impl.hpp @@ -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_; diff --git a/implementation/service_discovery/src/service_discovery_impl.cpp b/implementation/service_discovery/src/service_discovery_impl.cpp index 1a25c86e1..a033a0e7a 100644 --- a/implementation/service_discovery/src/service_discovery_impl.cpp +++ b/implementation/service_discovery/src/service_discovery_impl.cpp @@ -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()), @@ -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( @@ -2885,6 +2886,7 @@ 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); } @@ -2892,17 +2894,6 @@ service_discovery_impl::start_find_debounce_timer(bool _first_start) { 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,