Add GC NotificationEmitter Support #9799
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for the emission of GC notifications from GC MXBeans. Previously, SubstratVM's GC MXBeans (
CompleteGarbageCollectorMXBean
andIncrementalGarbageCollectorMXBean
) implementedNotificationEmitter
, but actually did not support notifications.Details
A new feature
ServiceFeature
has been added. Use--enable-monitoring=gcnotif
to include the feature at build time and add support for GC notifications.The ImageSingleton
ServiceSupport
starts up a dedicated service thread which asynchronously handles creating and sending notifications. Notification "requests" are created during GC safepoints. They temporarily hold the information later needed to create and send GC notifications. During the GC safepoint, the thread executing the VM operation enqueues a request inGcNotifier
and signals the service thread that a request is ready. That process should be relatively quick and allocation free. Once the safepoint is over, the service thread uses the queued requests to create notifications that are sent by the appropriate GC MXBean.The new classes
GcNotifier
andServiceThread
are meant to serve almost the same purposes as theGCNotifier
andServiceThread
classes in Hotspot respectively.The various GC MXBeans now extend
AbstractGarbageCollectorMXBean
which contains the code for creating and sending notifications from request data. This class serves a similar purpose tocom.sun.management.internal.GarbageCollectorExtImpl
. Additionally, this class extendssun.management.NotificationEmitterSupport
from which the listener registration/deregistration logic is reused.Other notes
I'm not sure about the naming of
ServiceSupport
andServiceFeature
. MaybeNotificationSupport
makes more sense? I decided on the "service" prefix because, in Hotspot, the GC notification code is in the /hotspot/share/services directory. Also, maybe we will want to add other services in the future.Related Issues: #8237