From 1c36203493ba96e003fe3587bf7cd40e249a6ad8 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 21 Sep 2021 15:17:14 -0500 Subject: [PATCH] Protect storage accounting UDP messages from NaN NaN's were being reported from the values computed using sqrt. This most likely was from the different variables not being updated atomically together. --- .../src/StatisticsSenderService.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Utilities/StorageFactory/src/StatisticsSenderService.cc b/Utilities/StorageFactory/src/StatisticsSenderService.cc index 53457f49e0b81..d68f83bbd0576 100644 --- a/Utilities/StorageFactory/src/StatisticsSenderService.cc +++ b/Utilities/StorageFactory/src/StatisticsSenderService.cc @@ -77,9 +77,9 @@ void StatisticsSenderService::FileStatistics::fillUDP(std::ostringstream &os) { double single_sum = read_single_bytes - m_read_single_bytes; double single_average = single_sum / static_cast(single_op_count); os << "\"read_single_sigma\":" - << sqrt((static_cast(read_single_square - m_read_single_square) - - single_average * single_average * single_op_count) / - static_cast(single_op_count)) + << sqrt(std::abs((static_cast(read_single_square - m_read_single_square) - + single_average * single_average * single_op_count) / + static_cast(single_op_count))) << ", "; os << "\"read_single_average\":" << single_average << ", "; } @@ -90,17 +90,17 @@ void StatisticsSenderService::FileStatistics::fillUDP(std::ostringstream &os) { static_cast(read_vector_bytes - m_read_vector_bytes) / static_cast(vector_op_count); os << "\"read_vector_average\":" << vector_average << ", "; os << "\"read_vector_sigma\":" - << sqrt((static_cast(read_vector_square - m_read_vector_square) - - vector_average * vector_average * vector_op_count) / - static_cast(vector_op_count)) + << sqrt(std::abs((static_cast(read_vector_square - m_read_vector_square) - + vector_average * vector_average * vector_op_count) / + static_cast(vector_op_count))) << ", "; double vector_count_average = static_cast(read_vector_count_sum - m_read_vector_count_sum) / static_cast(vector_op_count); os << "\"read_vector_count_average\":" << vector_count_average << ", "; os << "\"read_vector_count_sigma\":" - << sqrt((static_cast(read_vector_count_square - m_read_vector_count_square) - - vector_count_average * vector_count_average * vector_op_count) / - static_cast(vector_op_count)) + << sqrt(std::abs((static_cast(read_vector_count_square - m_read_vector_count_square) - + vector_count_average * vector_count_average * vector_op_count) / + static_cast(vector_op_count))) << ", "; } m_read_vector_square = read_vector_square;