-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8321288: [JVMCI] HotSpotJVMCIRuntime doesn't clean up WeakReferences in resolvedJavaTypes #16981
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
Conversation
…in resolvedJavaTypes
|
👋 Welcome back never! A progress list of the required criteria for merging this PR into |
|
@tkrodriguez 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. |
Webrevs
|
|
|
||
| @NativeImageReinitialize private HashMap<Long, WeakReference<ResolvedJavaType>> resolvedJavaTypes; | ||
|
|
||
| static class KlassWeakReference extends WeakReference<ResolvedJavaType> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add javadoc to this class explaining why it's needed/useful.
| /** | ||
| * Clean up WeakReferences whose referents have been cleared. | ||
| */ | ||
| private void expungeStaleEntries() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expungeStaleEntries -> expungeStaleKlassEntries (or expungeStaleKlasses)
| private void expungeStaleEntries() { | ||
| KlassWeakReference current = (KlassWeakReference) resolvedJavaTypesQueue.poll(); | ||
| while (current != null) { | ||
| // Make sure the entry is still mapped to the weak reference |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The atomicity of this test-and-update relies on fromMetaspace being synchronized right? Maybe worth pointing this out in the comment.
|
|
||
| static class KlassWeakReference extends WeakReference<ResolvedJavaType> { | ||
|
|
||
| private final Long klassPointer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is Long instead of long to avoid boxing in expungeStaleEntries?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's autoboxing in a more few places and I wanted to avoid having multiple copies of the box live so I promoted it to Long on entry to fromMetaspace.
|
I pushed some expanded comments and renames. I also adjusted some types that were weaker than the actual type which removed a bit of casting. Testing was clean. |
|
@tkrodriguez This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 49 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good as far as I can understand.
|
Thanks for the reviews. /integrate |
|
Going to push as commit 05f7f0a.
Your commit was automatically rebased without conflicts. |
|
@tkrodriguez Pushed as commit 05f7f0a. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
HotSpotJVMCIRuntime.resolvedJavaTypes implements a weak value map but is lacking code to clean out cleared weak references. In normal mixed execution this isn't likely to get big and generally isolates are shutdown frequently so this doesn't lead to problems. In Xcomp mode with tests that stress unloading this becomes more problematic. In the worst case is still doesn't lead to large heaps but does make the idle heap larger than required.
This PR adds ReferenceQueue based cleaning of reclaimed values. Testing in the context of a long running isolate shows that they are no longer accumulating.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/16981/head:pull/16981$ git checkout pull/16981Update a local copy of the PR:
$ git checkout pull/16981$ git pull https://git.openjdk.org/jdk.git pull/16981/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 16981View PR using the GUI difftool:
$ git pr show -t 16981Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/16981.diff
Webrev
Link to Webrev Comment