Skip to content

Commit

Permalink
Merge pull request #16442 from cjjdespres/aot-cache-exclusion
Browse files Browse the repository at this point in the history
Add options for JITServer AOT caching exclusion
  • Loading branch information
mpirvu authored Dec 21, 2022
2 parents 3e69bae + d78d37d commit 81a169a
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 3 deletions.
3 changes: 3 additions & 0 deletions runtime/compiler/control/CompilationRuntime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,9 @@ class CompilationInfo

JITServerAOTDeserializer *getJITServerAOTDeserializer() const { return _JITServerAOTDeserializer; }
void setJITServerAOTDeserializer(JITServerAOTDeserializer *deserializer) { _JITServerAOTDeserializer = deserializer; }

bool methodCanBeJITServerAOTCacheStored(const char *methodSig, TR::Method::Type ty);
bool methodCanBeJITServerAOTCacheLoaded(const char *methodSig, TR::Method::Type ty);
#endif /* defined(J9VM_OPT_JITSERVER) */

static void replenishInvocationCount(J9Method* method, TR::Compilation* comp);
Expand Down
26 changes: 26 additions & 0 deletions runtime/compiler/control/CompilationThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13037,4 +13037,30 @@ TR::CompilationInfo::requeueOutOfProcessEntry(TR_MethodToBeCompiled *entry)
getCompilationMonitor()->notifyAll();
}
}

static bool
queryJITServerAOTCacheFilter(const char *methodSig, TR::Method::Type ty, TR::CompilationFilters *filters)
{
if (!filters)
return true;

TR_Debug *debug = TR::Options::getDebug();
if (!debug)
return true;

TR_FilterBST *filter = NULL;
return debug->methodSigCanBeFound(methodSig, filters, filter, ty);
}

bool
TR::CompilationInfo::methodCanBeJITServerAOTCacheStored(const char *methodSig, TR::Method::Type ty)
{
return queryJITServerAOTCacheFilter(methodSig, ty, TR::Options::_JITServerAOTCacheStoreFilters);
}

bool
TR::CompilationInfo::methodCanBeJITServerAOTCacheLoaded(const char *methodSig, TR::Method::Type ty)
{
return queryJITServerAOTCacheFilter(methodSig, ty, TR::Options::_JITServerAOTCacheLoadFilters);
}
#endif /* defined(J9VM_OPT_JITSERVER) */
41 changes: 41 additions & 0 deletions runtime/compiler/control/J9Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ int32_t J9::Options::_highActiveThreadThreshold = -1;
int32_t J9::Options::_veryHighActiveThreadThreshold = -1;
int32_t J9::Options::_aotCachePersistenceMinDeltaMethods = 200;
int32_t J9::Options::_aotCachePersistenceMinPeriodMs = 10000; // ms
TR::CompilationFilters *J9::Options::_JITServerAOTCacheStoreFilters = NULL;
TR::CompilationFilters *J9::Options::_JITServerAOTCacheLoadFilters = NULL;
#endif /* defined(J9VM_OPT_JITSERVER) */

#if defined(J9VM_OPT_CRIU_SUPPORT)
Expand Down Expand Up @@ -648,6 +650,39 @@ Options::loadLimitfileOption(char * option, void * base, TR::OptionTable *entry)
}
}

#if defined(J9VM_OPT_JITSERVER)
char *
Options::JITServerAOTCacheLimitOption(char *option, void *base, TR::OptionTable *entry, TR::CompilationFilters *&filters, const char *optName)
{
if (!TR::Options::getDebug() && !TR::Options::createDebug())
return NULL;
if (TR::Options::getJITCmdLineOptions() == NULL)
{
// if JIT options are NULL, means we're processing AOT options now
return TR::Options::getDebug()->limitOption(option, base, entry, TR::Options::getAOTCmdLineOptions(), filters);
}
else
{
// otherwise, we're processing JIT options
J9JITConfig * jitConfig = (J9JITConfig*)base;
PORT_ACCESS_FROM_JAVAVM(jitConfig->javaVM);
j9tty_printf(PORTLIB, "<JIT: %s option should be specified on -Xaot --> '%s'>\n", optName, option);
return option;
}
}

char *
Options::JITServerAOTCacheStoreLimitOption(char *option, void *base, TR::OptionTable *entry)
{
return JITServerAOTCacheLimitOption(option, base, entry, _JITServerAOTCacheStoreFilters, "jitserverAOTCacheStoreExclude");
}

char *
Options::JITServerAOTCacheLoadLimitOption(char *option, void *base, TR::OptionTable *entry)
{
return JITServerAOTCacheLimitOption(option, base, entry, _JITServerAOTCacheLoadFilters, "jitserverAOTCacheLoadExclude");
}
#endif /* defined(J9VM_OPT_JITSERVER) */

