Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue relate with CollectionUsageThreshold of memory pool #2993

Merged
merged 1 commit into from
Oct 16, 2018

Conversation

LinHu2016
Copy link
Contributor

@LinHu2016 LinHu2016 commented Sep 24, 2018

  • we should only check if the notification for
    CollectionUsageThreshold need to be fired at the end of the collection,
    which try to recycle the memory pool.
  • for BackCompatible mode scavenge does not try to reclaim memory from
    the whole heap, so we do not fire the notification of
    CollectionUsageThreshold at the end scavenge.
  • record the last GC ID for retrieving more detail gcInfo of last
    GC from J9GarbageCollectorData
  • MemoryPoolMXBean.getCollectionUsage() getPreCollectionUsage()

and isCollectionUsageThresholdExceeded() also match the same rule.
fix: #2982

Signed-off-by: Lin Hu linhu@ca.ibm.com

/* if a heap collection threshold is set, check whether we are above or below */
if (0 < memoryPool->collectionUsageThreshold) {
/* if a memory pool collection threshold is set and the memory pool is manaaged by the collector, check whether we are above or below */
if (0 < memoryPool->collectionUsageThreshold && j9gc_is_managedpool_by_collector(vm, (UDATA)(gcID & J9VM_MANAGEMENT_GC_HEAP_ID_MASK), (UDATA)(memoryPool->id & J9VM_MANAGEMENT_POOL_HEAP_ID_MASK))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you please add extra brackets around "0 < memoryPool->collectionUsageThreshold" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@dmitripivkine
Copy link
Contributor

There is a similar pattern in Java_com_ibm_java_lang_management_internal_MemoryPoolMXBeanImpl_isCollectionUsageThresholdExceededImpl(). Should it be updated as well?

@LinHu2016 LinHu2016 force-pushed the issue2982 branch 3 times, most recently from 3d97c85 to 4fdc078 Compare September 24, 2018 16:43
@@ -632,8 +632,8 @@ gcEndEvent(J9JavaVM *vm, UDATA heapSize, UDATA heapUsed, UDATA *totals, UDATA *f
memoryPool->peakMax = memoryPool->postCollectionMaxSize;
}

/* if a heap collection threshold is set, check whether we are above or below */
if (0 < memoryPool->collectionUsageThreshold) {
/* if a memory pool collection threshold is set and the memory pool is manaaged by the collector, check whether we are above or below */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo manaaged -> managed

@LinHu2016 LinHu2016 force-pushed the issue2982 branch 9 times, most recently from f6d37d8 to ddf4792 Compare September 27, 2018 14:21
@LinHu2016
Copy link
Contributor Author

update for MemoryPoolMXBean.getCollectionUsage() getPreCollectionUsage() and isCollectionUsageThresholdExceeded() as well

@@ -546,7 +552,8 @@ gcStartEvent(J9JavaVM *vm, UDATA heapSize, UDATA heapUsed, UDATA *totals, UDATA
notification->usageThreshold->poolID = memoryPool->id;
notification->usageThreshold->usedSize = used;
notification->usageThreshold->totalSize = total;
notification->usageThreshold->maxSize = memoryPool->preCollectionMaxSize;
// notification->usageThreshold->maxSize = memoryPool->preCollectionMaxSize;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this line should be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

{
UDATA idx = 0;

for(; idx < mgmt->supportedCollectors; ++idx) {
Copy link
Contributor

@dmitripivkine dmitripivkine Sep 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need space between "for" and bracket. Also I would provide initial value explicitly:
for (idx=0; idx < mgmt->supportedCollectors; ++idx) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

@dmitripivkine dmitripivkine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@DanHeidinga
Copy link
Member

@dmitripivkine @LinHu2016 Is this required for the 0.11.0 release? How risky is the change?

@dmitripivkine
Copy link
Contributor

@dmitripivkine @LinHu2016 Is this required for the 0.11.0 release? How risky is the change?

I believe the risk is medium but limited to MemoryPoolMXBean functionality. @LinHu2016 is there urgency for this?

Copy link
Member

@DanHeidinga DanHeidinga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one minor nitpick which isn't strictly required and the code looks ok to me

if (J9_GC_MANAGEMENT_COLLECTOR_SCAVENGE == gcID) {
/* for BackCompatible mode scavenge does not try to reclaim memory from the whole heap, so we do not mark JavaHeap managed by scavenge */
return 0;
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The else block is unnecessary as the if block returns. Can be written as:

		if (J9_GC_MANAGEMENT_COLLECTOR_SCAVENGE == gcID) {
			/* for BackCompatible mode scavenge does not try to reclaim memory from the whole heap, so we do not mark JavaHeap managed by scavenge */
			return 0;
		}
		return 1;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@LinHu2016
Copy link
Contributor Author

@DanHeidinga @dmitripivkine As Dmitri said without the fix, it would be limited to MemoryPoolMXBean CollectionUsage related functionality, but it is not urgency.

@DanHeidinga
Copy link
Member

Jenkins test sanity,functional zlinux,win jdk8

@DanHeidinga
Copy link
Member

Jenkins test sanity,functional zlinux jdk8

@DanHeidinga
Copy link
Member

Jenkins test sanity zlinux jdk8

@DanHeidinga
Copy link
Member

Jenkins test extended zlinux jdk8

@DanHeidinga
Copy link
Member

Jenkins test sanity win jdk10

@DanHeidinga DanHeidinga self-assigned this Oct 12, 2018
@DanHeidinga
Copy link
Member

Windows compile failure:

12:05:28 ../common/mgmtinit.c(623) : error C2220: warning treated as error - no 'object' file generated
12:05:28 ../common/mgmtinit.c(623) : warning C4244: '=' : conversion from 'UDATA' to 'U_32', possible loss of data
12:05:28 mgmtos.c

@DanHeidinga
Copy link
Member

@LinHu2016 are you looking at the compile failure?

  - we should only check if the notification for
CollectionUsageThreshold need to be fired at the end of the collection,
which try to recycle the memory pool.
  - for BackCompatible mode scavenge does not try to reclaim memory from
the whole heap, so we do not fire the notification of
CollectionUsageThreshold at the end scavenge.
  - record the last GC ID for retrieving more detail gcInfo of last
  GC from J9GarbageCollectorData
  - MemoryPoolMXBean.getCollectionUsage() getPreCollectionUsage()
  and isCollectionUsageThresholdExceeded() also match the same rule.
  
Signed-off-by: Lin Hu <linhu@ca.ibm.com>
@LinHu2016
Copy link
Contributor Author

fixed the compiling error.

@DanHeidinga
Copy link
Member

Jenkins test all zlinux jdk8

@DanHeidinga
Copy link
Member

Jenkins test sanity win jdk10

@pshipton
Copy link
Member

pshipton commented Oct 16, 2018

Reverted until the problems can be fixed, since the change is causing test failures

j> 14:09:22 Exception in thread "MemoryMXBean notification dispatcher" java.lang.IllegalArgumentException: committed value cannot be larger than the max value
j> 14:09:22 	at java.lang.management.MemoryUsage.<init>(MemoryUsage.java:118)
j> 14:09:22 	at com.ibm.lang.management.internal.ExtendedGarbageCollectorMXBeanImpl.buildGcInfo(ExtendedGarbageCollectorMXBeanImpl.java:94)
j> 14:09:22 	at com.ibm.lang.management.internal.MemoryNotificationThread.dispatchGCNotificationHelper(MemoryNotificationThread.java:95)
j> 14:09:22 	at com.ibm.lang.management.internal.MemoryNotificationThread.processNotificationLoop(Native Method)
j> 14:09:22 	at com.ibm.lang.management.internal.MemoryNotificationThread.run(MemoryNotificationThread.java:183)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

issue about notification for exceeding CollectionUsageThresold of tenure MemoryPool
4 participants