From bea00402940dcc1fd84d4ecb28cc8a47388d3bfd Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Tue, 13 Jul 2021 14:47:33 +0200 Subject: [PATCH 1/6] Boost include dirs may be necessary when Boost_LIBRARIES is empty Signed-off-by: Miguel Company --- performance_test/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/performance_test/CMakeLists.txt b/performance_test/CMakeLists.txt index 3cdfa652..300e0a4d 100644 --- a/performance_test/CMakeLists.txt +++ b/performance_test/CMakeLists.txt @@ -399,6 +399,10 @@ if(TARGET rti_connextdds_idl) ) endif() +target_include_directories(${EXE_NAME} + PRIVATE + ${Boost_INCLUDE_DIRS} +) target_link_libraries(${EXE_NAME} ${Boost_LIBRARIES} ${OPTIONAL_LIBRARIES} From 141987e4333d633b818465d86430fa2078ee75b7 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Mon, 26 Jul 2021 12:56:57 +0200 Subject: [PATCH 2/6] Force static linking on boost libraries. Signed-off-by: Miguel Company --- performance_test/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/performance_test/CMakeLists.txt b/performance_test/CMakeLists.txt index 300e0a4d..8ceb54ac 100644 --- a/performance_test/CMakeLists.txt +++ b/performance_test/CMakeLists.txt @@ -24,6 +24,7 @@ set(OPTIONAL_LIBRARIES) # Default to C++14 set(CMAKE_CXX_STANDARD 14) +set(Boost_USE_STATIC_LIBS ON) find_package(Boost COMPONENTS program_options timer REQUIRED) find_package(ament_cmake REQUIRED) From 17b72833113f770095a9491c01f3b3023b4cc45b Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Tue, 13 Jul 2021 14:49:22 +0200 Subject: [PATCH 3/6] Fixes on analysis_result Signed-off-by: Miguel Company --- .../experiment_execution/analysis_result.cpp | 27 ++++++++++++++++++- .../experiment_execution/analysis_result.hpp | 10 +++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/performance_test/src/experiment_execution/analysis_result.cpp b/performance_test/src/experiment_execution/analysis_result.cpp index f308d0a7..b188c23c 100644 --- a/performance_test/src/experiment_execution/analysis_result.cpp +++ b/performance_test/src/experiment_execution/analysis_result.cpp @@ -14,7 +14,9 @@ #include "analysis_result.hpp" -#include +#if !defined(WIN32) + #include +#endif // !defined(WIN32) #include #include @@ -25,10 +27,12 @@ namespace performance_test { +#if !defined(WIN32) std::ostream & operator<<(std::ostream & stream, const timeval & e) { return stream << double(e.tv_sec) + double(e.tv_usec) / 1000000.0; } +#endif // !defined(WIN32) AnalysisResult::AnalysisResult( const std::chrono::nanoseconds experiment_start, @@ -53,6 +57,7 @@ AnalysisResult::AnalysisResult( m_sub_loop_time_reserve(sub_loop_time_reserve), m_cpu_info(cpu_info) { +#if !defined(WIN32) const auto ret = getrusage(RUSAGE_SELF, &m_sys_usage); #if defined(QNX) // QNX getrusage() max_rss does not give the correct value. Using a different method to get @@ -66,6 +71,7 @@ AnalysisResult::AnalysisResult( if (ret != 0) { throw std::runtime_error("Could not get system resource usage."); } +#endif // !defined(WIN32) if (m_num_samples_received != static_cast(m_latency.n())) { // TODO(andreas.pasternak): Commented out flaky assertion. Need to check if it actually a bug. /*throw std::runtime_error("Statistics result sample size does not match: " @@ -170,6 +176,24 @@ std::string AnalysisResult::to_csv_string(const bool pretty_print, std::string s * output below */ +#if defined(WIN32) + ss << 0 /* m_sys_usage.ru_utime */ << st; + ss << 0 /* m_sys_usage.ru_stime */ << st; + ss << 0 /* m_sys_usage.ru_maxrss */ << st; + ss << 0 /* m_sys_usage.ru_ixrss */ << st; + ss << 0 /* m_sys_usage.ru_idrss */ << st; + ss << 0 /* m_sys_usage.ru_isrss */ << st; + ss << 0 /* m_sys_usage.ru_minflt */ << st; + ss << 0 /* m_sys_usage.ru_majflt */ << st; + ss << 0 /* m_sys_usage.ru_nswap */ << st; + ss << 0 /* m_sys_usage.ru_inblock */ << st; + ss << 0 /* m_sys_usage.ru_oublock */ << st; + ss << 0 /* m_sys_usage.ru_msgsnd */ << st; + ss << 0 /* m_sys_usage.ru_msgrcv */ << st; + ss << 0 /* m_sys_usage.ru_nsignals */ << st; + ss << 0 /* m_sys_usage.ru_nvcsw */ << st; + ss << 0 /* m_sys_usage.ru_nivcsw */ << st; +#else ss << m_sys_usage.ru_utime << st; ss << m_sys_usage.ru_stime << st; ss << m_sys_usage.ru_maxrss << st; @@ -186,6 +210,7 @@ std::string AnalysisResult::to_csv_string(const bool pretty_print, std::string s ss << m_sys_usage.ru_nsignals << st; ss << m_sys_usage.ru_nvcsw << st; ss << m_sys_usage.ru_nivcsw << st; +#endif ss << m_cpu_info.cpu_usage() << st; diff --git a/performance_test/src/experiment_execution/analysis_result.hpp b/performance_test/src/experiment_execution/analysis_result.hpp index a9dbc2af..b244bc19 100644 --- a/performance_test/src/experiment_execution/analysis_result.hpp +++ b/performance_test/src/experiment_execution/analysis_result.hpp @@ -15,8 +15,10 @@ #ifndef EXPERIMENT_EXECUTION__ANALYSIS_RESULT_HPP_ #define EXPERIMENT_EXECUTION__ANALYSIS_RESULT_HPP_ -#include -#include +#if !defined(WIN32) + #include + #include +#endif // !defined(WIN32) #include #include @@ -33,8 +35,10 @@ namespace performance_test { +#if !defined(WIN32) /// Outstream operator for timeval to seconds (double). std::ostream & operator<<(std::ostream & stream, const timeval & e); +#endif // !defined(WIN32) #ifdef PERFORMANCE_TEST_ODB_FOR_SQL_ENABLED class RusageTracker { @@ -297,7 +301,9 @@ class AnalysisResult RusageTracker m_sys_tracker; #pragma db transient #endif +#if !defined(WIN32) rusage m_sys_usage; +#endif // !defined(WIN32) const CpuInfo m_cpu_info; }; From 6410b804f72e99138d3c4e48d0ee36effc36f3be Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Tue, 13 Jul 2021 14:50:02 +0200 Subject: [PATCH 4/6] Using std C++ sleep on analyze_runner. Signed-off-by: Miguel Company --- performance_test/src/experiment_execution/analyze_runner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/performance_test/src/experiment_execution/analyze_runner.cpp b/performance_test/src/experiment_execution/analyze_runner.cpp index 6bd32c0b..327b9894 100644 --- a/performance_test/src/experiment_execution/analyze_runner.cpp +++ b/performance_test/src/experiment_execution/analyze_runner.cpp @@ -147,7 +147,7 @@ void AnalyzeRunner::run() while (!check_exit(experiment_start)) { const auto loop_start = std::chrono::steady_clock::now(); - sleep(1); + std::this_thread::sleep_for(std::chrono::seconds(1)); std::for_each(m_pub_runners.begin(), m_pub_runners.end(), [](auto & a) {a->sync_reset();}); std::for_each(m_sub_runners.begin(), m_sub_runners.end(), [](auto & a) {a->sync_reset();}); From 1e8b37838657aee174b45144bde003b7ca330e70 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Tue, 13 Jul 2021 14:50:59 +0200 Subject: [PATCH 5/6] Adding `/bigobj` Signed-off-by: Miguel Company --- performance_test/compile_options.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/performance_test/compile_options.cmake b/performance_test/compile_options.cmake index b6405cc5..51aa9e0c 100644 --- a/performance_test/compile_options.cmake +++ b/performance_test/compile_options.cmake @@ -21,6 +21,7 @@ function(set_compile_options target) add_definitions(-D_CRT_NONSTDC_NO_WARNINGS) add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS) + add_definitions(/bigobj) else() target_compile_options(${target} PRIVATE -Wall -Wextra From 81995bc984ad93b378f2b6132dd43f191053ddda Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Mon, 26 Jul 2021 14:12:58 +0200 Subject: [PATCH 6/6] Avoid stack overflows Signed-off-by: Miguel Company --- .../src/communication_abstractions/ros2_communicator.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/performance_test/src/communication_abstractions/ros2_communicator.hpp b/performance_test/src/communication_abstractions/ros2_communicator.hpp index d04af3e1..1f35a4f7 100644 --- a/performance_test/src/communication_abstractions/ros2_communicator.hpp +++ b/performance_test/src/communication_abstractions/ros2_communicator.hpp @@ -124,13 +124,13 @@ class ROS2Communicator : public Communicator unlock(); m_publisher->publish(std::move(borrowed_message)); } else { - DataType data; + // DataType data; lock(); - data.time = time; - data.id = next_sample_id(); + m_data_copy->time = time; + m_data_copy->id = next_sample_id(); increment_sent(); // We increment before publishing so we don't have to lock twice. unlock(); - m_publisher->publish(data); + m_publisher->publish(*m_data_copy); } }