char *
Options::tprofOption(char * option, void * base, TR::OptionTable *entry)
Expand Down Expand Up @@ -901,6 +936,12 @@ TR::OptionTable OMR::Options::_feOptions[] = {
TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_iprofilerSamplesBeforeTurningOff, 0, "P%d", NOT_IN_SUBSET},
{"itFileNamePrefix=", "L<filename>\tprefix for itrace filename",
TR::Options::setStringForPrivateBase, offsetof(TR_JitPrivateConfig,itraceFileNamePrefix), 0, "P%s"},
#if defined(J9VM_OPT_JITSERVER)
{"jitserverAOTCacheLoadExclude=", "D{regex}\tdo not load methods matching regex from the JITServer AOT cache",
TR::Options::JITServerAOTCacheLoadLimitOption, 1, 0, "P%s"},
{"jitserverAOTCacheStoreExclude=", "D{regex}\tdo not store methods matching regex in the JITServer AOT cache",
TR::Options::JITServerAOTCacheStoreLimitOption, 1, 0, "P%s"},
#endif /* defined(J9VM_OPT_JITSERVER) */
{"jProfilingEnablementSampleThreshold=", "M<nnn>\tNumber of global samples to allow generation of JProfiling bodies",
TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_jProfilingEnablementSampleThreshold, 0, "F%d", NOT_IN_SUBSET },
{"kcaoffsets", "I\tGenerate a header file with offset data for use with KCA", TR::Options::kcaOffsets, 0, 0, "F" },
Expand Down
13 changes: 13 additions & 0 deletions runtime/compiler/control/J9Options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ class OMR_EXTENSIBLE Options : public OMR::OptionsConnector
static const uint32_t DEFAULT_JITSERVER_TIMEOUT = 30000; // ms
static int32_t _aotCachePersistenceMinDeltaMethods;
static int32_t _aotCachePersistenceMinPeriodMs;
static TR::CompilationFilters *_JITServerAOTCacheStoreFilters;
static TR::CompilationFilters *_JITServerAOTCacheLoadFilters;
#endif /* defined(J9VM_OPT_JITSERVER) */

#if defined(J9VM_OPT_CRIU_SUPPORT)
Expand Down Expand Up @@ -357,6 +359,11 @@ class OMR_EXTENSIBLE Options : public OMR::OptionsConnector

static char *loadLimitfileOption(char *option, void *, TR::OptionTable *entry);

#if defined(J9VM_OPT_JITSERVER)
static char *JITServerAOTCacheStoreLimitOption(char *option, void *, TR::OptionTable *entry);
static char *JITServerAOTCacheLoadLimitOption(char *option, void *, TR::OptionTable *entry);
#endif /* defined(J9VM_OPT_JITSERVER) */

static char *vmStateOption(char *option, void *, TR::OptionTable *entry);

static char *setJitConfigRuntimeFlag(char *option, void *base, TR::OptionTable *entry);
Expand Down Expand Up @@ -519,6 +526,12 @@ class OMR_EXTENSIBLE Options : public OMR::OptionsConnector
void setLogFileForClientOptions(int suffixNumber = 0);
void closeLogFileForClientOptions();
#endif /* defined(J9VM_OPT_JITSERVER) */

private:

#if defined(J9VM_OPT_JITSERVER)
static char *JITServerAOTCacheLimitOption(char *option, void *base, TR::OptionTable *entry, TR::CompilationFilters *&filters, const char *optName);
#endif /* defined(J9VM_OPT_JITSERVER) */
};

}
Expand Down
7 changes: 4 additions & 3 deletions runtime/compiler/control/JITClientCompilationThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3052,9 +3052,10 @@ remoteCompile(J9VMThread *vmThread, TR::Compilation *compiler, TR_ResolvedMethod
TR::PersistentInfo *persistentInfo = compInfo->getPersistentInfo();
bool useAotCompilation = entry->_useAotCompilation;

bool aotCacheStore = useAotCompilation && persistentInfo->getJITServerUseAOTCache();
bool aotCacheLoad = useAotCompilation && persistentInfo->getJITServerUseAOTCache() &&
!entry->_doNotLoadFromJITServerAOTCache;
bool aotCacheStore = useAotCompilation && persistentInfo->getJITServerUseAOTCache() &&
compInfo->methodCanBeJITServerAOTCacheStored(compiler->signature(), compilee->convertToMethod()->methodType());
bool aotCacheLoad = aotCacheStore && !entry->_doNotLoadFromJITServerAOTCache &&
compInfo->methodCanBeJITServerAOTCacheLoaded(compiler->signature(), compilee->convertToMethod()->methodType());
auto deserializer = compInfo->getJITServerAOTDeserializer();
if (!aotCacheLoad && deserializer)
deserializer->incNumCacheBypasses();
Expand Down

0 comments on commit 81a169a

Please sign in to comment.