-
Notifications
You must be signed in to change notification settings - Fork 5.9k
8338929: Make Metaspace::deallocate space-aware #20701
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
👋 Welcome back stuefe! A progress list of the required criteria for merging this PR into |
@tstuefe 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 18 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 |
Webrevs
|
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
Thank you, Andrew! |
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.
Thank you for doing this and I agree in principle but now I'm confused about these spaces.
static bool contains(const void* ptr) { | ||
return is_in_shared_metaspace(ptr) || // in cds | ||
is_in_class_space(ptr) || // in class space | ||
is_in_nonclass_metaspace(ptr); // in one of the non-class regions? |
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.
So the shared_metaspace region, which is the memory for CDS is not in class_space? I suppose for deallocate this doesn't matter since this memory is never deallocated.
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.
By terminology, it is not in class space.
Class space I (we? don't we all?) call the section that is governed by the metaspace allocator. The CDS region containing Klass is not in class space. It is, however, in the narrow Klass decoding range:
- Klass decoding range: [CompressedKlassPointers::base() ... CompressedKlassPointers::base() + CompressedKlassPointers::range() )
- that range contains the CDS klass range, followed (after a possible gap) by the traditional class space. If CDS is off, its just the class space.
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 had been a nice ASCII art somewhere, but I cannot find it anymore; maybe someone removed it.
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.
This comment should then be "or the CDS archive", since the function is contains() and includes the non-class metaspace. That is, is_in_shared_metaspace() includes all of the CDS archive. I don't think the CompressedKlassPointers:::range limit is in the middle of the CDS archive memory area, unless CDS was changed without me noticing to separate class and non-class metadata (I hope not).
|
||
// Returns true if pointer points into one of the metaspace regions, or | ||
// into the class space. | ||
static bool is_in_shared_metaspace(const void* ptr); |
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.
This comment doesn't make sense to me. Isn't this just pointing to the CDS region, which includes class and non-class data? But is this in the range of class space?
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.
You are absolutely right, the comment is wrong. Sorry for the confusion. This is just the CDS portion.
static bool is_in_nonclass_metaspace(const void* ptr); | ||
|
||
// Returns true if ptr points into class space, false if it doesn't or if | ||
// there is no class space. |
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.
Add a comment that the class space is one contiguous allocated region, which is why this pointer compare is correct, unlike the non-class metaspace.
@coleenp I improved the comments. I think as a follow-up I will take a look at these functions and figure out which ones we really need, and maybe scrap the rest. |
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.
Nit comment change and question for my own clarification, but this looks fine.
static bool contains(const void* ptr) { | ||
return is_in_shared_metaspace(ptr) || // in cds | ||
is_in_class_space(ptr) || // in class space | ||
is_in_nonclass_metaspace(ptr); // in one of the non-class regions? |
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.
This comment should then be "or the CDS archive", since the function is contains() and includes the non-class metaspace. That is, is_in_shared_metaspace() includes all of the CDS archive. I don't think the CompressedKlassPointers:::range limit is in the middle of the CDS archive memory area, unless CDS was changed without me noticing to separate class and non-class metadata (I hope not).
// two address comparisons are enough. | ||
static inline bool is_in_class_space(const void* ptr) { | ||
return ptr < _class_space_end && ptr >= _class_space_start; | ||
} |
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.
So this does not include the Klasses in the CDS archive, it really is only useful for deallocation. I don't need this to be a comment update, just making sure I follow.
static bool contains(const void* ptr); | ||
static bool contains_non_shared(const void* ptr); | ||
// Returns true if the pointer points into class space, non-class metaspace, or the | ||
// Klass portion of the CDS archive. |
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.
This was the tiny comment nit. This doesn't return the "Klass portion of the" CDS archive so can you remove those words? Then it's good to go and I'll merge with it. Thanks!
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.
Oh, I see. How about "metadata portion" then?
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.
Oh, I see. How about "metadata portion" then?
Okay, will do.
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.
Could you re-approve?
Hi @coleenp
(GitHub, why can I not reply to comments inline? ) CDS also has heap parts, which are not in the Klass decoding range. That is why I named it the "Klass portion". I could also name it the "Metaspace" portion, but that is confusing, since its not in metaspace. "Metadata portion" maybe?
Yes, that is correct. |
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.
Thank you!
Going to push as commit daf2617.
Your commit was automatically rebased without conflicts. |
For ucoming Lilliput changes, as well as to simplify JDK-8338526, we should make Metaspace::deallocate space-aware (as in, instead of having to tell it where the pointed-to block resides, it should know it on its own).
As of now, callers need to tell the function of the deallocated block is in class space or in non-class metaspace. That is unnecessary and won't work for TinyCP. The deallocation function can do this better on itself by doing a range check on the class space range.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/20701/head:pull/20701
$ git checkout pull/20701
Update a local copy of the PR:
$ git checkout pull/20701
$ git pull https://git.openjdk.org/jdk.git pull/20701/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 20701
View PR using the GUI difftool:
$ git pr show -t 20701
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/20701.diff
Webrev
Link to Webrev Comment