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

[core] shm-monitoring-performance #1645

Merged
merged 9 commits into from
Jul 9, 2024
9 changes: 3 additions & 6 deletions ecal/core/cfg/ecal.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
; --------------------------------------------------
; NETWORK SETTINGS
; --------------------------------------------------
; network_enabled = true / false true = all eCAL components communicate over network boundaries
; false = local host only communication
; network_enabled = true / false true = all eCAL components communicate over network boundaries (registration over udp)
; false = local host only communication (registration over shm)
;
; multicast_config_version = v1 / v2 UDP configuration version (Since eCAL 5.12.)
; v1: default behavior
Expand Down Expand Up @@ -43,6 +43,7 @@

[network]
network_enabled = false
shm_registration_enabled = false
multicast_config_version = v1
multicast_group = 239.0.0.1
multicast_mask = 0.0.0.15
Expand Down Expand Up @@ -175,16 +176,12 @@ filter_excl = ^eCALSysClient$|^eCALSysGUI$|^eCALSys$
; --------------------------------------------------
; EXPERIMENTAL SETTINGS
; --------------------------------------------------
; shm_monitoring_enabled = false Enable distribution of monitoring/registration information via shared memory
; shm_monitoring_domain = ecal_monitoring Domain name for shared memory based monitoring/registration
; shm_monitoring_queue_size = 1024 Queue size of monitoring/registration events
; network_monitoring_enabled = true Enable distribution of monitoring/registration information via network
;
; drop_out_of_order_messages = false Enable dropping of payload messages that arrive out of order
; --------------------------------------------------
[experimental]
shm_monitoring_enabled = false
shm_monitoring_domain = ecal_mon
shm_monitoring_queue_size = 1024
network_monitoring_enabled = true
drop_out_of_order_messages = false
54 changes: 27 additions & 27 deletions ecal/core/include/ecal/config/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,34 +47,34 @@

namespace eCAL
{
struct Configuration
{
TransportLayer::Configuration transport_layer{};
Registration::Configuration registration{};
Monitoring::Configuration monitoring{};
Subscriber::Configuration subscriber{};
Publisher::Configuration publisher{};
Time::Configuration timesync{};
Service::Configuration service{};
Application::Configuration application{};
Logging::Configuration logging{};
Cli::Configuration command_line_arguments{};

ECAL_API Configuration();
ECAL_API Configuration(int argc_ , char **argv_);
ECAL_API Configuration(std::vector<std::string>& args_);
struct Configuration
{
Registration::Configuration registration{};
TransportLayer::Configuration transport_layer{};
Monitoring::Configuration monitoring{};
Subscriber::Configuration subscriber{};
Publisher::Configuration publisher{};
Time::Configuration timesync{};
Service::Configuration service{};
Application::Configuration application{};
Logging::Configuration logging{};
Cli::Configuration command_line_arguments{};

ECAL_API void InitConfigWithDefaultIni();
ECAL_API void InitConfig(std::string ini_path_ = std::string(""));
ECAL_API Configuration();
ECAL_API Configuration(int argc_, char** argv_);
ECAL_API Configuration(std::vector<std::string>& args_);

ECAL_API std::string GetIniFilePath();
ECAL_API void InitConfigWithDefaultIni();
ECAL_API void InitConfig(std::string ini_path_ = std::string(""));

friend class CmdParser;
ECAL_API std::string GetIniFilePath();

protected:
std::string ecal_ini_file_path{};

private:
ECAL_API void Init(std::vector<std::string>& args_);
};
}
friend class CmdParser;

protected:
std::string ecal_ini_file_path{};

private:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function 'eCAL::Configuration::Init' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name]

    ECAL_API void Init(std::vector<std::string>& args_);
                  ^
Additional context

ecal/core/src/config/ecal_config_initializer.cpp:236: the definition seen here

    void Configuration::Init(std::vector<std::string>& arguments_)
                        ^

ecal/core/include/ecal/config/configuration.h:77: differing parameters are named here: ('args_'), in definition: ('arguments_')

    ECAL_API void Init(std::vector<std::string>& args_);
                  ^

