-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
8266936: Add a finalization JFR event #4101
Conversation
👋 Welcome back bchristi! A progress list of the required criteria for merging this PR into |
@bchristi-git The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
/label add hotspot |
@bchristi-git The |
Webrevs
|
This looks useful, but I am worried about the performance impact:
The default configuration must be safe to use even in pathological cases, i.e. an application with lots of objects being finalized. It's probably too much overhead (or number of events) for the profile configuration as well. There is also the added startup cost of JFR. One event may not matter that much, but they all add up. We need to put in place a mechanism that doesn't rely on bytecode instrumentation at runtime. There is an enhancement for that, but it requires some engineering first. |
I'm a bit worried by this too. Does it need to be enabled by default? Can we put a static final instance of FinalizerEvent in that class that can be used to test if the event is enabled so that it doesn't create a FinalizerEvent when disabled? Is it worth exploring doing have an event in the VM, in register_finalizer, instead? |
I wonder if there needs to be one event per finalized object? Perhaps a counter per class would be as useful, i.e. jdk.FinalizationStatistics, and if it could be implemented in the VM, without other implications, that would be great. Such an event could be enabled by default and provide much greater value than an event that users would need to know about and configure themselves, which 99,99% of all user will not do. |
/label remove security |
@AlanBateman |
So some statistics or periodic event that N instances of class C were registered or queued? I think you are right that this would be a lot more valuable. It might be possible to prototype this quickly with a ClassValue. |
My 0.02$ ;-) I really like the idea of a jdk.FinalizationStatistics event. The devil is (as always) in the details. Multiple concerns have been raised above, which benefit from being separated out:
|
I also concern with the performance overhead of one event per finalized object. The primary goal of this JFR event is to help identifying the use of finalizers in existing libraries/applications and prepare them to migrate away from using finalization. As well-known, the finalization mechanism is inherently problematic.
Therefore, a counter per class would be useful as it identifies the usage of finalizers while providing the number of objects per class pending for finalization (see Another option is to go with a simple approach - just report the aggregated number of BTW the number of finalizer invocation is not more useful than the number of
I agree an event enabled by default is more useful provided that the performance overhead is insignificant. I was also thinking if this event should be implemented in the VM in order to avoid some performance overhead such as object allocation. Erin, what is the benefit of implementing in in the VM? |
No startup cost, no allocation and there are callbacks when a class gets unloaded, so it's probably easier to clear any table where the statistics is held. |
Thanks for the confirmation. This is performance sensitive area and so it's worth considering doing it in the VM. In either case, performance measurement of the overhead will tell. |
@bchristi-git This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
@bchristi-git This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the |
Please review this enhancement to add a new JFR event, generated whenever a finalizer is run.
(The makeup is similar to the Deserialization event, JDK-8261160.)
The event's only datum (beyond those common to all jfr events) is the class of the object that was finalized.
The Category for the event:
"Java Virtual Machine" / "GC" / "Finalization"
is what made sense to me, even though the event is generated from library code.
Along with the new regtest, I added a run mode to the basic finalizer test to enable jfr.
Automated testing looks good so far.
Thanks,
-Brent
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/4101/head:pull/4101
$ git checkout pull/4101
Update a local copy of the PR:
$ git checkout pull/4101
$ git pull https://git.openjdk.java.net/jdk pull/4101/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 4101
View PR using the GUI difftool:
$ git pr show -t 4101
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/4101.diff