diff -r 10c6e9066819 -r e7fdc9d9c376 src/hotspot/share/runtime/synchronizer.cpp --- a/src/hotspot/share/runtime/synchronizer.cpp Tue Nov 27 17:53:17 2018 -0500 +++ b/src/hotspot/share/runtime/synchronizer.cpp Tue Nov 27 18:35:16 2018 -0500 @@ -45,6 +45,7 @@ #include "runtime/stubRoutines.hpp" #include "runtime/synchronizer.hpp" #include "runtime/thread.inline.hpp" +#include "runtime/timer.hpp" #include "runtime/vframe.hpp" #include "runtime/vmThread.hpp" #include "utilities/align.hpp" @@ -1618,9 +1619,10 @@ } void ObjectSynchronizer::prepare_deflate_idle_monitors(DeflateMonitorCounters* counters) { - counters->nInuse = 0; // currently associated with objects - counters->nInCirculation = 0; // extant - counters->nScavenged = 0; // reclaimed + counters->nInuse = 0; // currently associated with objects + counters->nInCirculation = 0; // extant + counters->nScavenged = 0; // reclaimed + counters->perThreadTimes = 0.0; // per-thread scavenge times } void ObjectSynchronizer::deflate_idle_monitors(DeflateMonitorCounters* counters) { @@ -1660,6 +1662,14 @@ } void ObjectSynchronizer::finish_deflate_idle_monitors(DeflateMonitorCounters* counters) { + if (log_is_enabled(Info, safepoint, cleanup)) { + // Report the cumulative time for deflating each thread's idle + // monitors. Note: if the work is split among more than one + // worker thread, then the reported time will likely be more + // than a beginning to end measurement of the phase. + log_info(safepoint, cleanup)("deflating per-thread idle monitors, %3.7f secs", counters->perThreadTimes); + } + gMonitorFreeCount += counters->nScavenged; // Consider: audit gFreeList to ensure that gMonitorFreeCount and list agree. @@ -1680,9 +1690,16 @@ ObjectMonitor * freeHeadp = NULL; // Local SLL of scavenged monitors ObjectMonitor * freeTailp = NULL; + elapsedTimer timer; + + if (log_is_enabled(Info, safepoint, cleanup)) { + timer.start(); + } int deflated_count = deflate_monitor_list(thread->omInUseList_addr(), &freeHeadp, &freeTailp); + timer.stop(); + Thread::muxAcquire(&gListLock, "scavenge - return"); // Adjust counters @@ -1690,6 +1707,8 @@ thread->omInUseCount -= deflated_count; counters->nScavenged += deflated_count; counters->nInuse += thread->omInUseCount; + // For now, we only care about cumulative per-thread deflation time. + counters->perThreadTimes += timer.seconds(); // Move the scavenged monitors back to the global free list. if (freeHeadp != NULL) {