From a5cd649483d63e7267e256cffaa333039936bc29 Mon Sep 17 00:00:00 2001 From: Eman Elsabban Date: Fri, 29 May 2020 06:35:24 -0700 Subject: [PATCH] Collect stats about sizes of different types of messages sent I'm keeping track of the size of different types of messages sent using msg.type() and I'm using the class TR_Stats to store avg,min,max and stddev of every type of message. I declared a static array in CommunicationStream.hpp and I'm using that to store in. issue: #9708 Signed-off-by: Eman Elsabban --- runtime/compiler/control/JITServerHelpers.cpp | 17 +++++++++++++++-- runtime/compiler/net/CommunicationStream.cpp | 8 ++++++++ runtime/compiler/net/CommunicationStream.hpp | 5 +++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/runtime/compiler/control/JITServerHelpers.cpp b/runtime/compiler/control/JITServerHelpers.cpp index 4330a21392d..26e67c6ae5a 100644 --- a/runtime/compiler/control/JITServerHelpers.cpp +++ b/runtime/compiler/control/JITServerHelpers.cpp @@ -26,6 +26,9 @@ #include "control/JITServerCompilationThread.hpp" #include "control/MethodToBeCompiled.hpp" #include "infra/CriticalSection.hpp" +#include "infra/Statistics.hpp" +#include "net/CommunicationStream.hpp" + uint32_t JITServerHelpers::serverMsgTypeCount[] = {}; @@ -123,12 +126,22 @@ JITServerHelpers::printJITServerMsgStats(J9JITConfig *jitConfig) int totalMsgCount = 0; PORT_ACCESS_FROM_JITCONFIG(jitConfig); j9tty_printf(PORTLIB, "JITServer Message Type Statistics:\n"); - j9tty_printf(PORTLIB, "Type# #called TypeName\n"); + j9tty_printf(PORTLIB, "Type# #called"); +#ifdef MESSAGE_SIZE_STATS + j9tty_printf(PORTLIB, "\t\tMax\t\tMin\t\tMean\t\tStdDev\t\tSum"); +#endif + j9tty_printf(PORTLIB, "\t\tTypeName\n"); for (int i = 0; i < JITServer::MessageType_ARRAYSIZE; ++i) { if (JITServerHelpers::serverMsgTypeCount[i] > 0) { - j9tty_printf(PORTLIB, "#%04d %7u %s\n", i, JITServerHelpers::serverMsgTypeCount[i], JITServer::messageNames[i]); + j9tty_printf(PORTLIB, "#%04d %7u", i, JITServerHelpers::serverMsgTypeCount[i]); +#ifdef MESSAGE_SIZE_STATS + j9tty_printf(PORTLIB, "\t%f\t%f\t%f\t%f\t%f", JITServer::CommunicationStream::collectMsgStat[i].maxVal(), + JITServer::CommunicationStream::collectMsgStat[i].minVal(), JITServer::CommunicationStream::collectMsgStat[i].mean(), + JITServer::CommunicationStream::collectMsgStat[i].stddev(), JITServer::CommunicationStream::collectMsgStat[i].sum()); +#endif + j9tty_printf(PORTLIB, "\t\t%s\n", JITServer::messageNames[i]); totalMsgCount += JITServerHelpers::serverMsgTypeCount[i]; } } diff --git a/runtime/compiler/net/CommunicationStream.cpp b/runtime/compiler/net/CommunicationStream.cpp index f02e6afbdf9..f0f79e16c70 100644 --- a/runtime/compiler/net/CommunicationStream.cpp +++ b/runtime/compiler/net/CommunicationStream.cpp @@ -29,6 +29,9 @@ namespace JITServer { uint32_t CommunicationStream::CONFIGURATION_FLAGS = 0; +#ifdef MESSAGE_SIZE_STATS +TR_Stats JITServer::CommunicationStream::collectMsgStat[]; +#endif void CommunicationStream::initConfigurationFlags() @@ -73,6 +76,11 @@ CommunicationStream::readMessage(Message &msg) // rebuild the message msg.deserialize(); + + // collect message size +#ifdef MESSAGE_SIZE_STATS + collectMsgStat[int(msg.type())].update(messageSize); +#endif } void diff --git a/runtime/compiler/net/CommunicationStream.hpp b/runtime/compiler/net/CommunicationStream.hpp index f282680e79c..86d8a83657b 100644 --- a/runtime/compiler/net/CommunicationStream.hpp +++ b/runtime/compiler/net/CommunicationStream.hpp @@ -28,6 +28,7 @@ #include #include "net/LoadSSLLibs.hpp" #include "net/Message.hpp" +#include "infra/Statistics.hpp" namespace JITServer @@ -43,6 +44,10 @@ class CommunicationStream public: static bool useSSL(); static void initSSL(); + +#ifdef MESSAGE_SIZE_STATS + static TR_Stats collectMsgStat[JITServer::MessageType_ARRAYSIZE]; +#endif static void initConfigurationFlags();