Skip to content

Commit

Permalink
Merge pull request #9681 from a7ehuo/jitserver-trace
Browse files Browse the repository at this point in the history
Add trace points for JITServer
  • Loading branch information
mpirvu committed May 28, 2020
2 parents 4388915 + c265023 commit 42df7a4
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 19 deletions.
11 changes: 9 additions & 2 deletions runtime/compiler/control/CompilationThread.cpp
Expand Up @@ -8612,12 +8612,14 @@ TR::CompilationInfoPerThreadBase::wrappedCompile(J9PortLibrary *portLib, void *
if (TR::Options::getVerboseOption(TR_VerboseJITServer))
TR_VerboseLog::writeLineLocked(TR_Vlog_JITServer, "<EARLY TRANSLATION FAILURE: JITServer stream failure>");
that->_methodBeingCompiled->_compErrCode = compilationStreamFailure;
Trc_JITServerStreamFailure(vmThread, that->getCompThreadId(), __FUNCTION__, "", "", e.what());
}
catch (const JITServer::StreamInterrupted &e)
{
if (TR::Options::getVerboseOption(TR_VerboseJITServer))
TR_VerboseLog::writeLineLocked(TR_Vlog_JITServer, "<EARLY TRANSLATION FAILURE: compilation interrupted by JITClient>");
that->_methodBeingCompiled->_compErrCode = compilationStreamInterrupted;
Trc_JITServerStreamInterrupted(vmThread, that->getCompThreadId(), __FUNCTION__, e.what());
}
#endif /* defined(J9VM_OPT_JITSERVER) */
catch (const J9::JITShutdown)
Expand All @@ -8631,6 +8633,7 @@ TR::CompilationInfoPerThreadBase::wrappedCompile(J9PortLibrary *portLib, void *
if (TR::Options::isAnyVerboseOptionSet(TR_VerboseCompileEnd, TR_VerboseCompFailure, TR_VerbosePerformance))
TR_VerboseLog::writeLineLocked(TR_Vlog_FAILURE,"<EARLY TRANSLATION FAILURE: out of scratch memory>");
that->_methodBeingCompiled->_compErrCode = compilationFailure;
Trc_JIT_outOfMemory(vmThread);
}
catch (const std::exception &e)
{
Expand All @@ -8639,8 +8642,6 @@ TR::CompilationInfoPerThreadBase::wrappedCompile(J9PortLibrary *portLib, void *
that->_methodBeingCompiled->_compErrCode = compilationFailure;
}

Trc_JIT_outOfMemory(vmThread);

#if defined(J9VM_OPT_JITSERVER)
if (compiler && compiler->getPersistentInfo()->getRemoteCompilationMode() == JITServer::SERVER)
{
Expand Down Expand Up @@ -10503,6 +10504,9 @@ TR::CompilationInfo::compilationEnd(J9VMThread * vmThread, TR::IlGeneratorMethod
"compThreadID=%d has failed to compile: compErrCode %u %s",
entry->_compInfoPT->getCompThreadId(), entry->_compErrCode, comp ? comp->signature() : "");
}
if (vmThread)
Trc_JITServerFailedToCompile(vmThread, entry->_compInfoPT->getCompThreadId(), entry->_compErrCode, comp ? comp->signature() : "");

static bool breakAfterFailedCompile = feGetEnv("TR_breakAfterFailedCompile") != NULL;
if (breakAfterFailedCompile)
{
Expand Down Expand Up @@ -10533,6 +10537,9 @@ TR::CompilationInfo::compilationEnd(J9VMThread * vmThread, TR::IlGeneratorMethod
"compThreadID=%d has failed to recompile: compErrCode %u %s",
entry->_compInfoPT->getCompThreadId(), entry->_compErrCode, comp ? comp->signature() : "");
}
if (vmThread)
Trc_JITServerFailedToRecompile(vmThread, entry->_compInfoPT->getCompThreadId(), entry->_compErrCode, comp ? comp->signature() : "");

int8_t compErrCode = entry->_compErrCode;
if (compErrCode != compilationStreamInterrupted && compErrCode != compilationStreamFailure)
entry->_stream->writeError(compilationNotNeeded);
Expand Down
32 changes: 31 additions & 1 deletion runtime/compiler/control/JITClientCompilationThread.cpp
Expand Up @@ -30,6 +30,7 @@
#include "env/J2IThunk.hpp"
#include "env/j9methodServer.hpp"
#include "env/JITServerPersistentCHTable.hpp"
#include "env/ut_j9jit.h"
#include "env/VMAccessCriticalSection.hpp"
#include "env/VMJ9.h"
#include "net/ClientStream.hpp"
Expand Down Expand Up @@ -187,6 +188,7 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes
TR_VerboseLog::writeLineLocked(TR_Vlog_FAILURE, "Interrupting remote compilation (interruptReason %u) in handleServerMessage(%s) for %s @ %s",
interruptReason, JITServer::messageNames[response], comp->signature(), comp->getHotnessName());

Trc_JITServerInterruptRemoteCompile(vmThread, interruptReason, JITServer::messageNames[response], comp->signature(), comp->getHotnessName());
comp->failCompilation<TR::CompilationInterrupted>("Compilation interrupted in handleServerMessage");
}

