Skip to content

Commit 6065516

Browse files
author
Daniel D. Daugherty
committed
8291418: adjust monitor deflation logging and deflate_idle_monitors use
Reviewed-by: dholmes, stuefe, pchilanomate
1 parent 6e54705 commit 6065516

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/hotspot/share/runtime/synchronizer.cpp

+11-9
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,8 @@ size_t ObjectSynchronizer::deflate_idle_monitors(ObjectMonitorsHashtable* table)
14971497

14981498
// Deflate some idle ObjectMonitors.
14991499
size_t deflated_count = deflate_monitor_list(current, ls, &timer, table);
1500+
size_t unlinked_count = 0;
1501+
size_t deleted_count = 0;
15001502
if (deflated_count > 0 || is_final_audit()) {
15011503
// There are ObjectMonitors that have been deflated or this is the
15021504
// final audit and all the remaining ObjectMonitors have been
@@ -1506,8 +1508,7 @@ size_t ObjectSynchronizer::deflate_idle_monitors(ObjectMonitorsHashtable* table)
15061508
// Unlink deflated ObjectMonitors from the in-use list.
15071509
ResourceMark rm;
15081510
GrowableArray<ObjectMonitor*> delete_list((int)deflated_count);
1509-
size_t unlinked_count = _in_use_list.unlink_deflated(current, ls, &timer,
1510-
&delete_list);
1511+
unlinked_count = _in_use_list.unlink_deflated(current, ls, &timer, &delete_list);
15111512
if (current->is_Java_thread()) {
15121513
if (ls != NULL) {
15131514
timer.stop();
@@ -1533,7 +1534,6 @@ size_t ObjectSynchronizer::deflate_idle_monitors(ObjectMonitorsHashtable* table)
15331534

15341535
// After the handshake, safely free the ObjectMonitors that were
15351536
// deflated in this cycle.
1536-
size_t deleted_count = 0;
15371537
for (ObjectMonitor* monitor: delete_list) {
15381538
delete monitor;
15391539
deleted_count++;
@@ -1544,13 +1544,14 @@ size_t ObjectSynchronizer::deflate_idle_monitors(ObjectMonitorsHashtable* table)
15441544
deleted_count, ls, &timer);
15451545
}
15461546
}
1547+
assert(unlinked_count == deleted_count, "must be");
15471548
}
15481549

15491550
if (ls != NULL) {
15501551
timer.stop();
1551-
if (deflated_count != 0 || log_is_enabled(Debug, monitorinflation)) {
1552-
ls->print_cr("deflated " SIZE_FORMAT " monitors in %3.7f secs",
1553-
deflated_count, timer.seconds());
1552+
if (deflated_count != 0 || unlinked_count != 0 || log_is_enabled(Debug, monitorinflation)) {
1553+
ls->print_cr("deflated_count=" SIZE_FORMAT ", {unlinked,deleted}_count=" SIZE_FORMAT " monitors in %3.7f secs",
1554+
deflated_count, unlinked_count, timer.seconds());
15541555
}
15551556
ls->print_cr("end deflating: in_use_list stats: ceiling=" SIZE_FORMAT ", count=" SIZE_FORMAT ", max=" SIZE_FORMAT,
15561557
in_use_list_ceiling(), _in_use_list.count(), _in_use_list.max());
@@ -1659,17 +1660,18 @@ void ObjectSynchronizer::do_final_audit_and_print_stats() {
16591660
return;
16601661
}
16611662
set_is_final_audit();
1663+
log_info(monitorinflation)("Starting the final audit.");
16621664

16631665
if (log_is_enabled(Info, monitorinflation)) {
1664-
// Do a deflation in order to reduce the in-use monitor population
1666+
// Do deflations in order to reduce the in-use monitor population
16651667
// that is reported by ObjectSynchronizer::log_in_use_monitor_details()
16661668
// which is called by ObjectSynchronizer::audit_and_print_stats().
1667-
while (ObjectSynchronizer::deflate_idle_monitors(/* ObjectMonitorsHashtable is not needed here */ nullptr) >= (size_t)MonitorDeflationMax) {
1669+
while (deflate_idle_monitors(/* ObjectMonitorsHashtable is not needed here */ nullptr) > 0) {
16681670
; // empty
16691671
}
16701672
// The other audit_and_print_stats() call is done at the Debug
16711673
// level at a safepoint in SafepointSynchronize::do_cleanup_tasks.
1672-
ObjectSynchronizer::audit_and_print_stats(true /* on_exit */);
1674+
audit_and_print_stats(true /* on_exit */);
16731675
}
16741676
}
16751677

src/hotspot/share/runtime/vmOperations.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ void VM_ThreadDump::doit() {
287287
// when there are a lot of inflated monitors. So we deflate idle monitors and
288288
// gather information about owned monitors at the same time.
289289
tablep = &table;
290-
while (ObjectSynchronizer::deflate_idle_monitors(tablep) >= (size_t)MonitorDeflationMax) {
290+
while (ObjectSynchronizer::deflate_idle_monitors(tablep) > 0) {
291291
; /* empty */
292292
}
293293
}

0 commit comments

Comments
 (0)