Skip to content

Commit

Permalink
Merge pull request #5261 from LinHu2016/issue4674_014
Browse files Browse the repository at this point in the history
Report max storage limits for JIT Data/Code Cache via JMX
  • Loading branch information
pshipton committed Mar 26, 2019
2 parents 8b2f552 + e557aaf commit 687d0d9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
20 changes: 15 additions & 5 deletions runtime/jcl/common/mgmtinit.c
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1998, 2017 IBM Corp. and others
* Copyright (c) 1998, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -35,6 +35,8 @@
/* required for memset */
#include <string.h>

#include "ut_j9jcl.h"

typedef enum {
CLASS_MEMORY=0,
MISC_MEMORY,
Expand Down Expand Up @@ -754,10 +756,10 @@ gcEndEvent(J9JavaVM *vm, UDATA heapSize, UDATA heapUsed, UDATA *totals, UDATA *f
gcInfo->initialSize[idx] = nonHeapMemory->initialSize;
gcInfo->preUsed[idx] = nonHeapMemory->preCollectionUsed;
gcInfo->preCommitted[idx] = nonHeapMemory->preCollectionSize;
gcInfo->preMax[idx] = -1;
gcInfo->preMax[idx] = nonHeapMemory->maxSize;
gcInfo->postUsed[idx] = nonHeapMemory->postCollectionUsed;
gcInfo->postCommitted[idx] = nonHeapMemory->postCollectionSize;
gcInfo->postMax[idx] = -1;
gcInfo->postMax[idx] = nonHeapMemory->maxSize;
}

/* garbage collection notification */
Expand Down Expand Up @@ -886,23 +888,29 @@ initMemoryManagement(J9JavaVM *vm)
mgmt->nonHeapMemoryPools[idx].id = J9VM_MANAGEMENT_POOL_NONHEAP_SEG_CLASSES;
strcpy(mgmt->nonHeapMemoryPools[idx].name, J9VM_MANAGEMENT_NONHEAPPOOL_NAME_CLASSES);
segList = vm->classMemorySegments;
mgmt->nonHeapMemoryPools[idx].maxSize = -1;
break;
case MISC_MEMORY:
mgmt->nonHeapMemoryPools[idx].id = J9VM_MANAGEMENT_POOL_NONHEAP_SEG_MISC;
strcpy(mgmt->nonHeapMemoryPools[idx].name, J9VM_MANAGEMENT_NONHEAPPOOL_NAME_MISC);
segList = vm->memorySegments;
mgmt->nonHeapMemoryPools[idx].maxSize = -1;
break;
case JIT_CODECACHE:
mgmt->nonHeapMemoryPools[idx].id = J9VM_MANAGEMENT_POOL_NONHEAP_SEG_JIT_CODE;
strcpy(mgmt->nonHeapMemoryPools[idx].name, J9VM_MANAGEMENT_NONHEAPPOOL_NAME_JITCODE);
segList = vm->jitConfig->codeCacheList;
mgmt->nonHeapMemoryPools[idx].maxSize = vm->jitConfig->codeCacheTotalKB * 1024;
break;
case JIT_DATACACHE:
default:
mgmt->nonHeapMemoryPools[idx].id = J9VM_MANAGEMENT_POOL_NONHEAP_SEG_JIT_DATA;
strcpy(mgmt->nonHeapMemoryPools[idx].name, J9VM_MANAGEMENT_NONHEAPPOOL_NAME_JITDATA);
segList = vm->jitConfig->dataCacheList;
mgmt->nonHeapMemoryPools[idx].maxSize = vm->jitConfig->dataCacheTotalKB * 1024;
break;
default:
/* Unreachable */
Assert_JCL_unreachable();
}
getSegmentSizes(vm, segList, &mgmt->nonHeapMemoryPools[idx].initialSize, &used, &mgmt->nonHeapMemoryPools[idx].peakSize, &mgmt->nonHeapMemoryPools[idx].peakUsed);
}
Expand Down Expand Up @@ -981,9 +989,11 @@ updateNonHeapMemoryPoolSizes(J9JavaVM *vm, J9JavaLangManagementData *mgmt, BOOLE
segList = vm->jitConfig->codeCacheList;
break;
case JIT_DATACACHE:
default:
segList = vm->jitConfig->dataCacheList;
break;
default:
/* Unreachable */
Assert_JCL_unreachable();
}
if (isGCEND) {
storedSize = &mgmt->nonHeapMemoryPools[idx].postCollectionSize;
Expand Down
16 changes: 8 additions & 8 deletions runtime/jcl/common/mgmtmempool.c
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1998, 2016 IBM Corp. and others
* Copyright (c) 1998, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand All @@ -25,7 +25,7 @@
#include "mgmtinit.h"
#include "j9modron.h"

static jobject processSegmentList(JNIEnv *env, jclass memoryUsage, jobject memUsageConstructor, J9MemorySegmentList *segList, U_64 initSize, U_64 *storedPeakSize, U_64 *storedPeakUsed, UDATA action);
static jobject processSegmentList(JNIEnv *env, jclass memoryUsage, jobject memUsageConstructor, J9MemorySegmentList *segList, U_64 initSize, I_64 maxSize, U_64 *storedPeakSize, U_64 *storedPeakUsed, UDATA action);
static UDATA getIndexFromPoolID(J9JavaLangManagementData *mgmt, UDATA id);
static J9MemorySegmentList *getMemorySegmentList(J9JavaVM *javaVM, jint id);

Expand Down Expand Up @@ -147,7 +147,7 @@ Java_com_ibm_java_lang_management_internal_MemoryPoolMXBeanImpl_getPeakUsageImpl
/* NonHeap MemoryPool */
J9MemorySegmentList *segList = getMemorySegmentList(javaVM, id);
if (NULL != segList) {
return processSegmentList(env, memoryUsage, memUsageConstructor, segList, mgmt->nonHeapMemoryPools[id-J9VM_MANAGEMENT_POOL_NONHEAP_SEG].initialSize, &mgmt->nonHeapMemoryPools[id-J9VM_MANAGEMENT_POOL_NONHEAP_SEG].peakSize, &mgmt->nonHeapMemoryPools[id-J9VM_MANAGEMENT_POOL_NONHEAP_SEG].peakUsed, 1);
return processSegmentList(env, memoryUsage, memUsageConstructor, segList, mgmt->nonHeapMemoryPools[id-J9VM_MANAGEMENT_POOL_NONHEAP_SEG].initialSize, mgmt->nonHeapMemoryPools[id-J9VM_MANAGEMENT_POOL_NONHEAP_SEG].maxSize, &mgmt->nonHeapMemoryPools[id-J9VM_MANAGEMENT_POOL_NONHEAP_SEG].peakSize, &mgmt->nonHeapMemoryPools[id-J9VM_MANAGEMENT_POOL_NONHEAP_SEG].peakUsed, 1);
} else {
return NULL;
}
Expand Down Expand Up @@ -204,7 +204,7 @@ Java_com_ibm_java_lang_management_internal_MemoryPoolMXBeanImpl_getUsageImpl(JNI
/* NonHeap MemoryPool */
J9MemorySegmentList *segList = getMemorySegmentList(javaVM, id);
if (NULL != segList) {
return processSegmentList(env, memoryUsage, memUsageConstructor, segList, mgmt->nonHeapMemoryPools[id-J9VM_MANAGEMENT_POOL_NONHEAP_SEG].initialSize, &mgmt->nonHeapMemoryPools[id-J9VM_MANAGEMENT_POOL_NONHEAP_SEG].peakSize, &mgmt->nonHeapMemoryPools[id-J9VM_MANAGEMENT_POOL_NONHEAP_SEG].peakUsed, 0);
return processSegmentList(env, memoryUsage, memUsageConstructor, segList, mgmt->nonHeapMemoryPools[id-J9VM_MANAGEMENT_POOL_NONHEAP_SEG].initialSize, mgmt->nonHeapMemoryPools[id-J9VM_MANAGEMENT_POOL_NONHEAP_SEG].maxSize, &mgmt->nonHeapMemoryPools[id-J9VM_MANAGEMENT_POOL_NONHEAP_SEG].peakSize, &mgmt->nonHeapMemoryPools[id-J9VM_MANAGEMENT_POOL_NONHEAP_SEG].peakUsed, 0);
} else {
return NULL;
}
Expand Down Expand Up @@ -358,7 +358,7 @@ Java_com_ibm_java_lang_management_internal_MemoryPoolMXBeanImpl_resetPeakUsageIm
/* NonHeap MemoryPool */
J9MemorySegmentList *segList = getMemorySegmentList(javaVM, id);
if (NULL != segList) {
processSegmentList(env, NULL, NULL, segList, 0, &mgmt->nonHeapMemoryPools[id-J9VM_MANAGEMENT_POOL_NONHEAP_SEG].peakSize, &mgmt->nonHeapMemoryPools[id-J9VM_MANAGEMENT_POOL_NONHEAP_SEG].peakUsed, 2);
processSegmentList(env, NULL, NULL, segList, 0, 0, &mgmt->nonHeapMemoryPools[id-J9VM_MANAGEMENT_POOL_NONHEAP_SEG].peakSize, &mgmt->nonHeapMemoryPools[id-J9VM_MANAGEMENT_POOL_NONHEAP_SEG].peakUsed, 2);
}
}
}
Expand Down Expand Up @@ -440,7 +440,7 @@ Java_com_ibm_java_lang_management_internal_MemoryPoolMXBeanImpl_getPreCollection
1 - check peak and update if necessary, return a MemoryUsage object for the peak usage
2 - reset the peak to the current usage, return nothing */
static jobject
processSegmentList(JNIEnv *env, jclass memoryUsage, jobject memUsageConstructor, J9MemorySegmentList *segList, U_64 initialSize, U_64 *storedPeakSize, U_64 *storedPeakUsed, UDATA action) {
processSegmentList(JNIEnv *env, jclass memoryUsage, jobject memUsageConstructor, J9MemorySegmentList *segList, U_64 initialSize, I_64 maxSize, U_64 *storedPeakSize, U_64 *storedPeakUsed, UDATA action) {
jlong used = 0;
jlong committed = 0;
jlong peakUsed = 0;
Expand Down Expand Up @@ -483,9 +483,9 @@ processSegmentList(JNIEnv *env, jclass memoryUsage, jobject memUsageConstructor,
}

if (0 == action) {
memoryUsageObj = (*env)->NewObject(env, memoryUsage, ctor, (jlong) initialSize, used, committed, (jlong)-1);
memoryUsageObj = (*env)->NewObject(env, memoryUsage, ctor, (jlong) initialSize, used, committed, (jlong) maxSize);
} else if (1 == action) {
memoryUsageObj = (*env)->NewObject(env, memoryUsage, ctor, (jlong) initialSize, peakUsed, peakSize, (jlong)-1);
memoryUsageObj = (*env)->NewObject(env, memoryUsage, ctor, (jlong) initialSize, peakUsed, peakSize, (jlong) maxSize);
}
}

Expand Down
1 change: 1 addition & 0 deletions runtime/oti/j9nonbuilder.h
Expand Up @@ -756,6 +756,7 @@ typedef struct J9NonHeapMemoryData {
U_64 postCollectionUsed;
U_64 peakSize;
U_64 peakUsed;
U_64 maxSize;
}J9NonHeapMemoryData;

typedef struct J9JavaLangManagementData {
Expand Down

0 comments on commit 687d0d9

Please sign in to comment.