Skip to content

Commit

Permalink
Add timestamps, queue size and cleared caches information in diagnost…
Browse files Browse the repository at this point in the history
…ic thread

Added timestamps in the diagnostic thread to know when the information printed occurred.
In addition, I added the compilation queue size and the number of times the server clears the
clientSessionData/persistent caches.

Signed-off-by: Eman Elsabban <eman.elsaban1@gmail.com>
  • Loading branch information
EmanElsaban committed May 20, 2021
1 parent fad78e0 commit 557716c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions runtime/compiler/control/JITServerCompilationThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ TR::CompilationInfoPerThreadRemote::notifyAndDetachWaitingRequests(ClientSession
}
}

int32_t TR::CompilationInfoPerThreadRemote::_numClearedCaches = 0;

/**
* @brief Method executed by a compilation thread at JITServer to wait for all
* previous compilation requests it depends on to be processed.
Expand Down Expand Up @@ -335,6 +337,7 @@ TR::CompilationInfoPerThreadRemote::waitForMyTurn(ClientSessionData *clientSessi
!getWaitToBeNotified()) // Avoid a cohort of threads clearing the caches
{
clientSession->clearCaches();
incNumClearedCaches();

if (TR::Options::getVerboseOption(TR_VerboseJITServer))
TR_VerboseLog::writeLineLocked(TR_Vlog_JITServer,
Expand Down
4 changes: 4 additions & 0 deletions runtime/compiler/control/JITServerCompilationThread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class CompilationInfoPerThreadRemote : public TR::CompilationInfoPerThread
void waitForMyTurn(ClientSessionData *clientSession, TR_MethodToBeCompiled &entry); // Return false if timeout
bool getWaitToBeNotified() const { return _waitToBeNotified; }
void setWaitToBeNotified(bool b) { _waitToBeNotified = b; }
static int32_t getNumClearedCaches() { return _numClearedCaches; }
void incNumClearedCaches() { _numClearedCaches++; }

void copyClientOptions(const std::string &clientOptStr, TR_PersistentMemory *persistentMemory)
{
Expand Down Expand Up @@ -177,6 +179,8 @@ class CompilationInfoPerThreadRemote : public TR::CompilationInfoPerThread
FieldOrStaticAttrTable_t *_staticAttributesCache;
UnorderedMap<std::pair<TR_OpaqueClassBlock *, int32_t>, TR_IsUnresolvedString> *_isUnresolvedStrCache;
int32_t _classUnloadReadMutexDepth;
static int32_t _numClearedCaches; //number of instances JITServer was forced to clear its internal per-client caches

}; // class CompilationInfoPerThreadRemote
} // namespace TR

Expand Down
9 changes: 9 additions & 0 deletions runtime/compiler/runtime/JITServerStatisticsThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "env/VMJ9.h" // for TR_JitPrivateConfig
#include "env/VerboseLog.hpp"
#include "control/CompilationRuntime.hpp" // for CompilatonInfo
#include "control/JITServerCompilationThread.hpp"

JITServerStatisticsThread::JITServerStatisticsThread()
: _statisticsThread(NULL), _statisticsThreadMonitor(NULL), _statisticsOSThread(NULL),
Expand Down Expand Up @@ -72,10 +73,12 @@ static int32_t J9THREAD_PROC statisticsThreadProc(void * entryarg)
TR::CompilationInfo *compInfo = TR::CompilationInfo::get(jitConfig);
TR::PersistentInfo *persistentInfo = compInfo->getPersistentInfo();
PORT_ACCESS_FROM_JAVAVM(vm);
OMRPORT_ACCESS_FROM_J9PORT(PORTLIB);
uint64_t crtTime = j9time_current_time_millis();
uint64_t lastStatsTime = crtTime;
uint64_t lastPurgeTime = crtTime;
uint64_t lastCpuUpdate = crtTime;
char timestamp[32];

persistentInfo->setStartTime(crtTime);
persistentInfo->setElapsedTime(0);
Expand Down Expand Up @@ -112,10 +115,16 @@ static int32_t J9THREAD_PROC statisticsThreadProc(void * entryarg)
avgCpuUsage = cpuUtil->getAvgCpuUsage();
vmCpuUsage = cpuUtil->getVmCpuUsage();
}
omrstr_ftime_ex(timestamp, sizeof(timestamp), "%b %d %H:%M:%S %Y", crtTime, OMRSTR_FTIME_FLAG_LOCAL);

TR_VerboseLog::vlogAcquire();
TR_VerboseLog::writeLine(TR_Vlog_JITServer, "CurrentTime: %s", timestamp);
TR_VerboseLog::writeLine(TR_Vlog_JITServer, "Compilation Queue Size: %d", compInfo->getMethodQueueSize());
TR_VerboseLog::writeLine(TR_Vlog_JITServer, "Number of clients : %u", compInfo->getClientSessionHT()->size());
TR_VerboseLog::writeLine(TR_Vlog_JITServer, "Total compilation threads : %d", compInfo->getNumUsableCompilationThreads());
TR_VerboseLog::writeLine(TR_Vlog_JITServer, "Active compilation threads : %d",compInfo->getNumCompThreadsActive());
if (TR::CompilationInfoPerThreadRemote::getNumClearedCaches() > 0)
TR_VerboseLog::writeLine(TR_Vlog_JITServer, "Number of times the clientSession caches are cleared: %d", TR::CompilationInfoPerThreadRemote::getNumClearedCaches());
bool incompleteInfo;
TR_VerboseLog::writeLine(TR_Vlog_JITServer, "Physical memory available: %llu MB", compInfo->computeAndCacheFreePhysicalMemory(incompleteInfo) >> 20);
if (cpuUtil->isFunctional())
Expand Down

0 comments on commit 557716c

Please sign in to comment.