Skip to content

Commit

Permalink
8306825: Monitor deflation might be accidentally disabled by zero int…
Browse files Browse the repository at this point in the history
…ervals

Reviewed-by: dcubed, eastigeevich, phh
  • Loading branch information
shipilev committed May 1, 2023
1 parent 2d7c507 commit a6b4f25
Show file tree
Hide file tree
Showing 4 changed files with 388 additions and 236 deletions.
5 changes: 3 additions & 2 deletions src/hotspot/share/runtime/globals.hpp
Expand Up @@ -734,8 +734,9 @@ const int ObjectAlignmentInBytes = 8;
\
product(intx, MonitorUsedDeflationThreshold, 90, DIAGNOSTIC, \
"Percentage of used monitors before triggering deflation (0 is " \
"off). The check is performed on GuaranteedSafepointInterval " \
"or AsyncDeflationInterval.") \
"off). The check is performed on GuaranteedSafepointInterval, " \
"AsyncDeflationInterval or GuaranteedAsyncDeflationInterval, " \
"whichever is lower.") \
range(0, 100) \
\
product(uintx, NoAsyncDeflationProgressMax, 3, DIAGNOSTIC, \
Expand Down
33 changes: 30 additions & 3 deletions src/hotspot/share/runtime/monitorDeflationThread.cpp
Expand Up @@ -48,9 +48,36 @@ void MonitorDeflationThread::initialize() {

void MonitorDeflationThread::monitor_deflation_thread_entry(JavaThread* jt, TRAPS) {

// We wait for GuaranteedSafepointInterval so that is_async_deflation_needed() is checked
// at the same interval, unless GuaranteedAsyncDeflationInterval is lower.
const intx wait_time = MIN2(GuaranteedSafepointInterval, GuaranteedAsyncDeflationInterval);
// We wait for the lowest of these three intervals:
// - GuaranteedSafepointInterval
// While deflation is not related to safepoint anymore, this keeps compatibility with
// the old behavior when deflation also happened at safepoints. Users who set this
// option to get more/less frequent deflations would be served with this option.
// - AsyncDeflationInterval
// Normal threshold-based deflation heuristic checks the conditions at this interval.
// See is_async_deflation_needed().
// - GuaranteedAsyncDeflationInterval
// Backup deflation heuristic checks the conditions at this interval.
// See is_async_deflation_needed().
//
intx wait_time = max_intx;
if (GuaranteedSafepointInterval > 0) {
wait_time = MIN2(wait_time, GuaranteedSafepointInterval);
}
if (AsyncDeflationInterval > 0) {
wait_time = MIN2(wait_time, AsyncDeflationInterval);
}
if (GuaranteedAsyncDeflationInterval > 0) {
wait_time = MIN2(wait_time, GuaranteedAsyncDeflationInterval);
}

// If all options are disabled, then wait time is not defined, and the deflation
// is effectively disabled. In that case, exit the thread immediately after printing
// a warning message.
if (wait_time == max_intx) {
warning("Async deflation is disabled");
return;
}

while (true) {
{
Expand Down

1 comment on commit a6b4f25

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.