-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8320370: NMT: Change MallocMemorySnapshot to simplify code. #16724
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 jsjolen! A progress list of the required criteria for merging this PR into |
@jdksjolen To determine the appropriate audience for reviewing this pull request, one or more labels corresponding to different subsystems will normally be applied automatically. However, no automatic labelling rule matches the changes in this pull request. In order to have an "RFR" email sent to the correct mailing list, you will need to add one or more applicable labels manually using the /label pull request command. Applicable Labels
|
/label hotspot-runtime |
@jdksjolen |
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, smaller nits.
@@ -43,7 +43,7 @@ | |||
#include "utilities/ostream.hpp" | |||
#include "utilities/vmError.hpp" | |||
|
|||
size_t MallocMemorySummary::_snapshot[CALC_OBJ_SIZE_IN_TYPE(MallocMemorySnapshot, size_t)]; | |||
MallocMemorySnapshot MallocMemorySummary::_snapshot{}; |
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.
Why the curly braces?
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.
They're not necessary, I just have a tendency to explicitly use brace/"uniform" initialization everywhere. I've removed them.
@@ -49,9 +49,6 @@ void VirtualMemory::update_peak(size_t size) { | |||
#endif // ASSERT | |||
|
|||
void VirtualMemorySummary::initialize() { | |||
assert(sizeof(_snapshot) >= sizeof(VirtualMemorySnapshot), "Sanity Check"); | |||
// Use placement operator new to initialize static data area. | |||
::new ((void*)_snapshot) VirtualMemorySnapshot(); | |||
} |
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 be removed.
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, thanks! Should've seen that :-).
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.
Good
@jdksjolen 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 375 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 |
I believe the reason for the original shape of this code was to avoid initialization altogether if NMT was disabled. @zhengyu123 ? |
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.
Nice clean up!
Just one question: I'm probably missing something here, but did we have to change from ResourceObj
to AnyObj
for this change to work?
Hi Gerard, no I think it is unnecessary to do this change to make it work (I haven't checked). I do think keeping it as |
Why not make it a simple object then? Why derive from anything at all? (Update: I am fine with the current state of the patch; up to you) |
It's not clear to me what the rules are on this matter. To what degree are plain global classes allowed in HotSpot? I thought that they all need to inherit from |
I would hope so. Why increase compiler load and force inclusion of unrelated headers for stuff that is really not necessary. |
I believe it was coded this way to avoid memory allocation (malloc) during NMT initialization, before tracking infrastructure is ready, e.g. IIRC, not using static variable was to workaround the order of static variable initialization by linker, cannot remember the details. |
+1 Please don't use AnyObj unless you really need multiple allocation strategies. |
That makes a lot of sense. Its a moot point now since https://bugs.openjdk.org/browse/JDK-8256844 |
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.
Still looks good. Nice simplificaiton.
Thanks for the re-approval!
I'm very happy to hear this :). @gerard-ziemski, would you mind re-approving also? |
We currently have:
which used to be:
Are we OK with using |
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.
With this change it now seems unnecessary to keep the as_snapshot() functions. Right?
I'm fine with it either way, but would prefer the object not to inherit from anything if its only used inline or as stack object. In any case, lets ship this. |
Hi, Keeping the |
/integrate |
Going to push as commit a7f6016.
Your commit was automatically rebased without conflicts. |
@jdksjolen Pushed as commit a7f6016. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Hi,
MallocMemorySnapshot
used to be initialized in a quite non-standard way, using global placement new on an array ofsize_t
of the size required to fitMallocMemorySnapshot
. This looks like it was intended to circumvent someResourceObj
internals, but I'm unsure of its purpose. This change does what you expect a regular initialization of a global variable to look like.Currently running through tier1.GHA passed and so did tier1 on Oracle CI.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/16724/head:pull/16724
$ git checkout pull/16724
Update a local copy of the PR:
$ git checkout pull/16724
$ git pull https://git.openjdk.org/jdk.git pull/16724/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 16724
View PR using the GUI difftool:
$ git pr show -t 16724
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/16724.diff
Webrev
Link to Webrev Comment