From 1058363ff52f53ce6ff0c4e995ff88d6a10b6a94 Mon Sep 17 00:00:00 2001 From: Josh Finken Date: Tue, 17 Oct 2023 15:44:51 -0600 Subject: [PATCH 1/3] Update the resource-utilization calc to an average over the last N milliseconds. Previously, RU was calculated since program-start. This commit changes this calculation to average over the last N milliseconds. --- performance_metrics/src/resource_usage_logger.cpp | 8 +++++++- performance_test_factory/src/cli_options.cpp | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/performance_metrics/src/resource_usage_logger.cpp b/performance_metrics/src/resource_usage_logger.cpp index 4fe94a9d..60766711 100644 --- a/performance_metrics/src/resource_usage_logger.cpp +++ b/performance_metrics/src/resource_usage_logger.cpp @@ -49,7 +49,9 @@ void ResourceUsageLogger::start(std::chrono::milliseconds period) std::cout << "[ResourceUsageLogger]: Logging to " << m_filename << std::endl; m_t1_real_start = std::chrono::steady_clock::now(); - m_t1_user = std::clock(); + // Question: make this a flag? That is, calc RU since program start or over + // the last `period` ms. + //m_t1_user = std::clock(); m_t1_real = std::chrono::steady_clock::now(); m_logger_thread_done = false; @@ -58,6 +60,10 @@ void ResourceUsageLogger::start(std::chrono::milliseconds period) [ = ]() { int64_t i = 1; while (m_is_logging) { + // Updating m_t1_user here will have the effect of averaging resource + // utilization only over the last `period` milliseconds, *not* since + // program start. + m_t1_user = std::clock(); std::this_thread::sleep_until(m_t1_real_start + period * i); if (i == 1) { _print_header(m_file); diff --git a/performance_test_factory/src/cli_options.cpp b/performance_test_factory/src/cli_options.cpp index 96bbd185..de141755 100644 --- a/performance_test_factory/src/cli_options.cpp +++ b/performance_test_factory/src/cli_options.cpp @@ -29,7 +29,7 @@ Options::Options() name_threads = true; duration_sec = 5; csv_out = false; - resources_sampling_per_ms = 500; + resources_sampling_per_ms = 1000; tracking_options.is_enabled = false; tracking_options.late_percentage = 20; tracking_options.late_absolute_us = 5000; From 9ef72405f5ba139bc09a1b0159abce7e7816b5ae Mon Sep 17 00:00:00 2001 From: Josh Finken Date: Wed, 18 Oct 2023 11:32:12 -0600 Subject: [PATCH 2/3] Update m_t1_real start --- performance_metrics/src/resource_usage_logger.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/performance_metrics/src/resource_usage_logger.cpp b/performance_metrics/src/resource_usage_logger.cpp index 60766711..260dce8b 100644 --- a/performance_metrics/src/resource_usage_logger.cpp +++ b/performance_metrics/src/resource_usage_logger.cpp @@ -49,10 +49,8 @@ void ResourceUsageLogger::start(std::chrono::milliseconds period) std::cout << "[ResourceUsageLogger]: Logging to " << m_filename << std::endl; m_t1_real_start = std::chrono::steady_clock::now(); - // Question: make this a flag? That is, calc RU since program start or over - // the last `period` ms. //m_t1_user = std::clock(); - m_t1_real = std::chrono::steady_clock::now(); + //m_t1_real = std::chrono::steady_clock::now(); m_logger_thread_done = false; // create a detached thread that monitors resource usage periodically @@ -60,10 +58,11 @@ void ResourceUsageLogger::start(std::chrono::milliseconds period) [ = ]() { int64_t i = 1; while (m_is_logging) { - // Updating m_t1_user here will have the effect of averaging resource - // utilization only over the last `period` milliseconds, *not* since - // program start. + // Updating m_t1_user and m_t1_real here will have the effect of calculating + // resource utilization only over the last `period` milliseconds, *not* + // since program start. m_t1_user = std::clock(); + m_t1_real = std::chrono::steady_clock::now(); std::this_thread::sleep_until(m_t1_real_start + period * i); if (i == 1) { _print_header(m_file); From 84e4d27563fb6f6bdf99b5834c2a2559b2f31839 Mon Sep 17 00:00:00 2001 From: Josh Finken Date: Mon, 23 Oct 2023 07:57:06 -0600 Subject: [PATCH 3/3] PR build_and_test fixes --- performance_metrics/src/resource_usage_logger.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/performance_metrics/src/resource_usage_logger.cpp b/performance_metrics/src/resource_usage_logger.cpp index 260dce8b..959a1409 100644 --- a/performance_metrics/src/resource_usage_logger.cpp +++ b/performance_metrics/src/resource_usage_logger.cpp @@ -49,8 +49,6 @@ void ResourceUsageLogger::start(std::chrono::milliseconds period) std::cout << "[ResourceUsageLogger]: Logging to " << m_filename << std::endl; m_t1_real_start = std::chrono::steady_clock::now(); - //m_t1_user = std::clock(); - //m_t1_real = std::chrono::steady_clock::now(); m_logger_thread_done = false; // create a detached thread that monitors resource usage periodically @@ -59,7 +57,7 @@ void ResourceUsageLogger::start(std::chrono::milliseconds period) int64_t i = 1; while (m_is_logging) { // Updating m_t1_user and m_t1_real here will have the effect of calculating - // resource utilization only over the last `period` milliseconds, *not* + // resource utilization only over the last `period` milliseconds, *not* // since program start. m_t1_user = std::clock(); m_t1_real = std::chrono::steady_clock::now();