-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8374780: G1: Do not iterate klass metadata when splitting objArrays for every slice #29116
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
base: master
Are you sure you want to change the base?
8374780: G1: Do not iterate klass metadata when splitting objArrays for every slice #29116
Conversation
|
👋 Welcome back tschatzl! A progress list of the required criteria for merging this PR into |
|
@tschatzl 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 22 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 |
stefank
left a comment
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 agree that we should do a change like this.
I've given some feedback that I think the code would be easier to read if you operated on array indices instead of MemRegion. We do that in other GCs.
Then I have given some length comments about the oop iterate functions. I find their names misleading and inconsistent. I would like to take a stab at slightly tweaking them, if you don't mind. That can be done in parallel with this change, and doesn't block the PR.
| inline void oop_oop_iterate_bounded(oop obj, OopClosureType* closure, MemRegion mr); | ||
|
|
||
| // Iterate over oop elements within [start, end), and metadata. | ||
| // Iterate over oop elements within [start, end) without metadata. |
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 know that you didn't change this, but this inconsistency in the API between oop_oop_iterate_bounded and oop_oop_iterate_range is unsettling. I think they both should be visiting the klass metadata if the obj falls within mr.
FWIW, the InstanceKlass implementation is also slightly different in that it checks if mr spans the start of obj:
ALWAYSINLINE void InstanceKlass::oop_oop_iterate_bounded(oop obj, OopClosureType* closure, MemRegion mr) {
if (Devirtualizer::do_metadata(closure)) {
if (mr.contains(obj)) {
Devirtualizer::do_klass(closure, this);
}
}
I wonder if we should (maybe later) do an experiment where we check that we don't pass down a metadata-visiting closure when we iterate over a range. Similar to:
ALWAYSINLINE void InstanceKlass::oop_oop_iterate_reverse(oop obj, OopClosureType* closure) {
assert(!Devirtualizer::do_metadata(closure),
"Code to handle metadata is not implemented");
And then remove the metadata visiting from oop_oop_iterate_bounded as well.
| int start = checked_cast<int>(pointer_delta(MAX2(mr.start(), obj->base()), obj->base(), heapOopSize)); | ||
| int end = checked_cast<int>(pointer_delta(mr.end(), obj->base(), heapOopSize)); | ||
| obj->oop_iterate_range(_cm_oop_closure, start, end); |
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 think this becomes a bit obscure when the lines perform multiple tasks, and having one line per operation makes it easier to make sure that the code is correct.
If we look at the operations we also see an inconsistency between start and end calculation:
For start it calculates the lower boundary and then it converts to an index.
For end it skips calculating a upper boundary and then it converts to an index.
You need to read the callers to figure out if skipping calculating the upper boundary for end is correct.
I would strongly suggest that this code is rewritten so that scan_objArray takes a start and end as array indices, instead of using a MemRegion. And that the same is done for process_array_slice. I think then some of these casts and pointer_deltas will go away and the code will be easier to read and reason about.
|
|
||
| public: | ||
| // special iterators for index ranges, returns size of object | ||
| // Special iterator for index ranges. |
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 goes together with the one above in the objArrayKlass file. While looking at the various oop_oop_iterate functions in ObjArrayKlass I think it would be better if this was called oop_iterate_elements. Given the inconsistency described above, we might also have to do something about the ObjArrayKlass::oop_oop_iterate_range name. Let me take a closer look at these names separately from your patch.
Hi all,
please review this change that makes concurrent mark not try to iterate over
objArraymetadata for every slice, to make behavior uniform with other garbage collection types/garbage collectors.Testing: tier1-5
Thanks,
Thomas
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/29116/head:pull/29116$ git checkout pull/29116Update a local copy of the PR:
$ git checkout pull/29116$ git pull https://git.openjdk.org/jdk.git pull/29116/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 29116View PR using the GUI difftool:
$ git pr show -t 29116Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/29116.diff
Using Webrev
Link to Webrev Comment