8291418: adjust monitor deflation logging and deflate_idle_monitors use

Reviewed-by: dholmes, stuefe, pchilanomate
This commit is contained in:
Daniel D. Daugherty 2022-12-02 22:31:08 +00:00
parent 6e5470525d
commit 6065516bb3
2 changed files with 12 additions and 10 deletions

View File

@ -1497,6 +1497,8 @@ size_t ObjectSynchronizer::deflate_idle_monitors(ObjectMonitorsHashtable* table)
// Deflate some idle ObjectMonitors.
size_t deflated_count = deflate_monitor_list(current, ls, &timer, table);
size_t unlinked_count = 0;
size_t deleted_count = 0;
if (deflated_count > 0 || is_final_audit()) {
// There are ObjectMonitors that have been deflated or this is the
// final audit and all the remaining ObjectMonitors have been
@ -1506,8 +1508,7 @@ size_t ObjectSynchronizer::deflate_idle_monitors(ObjectMonitorsHashtable* table)
// Unlink deflated ObjectMonitors from the in-use list.
ResourceMark rm;
GrowableArray<ObjectMonitor*> delete_list((int)deflated_count);
size_t unlinked_count = _in_use_list.unlink_deflated(current, ls, &timer,
&delete_list);
unlinked_count = _in_use_list.unlink_deflated(current, ls, &timer, &delete_list);
if (current->is_Java_thread()) {
if (ls != NULL) {
timer.stop();
@ -1533,7 +1534,6 @@ size_t ObjectSynchronizer::deflate_idle_monitors(ObjectMonitorsHashtable* table)
// After the handshake, safely free the ObjectMonitors that were
// deflated in this cycle.
size_t deleted_count = 0;
for (ObjectMonitor* monitor: delete_list) {
delete monitor;
deleted_count++;
@ -1544,13 +1544,14 @@ size_t ObjectSynchronizer::deflate_idle_monitors(ObjectMonitorsHashtable* table)
deleted_count, ls, &timer);
}
}
assert(unlinked_count == deleted_count, "must be");
}
if (ls != NULL) {
timer.stop();
if (deflated_count != 0 || log_is_enabled(Debug, monitorinflation)) {
ls->print_cr("deflated " SIZE_FORMAT " monitors in %3.7f secs",
deflated_count, timer.seconds());
if (deflated_count != 0 || unlinked_count != 0 || log_is_enabled(Debug, monitorinflation)) {
ls->print_cr("deflated_count=" SIZE_FORMAT ", {unlinked,deleted}_count=" SIZE_FORMAT " monitors in %3.7f secs",
deflated_count, unlinked_count, timer.seconds());
}
ls->print_cr("end deflating: in_use_list stats: ceiling=" SIZE_FORMAT ", count=" SIZE_FORMAT ", max=" SIZE_FORMAT,
in_use_list_ceiling(), _in_use_list.count(), _in_use_list.max());
@ -1659,17 +1660,18 @@ void ObjectSynchronizer::do_final_audit_and_print_stats() {
return;
}
set_is_final_audit();
log_info(monitorinflation)("Starting the final audit.");
if (log_is_enabled(Info, monitorinflation)) {
// Do a deflation in order to reduce the in-use monitor population
// Do deflations in order to reduce the in-use monitor population
// that is reported by ObjectSynchronizer::log_in_use_monitor_details()
// which is called by ObjectSynchronizer::audit_and_print_stats().
while (ObjectSynchronizer::deflate_idle_monitors(/* ObjectMonitorsHashtable is not needed here */ nullptr) >= (size_t)MonitorDeflationMax) {
while (deflate_idle_monitors(/* ObjectMonitorsHashtable is not needed here */ nullptr) > 0) {
; // empty
}
// The other audit_and_print_stats() call is done at the Debug
// level at a safepoint in SafepointSynchronize::do_cleanup_tasks.
ObjectSynchronizer::audit_and_print_stats(true /* on_exit */);
audit_and_print_stats(true /* on_exit */);
}
}

View File

@ -287,7 +287,7 @@ void VM_ThreadDump::doit() {
// when there are a lot of inflated monitors. So we deflate idle monitors and
// gather information about owned monitors at the same time.
tablep = &table;
while (ObjectSynchronizer::deflate_idle_monitors(tablep) >= (size_t)MonitorDeflationMax) {
while (ObjectSynchronizer::deflate_idle_monitors(tablep) > 0) {
; /* empty */
}
}