-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8340103: Add internal set_flag function to VMATree #20994
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 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 454 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 |
@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 |
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 the work. This enables the MemTracker::record_virtual_memory_tag
to just use this API and apply the results.
Just a few cases of 'flag' is missed in comments or in assertion strings. There should be 'tag'.
Can we use add(SummaryDiff& other)
instead of apply(SummaryDiff& other)
?
Done. |
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.
src/hotspot/share/nmt/vmatree.cpp
Outdated
out->print(SIZE_FORMAT " (%s) - %s - ", current->key(), NMTUtil::tag_to_name(current->val().out.mem_tag()), | ||
statetype_to_string(current->val().out.type())); |
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 we consider here adding a utility function:
IntervalState getState(TreapNode* node) {
return node->val().out;
}
to simplify from:
out->print(SIZE_FORMAT " (%s) - %s - ", current->key(), NMTUtil::tag_to_name(current->val().out.mem_tag()),
statetype_to_string(current->val().out.type()));
to
out->print(SIZE_FORMAT " (%s) - %s - ", current->key(), NMTUtil::tag_to_name(getState(current).mem_tag()),
statetype_to_string(getState(current).type()));
and all the other from:
stB.out = leqA_n->val().out;
to:
stB.out = getState(leqA_n);
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.
Sure, but I had to pick in_state
and out_state
as there are two states we're interested in.
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 to me. Thanks
Since the VMATree will remove the released range when it recognises that it is a no-op
@jdksjolen not so hasty :) The test was fine. You said that set_tag just ignores Released sections in range. So, what should have happened is that in the test, the remaining reserved section should have remained and changed to mtGC. The tree then should consist of In other words, the test would test that calling set_tag across a range that contains Released sections does not change said sections. |
I actually am stuck thinking about this, and it's worse than that :-). Consider a simpler test: {
VMATree tree;
Tree::RegionData class_shared(si, mtClassShared);
tree.reserve_mapping(10, 10, class_shared);
tree.set_tag(0, 100, mtCompiler);
} This will crash on an assert. After the So, when we run |
I wonder: The answer could be to start the tree out with a single range, State=Released, mtNone, nostack, from [0 .. max). In other words, have two nodes that border the very start and end of the The only problematic part is that one must encode the logic that there cannot be a node preceding the first node - so it has no input state (or it can have one, but should be ignored). What do you think? Elegant or too overengineered? |
You could alter the |
Hey @jdksjolen, hier is a thougt. Maybe for this RFE, maybe for future rework: We now add a function set_tag to modify the tag across a range of regions. That requires us to preserve the rest of the properties. So, you essentially go through the sections, read old property set, modify this one property, then exchange the old property set for this section with the new property set. The tree does the rest automagically (coalescing, splitting etc). But it occurred to me, that we may need this functionality for other properties, too. For example, State: We may want to implement "uncommit" as "uncommit across possibly multiple sections that may or may not have been committed, but preserve tags and stacks". So, we have a general need for "change properties across a range of positions" but where we don't just wipe out the old properties but modify them. So we need to know the old set. How about we implement this directly in the treap in a more general purpose way. For example:
with Transformer being a functor that gets the old property set (and possibly the positions of the old range, though that may not even be needed) and returns a new set of properties. The VMATree transformer for VMATree::set_tag would just return the input properties, but with Tag replaced by the new tag. A VMATree transformer for a possible "commit" function would return the input properties, but with State=Comitted. So, we could commit over a range of existing sections with different tags or stacks, and that would preserve the stacks and tags. And so forth. What do you think? |
I think that this is probably a generalization of the algorithm in |
Hi, I've updated the PR with further tests and a more complete implementation of |
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. Sorry for the delay. I am swamped atm.
Thank you! |
Going to push as commit 1e086b1.
Your commit was automatically rebased without conflicts. |
@jdksjolen Pushed as commit 1e086b1. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Hi!
The old VirtualMemoryTracker has a method set_reserved_region_type(address, flag). We implement this for the new VMATree implementation by altering the signature slightly to set_reserved_region_type(address, size, flag). This simplifies the implementation greatly for our new data structure and leads to trivial changes for the callers (all callers already know the size).
This PR implements the internal implementation along with tests, but does not change any callers.
I also do a few cleanups:
Node
toTreeNode
in tests, we've seen build failures because of this (probably a precompiled headers issue)print_on
methods for easy debuggingsize
alias, it was a bit confusing that some functions took an argumentposition sz
, so changed that tosize sz
Thanks.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/20994/head:pull/20994
$ git checkout pull/20994
Update a local copy of the PR:
$ git checkout pull/20994
$ git pull https://git.openjdk.org/jdk.git pull/20994/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 20994
View PR using the GUI difftool:
$ git pr show -t 20994
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/20994.diff
Using Webrev
Link to Webrev Comment