Expand Down Expand Up @@ -3102,6 +3104,7 @@ remoteCompile(
if (TR::Options::isAnyVerboseOptionSet(TR_VerboseJITServer, TR_VerboseCompilationDispatch))
TR_VerboseLog::writeLineLocked(TR_Vlog_FAILURE,
"Server is not available. Retry with local compilation for %s @ %s", compiler->signature(), compiler->getHotnessName());
Trc_JITServerRetryLocalCompile(vmThread, compiler->signature(), compiler->getHotnessName());
compiler->failCompilation<JITServer::StreamFailure>("Server is not available, should retry with local compilation.");
}
}
Expand All @@ -3111,6 +3114,10 @@ remoteCompile(
if (TR::Options::isAnyVerboseOptionSet(TR_VerboseJITServer, TR_VerboseCompilationDispatch))
TR_VerboseLog::writeLineLocked(TR_Vlog_FAILURE,
"JITServer::StreamFailure: %s for %s @ %s", e.what(), compiler->signature(), compiler->getHotnessName());

Trc_JITServerStreamFailure(vmThread, compInfoPT->getCompThreadId(), __FUNCTION__,
compiler->signature(), compiler->getHotnessName(), e.what());

compiler->failCompilation<JITServer::StreamFailure>(e.what());
}
catch (const std::bad_alloc &e)
Expand Down Expand Up @@ -3172,6 +3179,9 @@ remoteCompile(
"Client sending compReq seqNo=%u to server for method %s @ %s.",
seqNo, compiler->signature(), compiler->getHotnessName());
}

Trc_JITServerRemoteCompileRequest(vmThread, seqNo, compiler->signature(), compiler->getHotnessName());

client->buildCompileRequest(TR::comp()->getPersistentInfo()->getClientUID(), seqNo, romMethodOffset, method,
clazz, *compInfoPT->getMethodBeingCompiled()->_optimizationPlan, detailsStr,
details.getType(), unloadedClasses, illegalModificationList, classInfoTuple, optionsStr, recompMethodInfoStr,
Expand Down Expand Up @@ -3206,7 +3216,9 @@ remoteCompile(
auto recv = client->getRecvData<uint32_t>();
statusCode = std::get<0>(recv);
if (TR::Options::getVerboseOption(TR_VerboseJITServer))
TR_VerboseLog::writeLineLocked(TR_Vlog_JITServer, "remoteCompile: JITServer::MessageType::compilationFailure statusCode %u\n", statusCode);
TR_VerboseLog::writeLineLocked(TR_Vlog_JITServer, "remoteCompile: compilationFailure statusCode %u\n", statusCode);

Trc_JITServerRemoteCompilationFailure(vmThread, statusCode);
}

if (statusCode >= compilationMaxError)
Expand All @@ -3228,6 +3240,10 @@ remoteCompile(
if (TR::Options::isAnyVerboseOptionSet(TR_VerboseJITServer, TR_VerboseCompilationDispatch))
TR_VerboseLog::writeLineLocked(TR_Vlog_FAILURE,
"JITServer::StreamFailure: %s for %s @ %s", e.what(), compiler->signature(), compiler->getHotnessName());

Trc_JITServerStreamFailure(vmThread, compInfoPT->getCompThreadId(), __FUNCTION__,
compiler->signature(), compiler->getHotnessName(), e.what());

compiler->failCompilation<JITServer::StreamFailure>(e.what());
}
catch (const JITServer::StreamVersionIncompatible &e)
Expand All @@ -3240,13 +3256,21 @@ remoteCompile(
if (TR::Options::isAnyVerboseOptionSet(TR_VerboseJITServer, TR_VerboseCompilationDispatch))
TR_VerboseLog::writeLineLocked(TR_Vlog_FAILURE,
"JITServer::StreamVersionIncompatible: %s for %s @ %s", e.what(), compiler->signature(), compiler->getHotnessName());

Trc_JITServerStreamVersionIncompatible(vmThread, compInfoPT->getCompThreadId(), __FUNCTION__,
compiler->signature(), compiler->getHotnessName(), e.what());

compiler->failCompilation<JITServer::StreamVersionIncompatible>(e.what());
}
catch (const JITServer::StreamMessageTypeMismatch &e)
{
if (TR::Options::isAnyVerboseOptionSet(TR_VerboseJITServer, TR_VerboseCompilationDispatch))
TR_VerboseLog::writeLineLocked(TR_Vlog_FAILURE,
"JITServer::StreamMessageTypeMismatch: %s for %s @ %s", e.what(), compiler->signature(), compiler->getHotnessName());

Trc_JITServerStreamMessageTypeMismatch(vmThread, compInfoPT->getCompThreadId(), __FUNCTION__,
compiler->signature(), compiler->getHotnessName(), e.what());

compiler->failCompilation<JITServer::StreamMessageTypeMismatch>(e.what());
}

Expand Down Expand Up @@ -3375,6 +3399,8 @@ remoteCompile(
metaData, (metaData) ? (void *)metaData->startPC : NULL
);
}
Trc_JITServerMethodSuccessfullyLoaded(vmThread, compiler->signature(),compiler->getHotnessName(),
metaData, (metaData) ? (void *)metaData->startPC : NULL);
}
catch (const std::exception &e)
{
Expand All @@ -3388,6 +3414,7 @@ remoteCompile(
compiler->getHotnessName()
);
}
Trc_JITServerMethodFailedToLoad(vmThread, compiler->signature(),compiler->getHotnessName());
throw;
}
}
Expand All @@ -3398,6 +3425,9 @@ remoteCompile(
if (TR::Options::isAnyVerboseOptionSet(TR_VerboseJITServer, TR_VerboseCompilationDispatch))
TR_VerboseLog::writeLineLocked(TR_Vlog_FAILURE,
"JITServer::ServerCompilationFailure: errCode %u for %s @ %s", statusCode, compiler->signature(), compiler->getHotnessName());

Trc_JITServerServerCompilationFailure(vmThread, statusCode, compiler->signature(), compiler->getHotnessName());

compiler->failCompilation<JITServer::ServerCompilationFailure>("JITServer compilation failed.");
}

Expand Down

0 comments on commit 42df7a4

Please sign in to comment.