Skip to content

Commit

Permalink
Use RSSReport class
Browse files Browse the repository at this point in the history
  • Loading branch information
gita-omr committed May 27, 2024
1 parent ec6dc8e commit 143b9f7
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 2 deletions.
3 changes: 2 additions & 1 deletion runtime/compiler/build/files/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ JIT_PRODUCT_SOURCE_FILES+=\
omr/compiler/runtime/OMRCodeCacheConfig.cpp \
omr/compiler/runtime/OMRCodeCacheManager.cpp \
omr/compiler/runtime/OMRCodeCacheMemorySegment.cpp \
omr/compiler/runtime/OMRRuntimeAssumptions.cpp
omr/compiler/runtime/OMRRuntimeAssumptions.cpp \
omr/compiler/runtime/OMRRSSReport.cpp

ifneq ($(J9VM_OPT_JITSERVER),)
JIT_PRODUCT_SOURCE_FILES+=\
Expand Down
22 changes: 22 additions & 0 deletions runtime/compiler/control/HookedByTheJit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4625,6 +4625,7 @@ void memoryDisclaimLogic(TR::CompilationInfo *compInfo, uint64_t crtElapsedTime,
#endif
// Don't do anything during startup phase
J9JavaVM *javaVM = jitConfig->javaVM;

if (javaVM->phase != J9VM_PHASE_NOT_STARTUP || jitState == STARTUP_STATE)
return;

Expand Down Expand Up @@ -4669,6 +4670,23 @@ void memoryDisclaimLogic(TR::CompilationInfo *compInfo, uint64_t crtElapsedTime,
#endif // J9VM_INTERP_PROFILING_BYTECODES
}

void rssReportLogic(TR::CompilationInfo *compInfo)
{
static OMR::RSSReport *rssReport = OMR::RSSReport::instance();

if (rssReport)
{
static int printRSS = 0;

printRSS++;

if (printRSS == 2) // ~every second
{
rssReport->printRegions();
printRSS = 0;
}
}
}

static void samplingObservationsLogic(J9JITConfig * jitConfig, TR::CompilationInfo * compInfo)
{
Expand Down Expand Up @@ -4716,6 +4734,8 @@ static bool lateDisclaimNeeded = true;

#define GCR_HYSTERESIS 100



static void jitStateLogic(J9JITConfig * jitConfig, TR::CompilationInfo * compInfo, uint32_t diffTime)
{
// We enter STARTUP too often because IDLE is not operating correctly
Expand Down Expand Up @@ -5344,6 +5364,8 @@ static void jitStateLogic(J9JITConfig * jitConfig, TR::CompilationInfo * compInf
}
}

rssReportLogic(compInfo);

if (lateDisclaimNeeded)
{
CpuUtilization *cpuUtil = compInfo->getCpuUtil();
Expand Down
6 changes: 6 additions & 0 deletions runtime/compiler/control/rossa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,12 @@ onLoadInternal(
memset(aotStats, 0, sizeof(TR_AOTStats));
((TR_JitPrivateConfig*)jitConfig->privateConfig)->aotStats = aotStats;

bool produceRSSReportDetailed = TR::Options::getCmdLineOptions()->getVerboseOption(TR_VerboseRSSReportDetailed);
bool produceRSSReport = produceRSSReportDetailed || TR::Options::getCmdLineOptions()->getVerboseOption(TR_VerboseRSSReport);

if (produceRSSReport)
new (PERSISTENT_NEW) OMR::RSSReport(persistentMemory, produceRSSReportDetailed);

TR::CodeCacheManager *codeCacheManager = (TR::CodeCacheManager *) j9mem_allocate_memory(sizeof(TR::CodeCacheManager), J9MEM_CATEGORY_JIT);
if (codeCacheManager == NULL)
return -1;
Expand Down
16 changes: 15 additions & 1 deletion runtime/compiler/runtime/DataCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,19 @@ TR_DataCache* TR_DataCacheManager::allocateNewDataCache(uint32_t minimumSize)
dataCache->_status = 0;
dataCache->_vmThread = NULL;
dataCache->_allocationMark = dataCacheSeg->heapAlloc;

#ifdef LINUX
if (OMR::RSSReport::instance())
{
J9JavaVM * javaVM = jitConfig->javaVM;
PORT_ACCESS_FROM_JAVAVM(javaVM); // for j9vmem_supported_page_sizes

dataCache->_rssRegion = OMR::RSSRegion("data cache", dataCacheSeg->heapBase, segSize, OMR::RSSRegion::lowToHigh,
j9vmem_supported_page_sizes()[0]);
OMR::RSSReport::instance()->addRegion(&dataCache->_rssRegion);
}
#endif

_numAllocatedCaches++;
_totalSegmentMemoryAllocated += (uint32_t)allocatedSize;
#ifdef DATA_CACHE_DEBUG
Expand All @@ -301,6 +314,7 @@ TR_DataCache* TR_DataCacheManager::allocateNewDataCache(uint32_t minimumSize)
#endif
if (TR::Options::getCmdLineOptions()->getVerboseOption(TR_VerbosePerformance))
TR_VerboseLog::writeLineLocked(TR_Vlog_INFO, "Allocated new data cache segment starting at address %p", dataCacheSeg->heapBase);

#ifdef LINUX
if (_disclaimEnabled)
{
Expand Down Expand Up @@ -741,7 +755,7 @@ extern "C" {
#endif
}

//#define DEBUG_DISCLAIM
#define DEBUG_DISCLAIM // GITA
//----------------------------- disclaimSegment -----------------------------
// Disclaim memory for the given segment
// Return 1 if the memory segment was disclaimed, or 0 otherwise
Expand Down
2 changes: 2 additions & 0 deletions runtime/compiler/runtime/DataCache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <stdint.h>
#include "j9.h"
#include "infra/Assert.hpp"
#include "runtime/OMRRSSReport.hpp"

namespace TR { class Monitor; }
struct J9JITDataCacheHeader;
Expand All @@ -41,6 +42,7 @@ class TR_DataCache
uint8_t *_allocationMark; // used if we want to give back memory up to previously set mark
//TR::Monitor *_mutex; // Is this needed?
int32_t _status; // mostly RAS at this point
OMR::RSSRegion _rssRegion;
public:
enum {
RESERVED=1,
Expand Down
5 changes: 5 additions & 0 deletions runtime/compiler/runtime/J9CodeCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ J9::CodeCache::initialize(TR::CodeCacheManager *manager,

if (!self()->OMR::CodeCache::initialize(manager, codeCacheSegment, allocatedCodeCacheSizeInBytes))
return false;

J9JavaVM * javaVM = jitConfig->javaVM;
PORT_ACCESS_FROM_JAVAVM(javaVM); // for j9vmem_supported_page_sizes
_coldRSSRegion.setPageSize(j9vmem_supported_page_sizes()[0]);

self()->setInitialAllocationPointers();

_manager->reportCodeLoadEvents();
Expand Down

0 comments on commit 143b9f7

Please sign in to comment.