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
8259349: -XX:AvgMonitorsPerThreadEstimate=1 does not work right #1992
Conversation
👋 Welcome back dcubed! A progress list of the required criteria for merging this PR into |
@dcubed-ojdk The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Note: I'm testing out stacking patches in Git so the changes to src/hotspot/share/runtime/threadSMR.cpp This is the correct commit for this PR review: 0fe88c0 |
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.
LGTM!
@dcubed-ojdk 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 54 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 |
@coleenp - Thanks for the fast review! |
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.
Hi Dan,
The fix is fine in principle, but some comments below.
Thanks,
David
void ObjectSynchronizer::set_in_use_list_ceiling(size_t new_value) { | ||
// _in_use_list_ceiling is a jint so this cast could lose precision, | ||
// but in reality the ceiling should never get that high. | ||
_in_use_list_ceiling = (jint)new_value; | ||
} |
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'm sure I must have asked this before but why is AvgMonitorsPerThreadEstimate typed as intx
rather than int
? A jint is 32-bit and so is
inton all our 32-bit and 64-bit platforms; whereas
intx` is 64-bit on a 64-bit system.
And if we only ever set this field once why introduce a seemingly general use setter function instead of just doing the initialization directly in the initialize() method?
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.
@dholmes-ora - Thanks for the review.
The intx
type was copied from some other option when AvgMonitorsPerThreadEstimate
was introduced. I'd have to look to see why intx
is used instead of int
in options.
set_in_use_list_ceiling() is used in this fix and also in the follow on fix: JDK-8226416.
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.
$ grep -c 'product(int,' src/hotspot/share/runtime/globals.hpp
1
$ grep -c 'product(intx,' src/hotspot/share/runtime/globals.hpp
68
Looks like we have 1 int
option and 68 intx
options. I'll look at changing
AvgMonitorsPerThreadEstimate from intx
to int
.
…; fix bad assert tripped by the now working AvgMonitorsPerThreadEstimate option.
@coleenp or @dholmes-ora - a re-review would be appreciated. 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.
Hi Dan,
Thanks for the explanations. There is more cleanup now that the type of the flag has been changed (which is why I queried that - sorry for not being clear on intent).
Thanks,
David
@@ -717,7 +717,7 @@ const intx ObjectAlignmentInBytes = 8; | |||
\ | |||
/* notice: the max range value here is max_jint, not max_intx */ \ |
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.
The comment is no longer applicable.
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.
Deleted
// This is a 'jint' because the range of AvgMonitorsPerThreadEstimate | ||
// is 0..max_jint: |
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.
Do we need this comment now?
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.
Yes. The range for AvgMonitorsPerThreadEstimate is still 0..max_jint.
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.
what would happen if this option was set to max_jint? Is it a reasonable max?
} | ||
|
||
void ObjectSynchronizer::inc_in_use_list_ceiling() { | ||
Atomic::add(&_in_use_list_ceiling, (jint)AvgMonitorsPerThreadEstimate); | ||
} | ||
|
||
void ObjectSynchronizer::set_in_use_list_ceiling(size_t new_value) { |
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.
new_value should just be declared as int or jint now and the cast and comments 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.
I don't think so. For some reason @fisk used size_t for MonitorList
_count and _max fields so the ceiling that is passed in and returned
should be size_t. The only reason that the _in_use_list_ceiling is jint
is because the range is 0..max_jint. At one point I tried to change it
to size_t and ran into build issues, but I don't remember the details.
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 had a couple of questions.
// This is a 'jint' because the range of AvgMonitorsPerThreadEstimate | ||
// is 0..max_jint: |
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.
what would happen if this option was set to max_jint? Is it a reasonable max?
size_t l_in_use_list_ceiling = in_use_list_ceiling(); | ||
#endif | ||
assert(l_in_use_list_ceiling > 0, "in_use_list_ceiling=" SIZE_FORMAT | ||
": must be > 0", l_in_use_list_ceiling); |
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.
Did you find that this can go negative? I can see that it could go to zero at shutdown maybe.
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.
In a previous round I changed the assert to:
assert(l_in_use_list_ceiling >= 0, ...
and the Linux build complained about the assert always being true.
This is because size_t is unsigned. (No complaint on macOSX.)
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.
what would happen if this option was set to max_jint? Is it a reasonable max?
The _in_use_list_ceiling would be set to a very large number and we would
be allowing a very large number of monitors before a deflation cycle, i.e., we
would probably never async deflate.
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, Ok, on both points.
Mailing list message from David Holmes on hotspot-runtime-dev: On 9/01/2021 8:50 am, Daniel D.Daugherty wrote:
But the "This is jint" part is no longer relevant, the comment was This is a jint [rather than intx] because the range of AMPTE is but now AMPTE is an int we don't need to make that clarification on the
If you have a jint field being set by a setter function then the setter Cheers, |
I'm really tempted to back out the change that made AvgMonitorsPerThreadEstimate |
Mailing list message from David Holmes on hotspot-runtime-dev: On 9/01/2021 12:28 pm, Daniel D.Daugherty wrote:
Sorry about that. The cast and the comment about the cast is what jumped David |
…st_ceiling from jint to size_t.
In the "learn something new every day" category, I just learned that |
Mach5 Tier[1-3] testing looks good; no Tier[12] failures; 2 unrelated @coleenp and @dholmes-ora - a re-review would be appreciated. I believe this fix will also address:
I'm sorry that I forgot about that bug... |
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 like the new changes!
"Used to estimate a variable ceiling based on number of threads " \ | ||
"for use with MonitorUsedDeflationThreshold (0 is off).") \ | ||
range(0, max_jint) \ | ||
range(0, max_uintx) \ |
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 matches all the other size_t 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.
Yes it matches - but pity we don't have a max_size_t definition :(
size_t l_in_use_list_ceiling = in_use_list_ceiling(); | ||
#endif | ||
assert(l_in_use_list_ceiling > 0, "in_use_list_ceiling=" SIZE_FORMAT | ||
": must be > 0", l_in_use_list_ceiling); |
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, Ok, on both points.
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.
Hi Dan,
I'm happy with the consistent use of size_t - thanks. :)
A couple of minor comments remaining.
Thanks,
David
"Used to estimate a variable ceiling based on number of threads " \ | ||
"for use with MonitorUsedDeflationThreshold (0 is off).") \ | ||
range(0, max_jint) \ | ||
range(0, max_uintx) \ |
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.
Yes it matches - but pity we don't have a max_size_t definition :(
#endif | ||
assert(l_in_use_list_ceiling > 0, "in_use_list_ceiling=" SIZE_FORMAT | ||
": must be > 0", l_in_use_list_ceiling); | ||
Atomic::add(&_in_use_list_ceiling, -AvgMonitorsPerThreadEstimate); |
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.
Don't you need to cast AMPTE to a signed type to take the negative of it?
Why not just use Atomic::sub?
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.
Apparently no cast is needed since the current patch
passes Mach[1-3]. I don't remember the reason that
Atomic::add() of a negative value was used, but that's
not new in the patch so I'm planning to leave it alone.
@coleenp and @dholmes-ora - thanks for the re-reviews. |
/integrate |
@dcubed-ojdk Since your change was applied there have been 60 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit c338f11. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This is a trivial fix to make the "-XX:AvgMonitorsPerThreadEstimate"
option work correctly for values < 1024.
I've locally built and tested this fix on my MBP13. It will be included in my
next Mach5 Tier[1-3] testing batch.
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/1992/head:pull/1992
$ git checkout pull/1992