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
8296776: Stop using mtNone as marker for CHeap allocations in GrowableArray #11086
8296776: Stop using mtNone as marker for CHeap allocations in GrowableArray #11086
Conversation
👋 Welcome back stefank! A progress list of the required criteria for merging this PR into |
@stefank this pull request can not be integrated into git checkout 8296776_growablearray_mtnone_cleanout
git fetch https://git.openjdk.org/jdk master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push |
Webrevs
|
ba3508f
to
9e39835
Compare
/label remove serviceability |
@stefank |
All the serviceability files look okay to me. |
@stefank 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 4 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ 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.
It looks like no one is using mtNone for GrowableArray, but memReporter.cpp and virtualMemoryTracker still accept it. Shall we eliminate mtNone completely?
init_checks(); | ||
} | ||
|
||
GrowableArray(MEMFLAGS memflags, int initial_capacity = 2) : |
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 feel it's too dangerous to have two constructors with convertible parameters.
eg. GrowableArray(int initial_capacity) and GrowableArray(MEMFLAGS memflags, int initial_capacity = 2) are very close. what if someone has code like this:
short t = 2;
GrowableArray(2); // it's very vague to me which ctor will be selected.
I think it's a good idea to use 'explicit constructor' for one of them. in case implicit conversation takes place unconsciously.
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.
MEMFLAGS is defined as a class enum, so integers will not be automatically converted to MEMFLAGS. I'll add explicit to the constructors.
@stefank Please do not rebase or force-push to an active PR as it invalidates existing review comments. All changes will be squashed into a single commit automatically when integrating. See OpenJDK Developers’ Guide for more information. |
Eliminating mtNone completely is out of scope for this PR. |
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.
LGTM. I am not a reviewer.
Thanks for reviewing! |
The default initial capacity is 2, the explicit initial capacities are not 2 and in many case >>>2. So without an explicit capacity passed in these GrowableArrays would likely waste a lot of time unnecessarily growing. I don't think either of these parameters should really have a default value - in which case the order could have remained as it was. |
Sure, that's an alternative. Before committing to doing that, could you take a look at the similar change to CHeap allocated BitMaps #11084? I want the two classes to be similar in where we put the "allocation strategy". With both these changes I've pushed them to the beginning of the parameter list. With your suggestion I either have to make GrowableArray and CHeapBitMap inconsistent, or I need to change CHeapBitMap to also have the MEMFLAGS at the end, which would force all users to set the |
I'm going to go with @dholmes-ora suggestion here, and do a similar change to the CHeapBitMap PR. |
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 to me. I like this version better. Thanks for doing this.
Small nits remain, nothing big.
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.
Thanks for looking at this, Thomas.
I'm fixing most of your suggestions but left bits() alone, since I like it.
All good Stefan! I already approved. Cheers, Thomas |
Thanks for the reviews! |
/integrate |
Going to push as commit 5f51dff.
Your commit was automatically rebased without conflicts. |
Sorry @stefank this one slipped through the cracks. This simplified version looks better to me. Sorry for not responding to your query sooner. |
Today we use mtNone to denote that a GrowableArray should NOT be backed by a CHeap allocated array.
I've gotten feedback that it would probably be good to limit the usage of mtNone, and at some point maybe completely remove it.
This patch takes a small step to remove mtNone from the GrowableArray. What's left is only asserts to forbid that value. Those asserts will be trivial to remove when/if mtNone is removed.
Just like in the proposed patch to make MEMFLAGS non-optional in CHeapBitMap (see JDK-JDK-8296774), I have thrown around the parameter order for GrowableArray. When looking at the changes to the usages of CHeap-backed GrowableArrays it becomes apparent that all of these usages where forced to provide a value for the initial capacity. When MEMFLAGS move to the front, we can now skip having to figure an initial capacity.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/11086/head:pull/11086
$ git checkout pull/11086
Update a local copy of the PR:
$ git checkout pull/11086
$ git pull https://git.openjdk.org/jdk pull/11086/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 11086
View PR using the GUI difftool:
$ git pr show -t 11086
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/11086.diff