ECAL_API void Init(std::vector<std::string>& args_);
};
}
14 changes: 0 additions & 14 deletions ecal/core/include/ecal/config/monitoring.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,6 @@ namespace eCAL
{
namespace Monitoring
{
namespace Types
{
enum Mode
{
none = 0,
udp_monitoring = 1 << 0,
shm_monitoring = 1 << 1
};

using Mode_Filter = char;
}

namespace UDP
{
struct Configuration
Expand All @@ -60,9 +48,7 @@ namespace eCAL

struct Configuration
{
Types::Mode_Filter monitoring_mode{}; //!< Specify which monitoring is enabled (Default: none)
eCAL::Types::ConstrainedInteger<1000, 1000> monitoring_timeout{}; //!< Timeout for topic monitoring in ms (Default: 5000)
bool network_monitoring{}; //!< Enable distribution of monitoring/registration information via network (Default: true)
UDP::Configuration udp_options{};
SHM::Configuration shm_options{};

Expand Down
6 changes: 5 additions & 1 deletion ecal/core/include/ecal/config/registration.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,14 @@ namespace eCAL
ECAL_API unsigned int getTimeoutMS() const; //!< Timeout for topic registration in ms (internal) (Default: 60000)
ECAL_API unsigned int getRefreshMS() const; //!< Topic registration refresh cylce (has to be smaller then registration timeout!) (Default: 1000)

bool network_enabled; /*!< true = all eCAL components communicate over network boundaries
false = local host only communication (Default: false) */
bool shm_registration_enabled; /*!< true = registration layer is based on shm
false = registration layer is based on udp (Default: false) */
bool share_ttype; //!< Share topic type via registration layer (Default: true)
bool share_tdesc; //!< Share topic description via registration layer (switch off to disable reflection) (Default: true)

private:
private:
unsigned int m_registration_timeout;
unsigned int m_registration_refresh;
};
Expand Down
2 changes: 0 additions & 2 deletions ecal/core/include/ecal/config/transport_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ namespace eCAL

struct Configuration
{
bool network_enabled{}; /*!< true = all eCAL components communicate over network boundaries
false = local host only communication (Default: false) */
bool drop_out_of_order_messages{}; //!< Enable dropping of payload messages that arrive out of order (Default: false)
UDPMC::Configuration mc_options{};
TCPPubSub::Configuration tcp_options{};
Expand Down
1 change: 1 addition & 0 deletions ecal/core/include/ecal/ecal_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace eCAL
/////////////////////////////////////

ECAL_API bool IsNetworkEnabled ();
ECAL_API bool IsShmRegistrationEnabled ();
ECAL_API Types::UdpConfigVersion GetUdpMulticastConfigVersion ();
ECAL_API std::string GetUdpMulticastGroup ();
ECAL_API std::string GetUdpMulticastMask ();
Expand Down
7 changes: 3 additions & 4 deletions ecal/core/src/config/ecal_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ namespace eCAL
// network
/////////////////////////////////////

ECAL_API bool IsNetworkEnabled () { return GetConfiguration().transport_layer.network_enabled; }
ECAL_API bool IsNetworkEnabled () { return GetConfiguration().registration.network_enabled; }
ECAL_API bool IsShmRegistrationEnabled () { return GetConfiguration().registration.shm_registration_enabled; }

ECAL_API Types::UdpConfigVersion GetUdpMulticastConfigVersion () { return GetConfiguration().transport_layer.mc_options.config_version; }
ECAL_API Types::UdpConfigVersion GetUdpMulticastConfigVersion () { return GetConfiguration().transport_layer.mc_options.config_version; }

ECAL_API std::string GetUdpMulticastGroup () { return GetConfiguration().transport_layer.mc_options.group; }
ECAL_API std::string GetUdpMulticastMask () { return GetConfiguration().transport_layer.mc_options.mask; }
Expand Down Expand Up @@ -181,8 +182,6 @@ namespace eCAL

namespace Experimental
{
ECAL_API bool IsShmMonitoringEnabled () { return (GetConfiguration().monitoring.monitoring_mode & Monitoring::Types::Mode::shm_monitoring) != 0; }
ECAL_API bool IsNetworkMonitoringDisabled () { return !GetConfiguration().monitoring.network_monitoring; }
ECAL_API size_t GetShmMonitoringQueueSize () { return GetConfiguration().monitoring.shm_options.shm_monitoring_queue_size; }
ECAL_API std::string GetShmMonitoringDomain () { return GetConfiguration().monitoring.shm_options.shm_monitoring_domain;}
ECAL_API bool GetDropOutOfOrderMessages () { return GetConfiguration().transport_layer.drop_out_of_order_messages; }
Expand Down
18 changes: 8 additions & 10 deletions ecal/core/src/config/ecal_config_initializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ namespace eCAL

// transport layer options
auto& transportLayerOptions = transport_layer;
transportLayerOptions.network_enabled = iniConfig.get(NETWORK, "network_enabled", NET_ENABLED);
transportLayerOptions.drop_out_of_order_messages = iniConfig.get(EXPERIMENTAL, "drop_out_of_order_messages", EXP_DROP_OUT_OF_ORDER_MESSAGES);

auto& multicastOptions = transportLayerOptions.mc_options;
Expand Down Expand Up @@ -146,19 +145,18 @@ namespace eCAL
shmOptions.memfile_zero_copy = iniConfig.get(PUBLISHER, "memfile_zero_copy", PUB_MEMFILE_ZERO_COPY);

// registration options
auto registrationTimeout = iniConfig.get(COMMON, "registration_timeout", CMN_REGISTRATION_TO);
auto registrationRefresh = iniConfig.get(COMMON, "registration_refresh", CMN_REGISTRATION_REFRESH);
registration = Registration::Configuration(registrationTimeout, registrationRefresh);
auto& registrationOptions = registration;
registrationOptions.share_tdesc = iniConfig.get(PUBLISHER, "share_tdesc", PUB_SHARE_TDESC);
registrationOptions.share_ttype = iniConfig.get(PUBLISHER, "share_ttype", PUB_SHARE_TTYPE);
auto registrationTimeout = iniConfig.get(COMMON, "registration_timeout", CMN_REGISTRATION_TO);
auto registrationRefresh = iniConfig.get(COMMON, "registration_refresh", CMN_REGISTRATION_REFRESH);
registration = Registration::Configuration(registrationTimeout, registrationRefresh);
auto& registrationOptions = registration;
registrationOptions.network_enabled = iniConfig.get(NETWORK, "network_enabled", NET_ENABLED);
registrationOptions.shm_registration_enabled = iniConfig.get(NETWORK, "shm_registration_enabled", SHM_REGISTRATION_ENABLED);
registrationOptions.share_tdesc = iniConfig.get(PUBLISHER, "share_tdesc", PUB_SHARE_TDESC);
registrationOptions.share_ttype = iniConfig.get(PUBLISHER, "share_ttype", PUB_SHARE_TTYPE);

// monitoring options
auto& monitoringOptions = monitoring;
auto monitoringMode = iniConfig.get(EXPERIMENTAL, "shm_monitoring_enabled", false) ? Monitoring::Types::Mode::shm_monitoring : Monitoring::Types::Mode::none;
monitoringOptions.monitoring_mode = static_cast<Monitoring::Types::Mode_Filter>(monitoringMode);
monitoringOptions.monitoring_timeout = iniConfig.get(MONITORING, "timeout", MON_TIMEOUT);;
monitoringOptions.network_monitoring = iniConfig.get(EXPERIMENTAL, "network_monitoring", EXP_NETWORK_MONITORING_ENABLED);
monitoringOptions.filter_excl = iniConfig.get(MONITORING, "filter_excl", MON_FILTER_EXCL);
monitoringOptions.filter_incl = iniConfig.get(MONITORING, "filter_incl", MON_FILTER_INCL);

Expand Down
7 changes: 1 addition & 6 deletions ecal/core/src/ecal_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ constexpr const char* SYS_FILTER_EXCL = "^eCALSysClient$|^eCALSysGUI$|^eCALS
/**********************************************************************************************/
/* network switch */
constexpr bool NET_ENABLED = false;
constexpr bool SHM_REGISTRATION_ENABLED = false;

/* eCAL udp multicast defines */
constexpr eCAL::Types::UdpConfigVersion NET_UDP_MULTICAST_CONFIG_VERSION = eCAL::Types::UdpConfigVersion::V1;
Expand Down Expand Up @@ -187,10 +188,6 @@ constexpr const char* EVENT_SHUTDOWN_PROC = "ecal_shutdown_pro
/**********************************************************************************************/
/* experimental */
/**********************************************************************************************/
/* enable distribution of monitoring/registration information via shared memory */
constexpr bool EXP_SHM_MONITORING_ENABLED = false;
/* enable distribution of monitoring/registration information via network (default) */
constexpr bool EXP_NETWORK_MONITORING_ENABLED = true;
/* queue size of monitoring/registration events */
constexpr unsigned int EXP_SHM_MONITORING_QUEUE_SIZE = 1024U;
/* domain name for shared memory based monitoring/registration */
Expand All @@ -200,5 +197,3 @@ constexpr unsigned int EXP_MEMFILE_ACCESS_TIMEOUT = 100U;

/* enable dropping of payload messages that arrive out of order */
constexpr bool EXP_DROP_OUT_OF_ORDER_MESSAGES = false;

constexpr eCAL::Monitoring::Types::Mode EXP_MONITORING_MODE = eCAL::Monitoring::Types::Mode::none;
6 changes: 3 additions & 3 deletions ecal/core/src/registration/ecal_registration_provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ namespace eCAL
{
if(m_created) return;

// send registration to shared memory and to udp
m_use_registration_udp = !Config::Experimental::IsNetworkMonitoringDisabled();
m_use_registration_shm = Config::Experimental::IsShmMonitoringEnabled();
// send registration over udp or shared memory
m_use_registration_shm = Config::IsShmRegistrationEnabled();
m_use_registration_udp = !m_use_registration_shm;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused. shouldn't the registration provider / receiver also be passed configuration objects (maybe just registration configuration) in their constructors? But maybe that's for a different PR.

if (m_use_registration_udp)
{
Expand Down
6 changes: 3 additions & 3 deletions ecal/core/src/registration/ecal_registration_receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ namespace eCAL
{
if(m_created) return;

// receive registration from shared memory and or udp
m_use_registration_udp = !Config::Experimental::IsNetworkMonitoringDisabled();
m_use_registration_shm = Config::Experimental::IsShmMonitoringEnabled();
// receive registration via udp or shared memory
m_use_registration_shm = Config::IsShmRegistrationEnabled();
m_use_registration_udp = !m_use_registration_shm;

if (m_use_registration_udp)
{
Expand Down
3 changes: 2 additions & 1 deletion ecal/core/src/types/ecal_registration_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ namespace eCAL
namespace Registration
{
Configuration::Configuration()
: share_ttype(PUB_SHARE_TTYPE)
: network_enabled(NET_ENABLED)
, share_ttype(PUB_SHARE_TTYPE)
, share_tdesc(PUB_SHARE_TDESC)
, m_registration_timeout(CMN_REGISTRATION_TO)
, m_registration_refresh(CMN_REGISTRATION_REFRESH)
Expand Down
3 changes: 2 additions & 1 deletion ecal/samples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ========================= eCAL LICENSE =================================
#
# Copyright (C) 2016 - 2019 Continental Corporation
# Copyright (C) 2016 - 2024 Continental Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -66,6 +66,7 @@ endif()

if(ECAL_CORE_PUBLISHER AND ECAL_CORE_SUBSCRIBER)
add_subdirectory(cpp/benchmarks/perftool)
add_subdirectory(cpp/benchmarks/massive_pub_sub)
endif()

# misc
Expand Down
41 changes: 41 additions & 0 deletions ecal/samples/cpp/benchmarks/massive_pub_sub/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# ========================= eCAL LICENSE =================================
#
# Copyright (C) 2016 - 2024 Continental Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ========================= eCAL LICENSE =================================

cmake_minimum_required(VERSION 3.10)

set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)

project(massive_pub_sub)

find_package(eCAL REQUIRED)

set(massive_pub_sub_src
src/massive_pub_sub.cpp
)

ecal_add_sample(${PROJECT_NAME} ${massive_pub_sub_src})

target_link_libraries(${PROJECT_NAME}
eCAL::core
)

target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14)

ecal_install_sample(${PROJECT_NAME})

set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER samples/cpp/benchmarks/massive_pub_sub)
Loading
Loading