8181859: Monitor deflation is not checked in cleanup path

Reviewed-by: sspitsyn, dcubed, shade, cvarming
This commit is contained in:
Robbin Ehn 2017-06-15 09:52:44 +02:00
parent 2a0bd0cd04
commit 0d3624a309
4 changed files with 25 additions and 1 deletions

View file

@ -1184,6 +1184,12 @@ public:
\ \
product(bool, MonitorInUseLists, true, "Track Monitors for Deflation") \ product(bool, MonitorInUseLists, true, "Track Monitors for Deflation") \
\ \
experimental(intx, MonitorUsedDeflationThreshold, 90, \
"Percentage of used monitors before triggering cleanup " \
"safepoint which deflates monitors (0 is off). " \
"The check is performed on GuaranteedSafepointInterval.") \
range(0, 100) \
\
experimental(intx, SyncFlags, 0, "(Unsafe, Unstable) " \ experimental(intx, SyncFlags, 0, "(Unsafe, Unstable) " \
"Experimental Sync flags") \ "Experimental Sync flags") \
\ \

View file

@ -525,6 +525,8 @@ void SafepointSynchronize::end() {
} }
bool SafepointSynchronize::is_cleanup_needed() { bool SafepointSynchronize::is_cleanup_needed() {
// Need a safepoint if there are many monitors to deflate.
if (ObjectSynchronizer::is_cleanup_needed()) return true;
// Need a safepoint if some inline cache buffers is non-empty // Need a safepoint if some inline cache buffers is non-empty
if (!InlineCacheBuffer::is_empty()) return true; if (!InlineCacheBuffer::is_empty()) return true;
return false; return false;

View file

@ -962,6 +962,21 @@ static inline ObjectMonitor* next(ObjectMonitor* block) {
return block; return block;
} }
static bool monitors_used_above_threshold() {
if (gMonitorPopulation == 0) {
return false;
}
int monitors_used = gMonitorPopulation - gMonitorFreeCount;
int monitor_usage = (monitors_used * 100LL) / gMonitorPopulation;
return monitor_usage > MonitorUsedDeflationThreshold;
}
bool ObjectSynchronizer::is_cleanup_needed() {
if (MonitorUsedDeflationThreshold > 0) {
return monitors_used_above_threshold();
}
return false;
}
void ObjectSynchronizer::oops_do(OopClosure* f) { void ObjectSynchronizer::oops_do(OopClosure* f) {
if (MonitorInUseLists) { if (MonitorInUseLists) {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -135,6 +135,7 @@ class ObjectSynchronizer : AllStatic {
static bool deflate_monitor(ObjectMonitor* mid, oop obj, static bool deflate_monitor(ObjectMonitor* mid, oop obj,
ObjectMonitor** freeHeadp, ObjectMonitor** freeHeadp,
ObjectMonitor** freeTailp); ObjectMonitor** freeTailp);
static bool is_cleanup_needed();
static void oops_do(OopClosure* f); static void oops_do(OopClosure* f);
// Process oops in thread local used monitors // Process oops in thread local used monitors
static void thread_local_used_oops_do(Thread* thread, OopClosure* f); static void thread_local_used_oops_do(Thread* thread, OopClosure* f);