Skip to content

Commit

Permalink
disclaim_cold_cache PR comments 1
Browse files Browse the repository at this point in the history
  • Loading branch information
gita-omr committed May 1, 2024
1 parent c58500a commit 1f360da
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
6 changes: 6 additions & 0 deletions runtime/compiler/control/J9Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2905,6 +2905,12 @@ J9::Options::fePostProcessJIT(void * base)
TR::Options::disableMemoryDisclaimIfNeeded(jitConfig);
}

if (TR::Compiler->target.isLinux() &&
self()->getOption(TR_EnableCodeCacheDisclaiming))
{
jitConfig->codeCacheKB *= 2;
}

#if defined(J9VM_OPT_JITSERVER)
self()->setupJITServerOptions();
#endif /* defined(J9VM_OPT_JITSERVER) */
Expand Down
2 changes: 1 addition & 1 deletion runtime/compiler/control/rossa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ onLoadInternal(
}
else
{
jitConfig->codeCacheKB = TR::Options::getCmdLineOptions()->getOption(TR_EnableCodeCacheDisclaiming) 2048 * 2 : 2048;
jitConfig->codeCacheKB = 2048;
jitConfig->dataCacheKB = 2048;
}
#else
Expand Down
12 changes: 8 additions & 4 deletions runtime/compiler/runtime/J9CodeCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@
// for madvise
#ifdef LINUX
#include <sys/mman.h>
#ifndef MADV_NOHUGEPAGE
#define MADV_NOHUGEPAGE 15
#endif // MADV_NOHUGEPAGE
#ifndef MADV_PAGEOUT
#define MADV_PAGEOUT 21
#endif
#endif // MADV_PAGEOUT
#endif

OMR::CodeCacheMethodHeader *getCodeCacheMethodHeader(char *p, int searchLimit, J9JITExceptionTable * metaData);
Expand Down Expand Up @@ -147,11 +150,12 @@ J9::CodeCache::initialize(TR::CodeCacheManager *manager,
#ifdef LINUX
if (manager->isDisclaimEnabled())
{
uint8_t *middle = _warmCodeAlloc + (_coldCodeAlloc - _warmCodeAlloc) / 2;
uint8_t *middle = _warmCodeAlloc + (_coldCodeAllocBase - _warmCodeAlloc) / 2;
size_t round = DISCLAIM_PAGE_SIZE - 1;

middle = (uint8_t *)(((size_t)(middle + round)) & ~round);
size_t coldCacheSize = _coldCodeAlloc - middle;
coldCacheSize = (coldCacheSize + round) & ~round;

if (madvise(middle, coldCacheSize, MADV_NOHUGEPAGE) != 0)
{
Expand Down Expand Up @@ -826,9 +830,9 @@ J9::CodeCache::disclaim(TR::CodeCacheManager *manager, bool canDisclaimOnSwap)
size_t warm_size = _warmCodeAlloc - _segment->segmentBase() + sizeof(this);
size_t cold_size = _coldCodeAllocBase - _coldCodeAlloc;

TR_VerboseLog::writeLine(TR_Vlog_PERF, "Disclaiming cold code cache %p : coldStart=%p coldBase=%p warm_size=%zuB cold_size=%zuB cold_size/warm_size=%5.2f%%\n",
TR_VerboseLog::writeLine(TR_Vlog_PERF, "Disclaiming cold code cache %p : coldStart=%p coldBase=%p warm_size=%zuB cold_size=%zuB cold_size/(cold_size + warm_size)=%5.2f%%\n",
this, _coldCodeAlloc, _coldCodeAllocBase,
warm_size, cold_size, cold_size * 100.0/warm_size);
warm_size, cold_size, cold_size * 100.0/(cold_size + warm_size));
}

int32_t ret = madvise((void *)disclaim_start, disclaim_size, MADV_PAGEOUT);
Expand Down
2 changes: 0 additions & 2 deletions runtime/compiler/runtime/J9CodeCacheManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,6 @@ J9::CodeCacheManager::allocateCodeCacheSegment(size_t segmentSize,
#ifdef LINUX
if (_disclaimEnabled)
{
segmentType |= MEMORY_TYPE_VIRTUAL; // Make sure mmap is used for allocation

// If swap is enabled, we can allocate memory with mmap(MAP_ANOYNMOUS|MAP_PRIVATE) and disclaim to swap
// If swap is not enabled we can disclaim to a backing file
TR::CompilationInfo * compInfo = TR::CompilationInfo::get(_jitConfig);
Expand Down

0 comments on commit 1f360da

Please sign in to comment.