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

Add GC NotificationEmitter Support #9799

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

roberttoyonaga
Copy link
Collaborator

@roberttoyonaga roberttoyonaga commented Oct 1, 2024

Summary

This PR adds support for the emission of GC notifications from GC MXBeans. Previously, SubstratVM's GC MXBeans (CompleteGarbageCollectorMXBean and IncrementalGarbageCollectorMXBean) implemented NotificationEmitter, 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 in GcNotifier 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 and ServiceThread are meant to serve almost the same purposes as the GCNotifier and ServiceThread 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 to com.sun.management.internal.GarbageCollectorExtImpl. Additionally, this class extends sun.management.NotificationEmitterSupport from which the listener registration/deregistration logic is reused.

Other notes

I'm not sure about the naming of ServiceSupport and ServiceFeature. Maybe NotificationSupport 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

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
native-image OCA Verified All contributors have signed the Oracle Contributor Agreement. redhat-interest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant