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
Changes from 7 commits
d4acfcf
0fe88c0
5b57bd9
42343e8
e68a5e5
f0af3c7
1fa734f
7737506
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
|
@@ -235,6 +235,8 @@ void ObjectSynchronizer::initialize() { | |
for (int i = 0; i < NINFLATIONLOCKS; i++) { | ||
gInflationLocks[i] = new os::PlatformMutex(); | ||
} | ||
// Start the ceiling with the estimate for one thread. | ||
set_in_use_list_ceiling(AvgMonitorsPerThreadEstimate); | ||
} | ||
|
||
static MonitorList _in_use_list; | ||
|
@@ -249,10 +251,11 @@ static MonitorList _in_use_list; | |
// of the thread count derived ceiling because we have used more | ||
// ObjectMonitors than the estimated average. | ||
// | ||
// Start the ceiling with the estimate for one thread. | ||
// Start the ceiling with the estimate for one thread in initialize() | ||
// which is called after cmd line options are processed. | ||
// This is a 'jint' because the range of AvgMonitorsPerThreadEstimate | ||
// is 0..max_jint: | ||
static jint _in_use_list_ceiling = AvgMonitorsPerThreadEstimate; | ||
static jint _in_use_list_ceiling = 0; | ||
bool volatile ObjectSynchronizer::_is_async_deflation_requested = false; | ||
bool volatile ObjectSynchronizer::_is_final_audit = false; | ||
jlong ObjectSynchronizer::_last_async_deflation_time_ns = 0; | ||
|
@@ -1166,17 +1169,18 @@ size_t ObjectSynchronizer::in_use_list_ceiling() { | |
|
||
void ObjectSynchronizer::dec_in_use_list_ceiling() { | ||
Atomic::add(&_in_use_list_ceiling, (jint)-AvgMonitorsPerThreadEstimate); | ||
#ifdef ASSERT | ||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. In a previous round I changed the assert to: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The _in_use_list_ceiling would be set to a very large number and we would There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, Ok, on both points. |
||
} | ||
|
||
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 commentThe 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 commentThe 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 |
||
// _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 commentThe 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 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 commentThe reason will be displayed to describe this comment to others. Learn more. @dholmes-ora - Thanks for the review. The 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 commentThe reason will be displayed to describe this comment to others. Learn more. $ grep -c 'product(int,' src/hotspot/share/runtime/globals.hpp $ grep -c 'product(intx,' src/hotspot/share/runtime/globals.hpp Looks like we have 1 |
||
|
||
bool ObjectSynchronizer::is_async_deflation_needed() { | ||
if (is_async_deflation_requested()) { | ||
// Async deflation request. | ||
|
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?