Skip to content

Commit

Permalink
Merge pull request #19506 from cjjdespres/malloc-trim
Browse files Browse the repository at this point in the history
Periodically issue malloc_trim at JITServer client
  • Loading branch information
mpirvu authored May 16, 2024
2 parents 5674d7c + e52971d commit a56cbdf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions runtime/compiler/control/HookedByTheJit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <algorithm>
#include <limits.h>
#include <malloc.h>
#include <stdarg.h>
#include "bcnames.h"
#include "jithash.h"
Expand Down Expand Up @@ -6723,6 +6724,16 @@ static int32_t J9THREAD_PROC samplerThreadProc(void * entryarg)
}

#if defined(J9VM_OPT_JITSERVER)
#if defined(LINUX)
static uint64_t lastMallocTrimTime = 0;
if ((TR::Options::_jitserverMallocTrimInterval > 0) &&
(persistentInfo->getRemoteCompilationMode() == JITServer::CLIENT) &&
(crtTime > lastMallocTrimTime + TR::Options::_jitserverMallocTrimInterval))
{
malloc_trim(0);
lastMallocTrimTime = crtTime;
}
#endif /* defined(LINUX) */
if (persistentInfo->getRemoteCompilationMode() == JITServer::CLIENT &&
TR::Options::_lowCompDensityModeEnterThreshold > 0 && // A value of 0 disables this feature
!TR::Options::getCmdLineOptions()->getOption(TR_FullSpeedDebug) && // FSD interferes with recompilations in LPQ
Expand Down
3 changes: 3 additions & 0 deletions runtime/compiler/control/J9Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ 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
int32_t J9::Options::_jitserverMallocTrimInterval = 1000 * 30; // 30000ms = 30s
int32_t J9::Options::_lowCompDensityModeEnterThreshold = 4; // Maximum number of compilations per 10 min of CPU required to enter low compilation density mode. Use 0 to disable feature
int32_t J9::Options::_lowCompDensityModeExitThreshold = 15; // Minimum number of compilations per 10 min of CPU required to exit low compilation density mode
int32_t J9::Options::_lowCompDensityModeExitLPQSize = 120; // Minimum number of compilations in LPQ to take us out of low compilation density mode
Expand Down Expand Up @@ -1062,6 +1063,8 @@ TR::OptionTable OMR::Options::_feOptions[] = {
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"},
{"jitserverMallocTrimInterval=", "M<nnn>\tmiminum time between two consecutive JITServer client malloc_trim invocations (ms)",
TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_jitserverMallocTrimInterval, 0, "F%d", NOT_IN_SUBSET },
#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 },
Expand Down
1 change: 1 addition & 0 deletions runtime/compiler/control/J9Options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ 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 int32_t _jitserverMallocTrimInterval;
static int32_t _lowCompDensityModeEnterThreshold;
static int32_t _lowCompDensityModeExitThreshold;
static int32_t _lowCompDensityModeExitLPQSize;
Expand Down

0 comments on commit a56cbdf

Please sign in to comment.