From d78d37df7a6f66fbaef019cbdfe8ab0336855f0e Mon Sep 17 00:00:00 2001 From: Christian Despres Date: Mon, 5 Dec 2022 15:23:10 +0000 Subject: [PATCH] Add options for JITServer AOT caching exclusion The -Xaot:jitserverLoadExclude and -Xaot:jitserverStoreExclude options reuse the existing method filtering framework so that clients can selectively exclude particular methods from AOT cache loading or storing in a connected JITServer. Fixes: #15399 Signed-off-by: Christian Despres --- .../compiler/control/CompilationRuntime.hpp | 3 ++ .../compiler/control/CompilationThread.cpp | 26 ++++++++++++ runtime/compiler/control/J9Options.cpp | 41 +++++++++++++++++++ runtime/compiler/control/J9Options.hpp | 13 ++++++ .../control/JITClientCompilationThread.cpp | 7 ++-- 5 files changed, 87 insertions(+), 3 deletions(-) diff --git a/runtime/compiler/control/CompilationRuntime.hpp b/runtime/compiler/control/CompilationRuntime.hpp index 1b8e81ffd6b..64b08156863 100644 --- a/runtime/compiler/control/CompilationRuntime.hpp +++ b/runtime/compiler/control/CompilationRuntime.hpp @@ -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); diff --git a/runtime/compiler/control/CompilationThread.cpp b/runtime/compiler/control/CompilationThread.cpp index bed4853686c..55241208e73 100644 --- a/runtime/compiler/control/CompilationThread.cpp +++ b/runtime/compiler/control/CompilationThread.cpp @@ -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) */ diff --git a/runtime/compiler/control/J9Options.cpp b/runtime/compiler/control/J9Options.cpp index 53ee4d96f3a..acd34b194f9 100644 --- a/runtime/compiler/control/J9Options.cpp +++ b/runtime/compiler/control/J9Options.cpp @@ -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) @@ -645,6 +647,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, " '%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) @@ -898,6 +933,12 @@ TR::OptionTable OMR::Options::_feOptions[] = { TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_iprofilerSamplesBeforeTurningOff, 0, "P%d", NOT_IN_SUBSET}, {"itFileNamePrefix=", "L\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\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" }, diff --git a/runtime/compiler/control/J9Options.hpp b/runtime/compiler/control/J9Options.hpp index cc833554fe6..2d0ee0e0042 100644 --- a/runtime/compiler/control/J9Options.hpp +++ b/runtime/compiler/control/J9Options.hpp @@ -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) @@ -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); @@ -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) */ }; } diff --git a/runtime/compiler/control/JITClientCompilationThread.cpp b/runtime/compiler/control/JITClientCompilationThread.cpp index 7fcd4af6a77..1b696fd41d6 100644 --- a/runtime/compiler/control/JITClientCompilationThread.cpp +++ b/runtime/compiler/control/JITClientCompilationThread.cpp @@ -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();