8325872: Make GuaranteedSafepointInterval default 0

Reviewed-by: shade, eosterlund, dcubed
This commit is contained in:
Coleen Phillimore 2024-04-18 11:21:39 +00:00
parent b0496096dc
commit 60b65e6090
5 changed files with 25 additions and 44 deletions

View File

@ -3646,6 +3646,11 @@ jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) {
apply_debugger_ergo(); apply_debugger_ergo();
// The VMThread needs to stop now and then to execute these debug options.
if ((HandshakeALot || SafepointALot) && FLAG_IS_DEFAULT(GuaranteedSafepointInterval)) {
FLAG_SET_DEFAULT(GuaranteedSafepointInterval, 1000);
}
if (log_is_enabled(Info, arguments)) { if (log_is_enabled(Info, arguments)) {
LogStream st(Log(arguments)::info()); LogStream st(Log(arguments)::info());
Arguments::print_on(&st); Arguments::print_on(&st);

View File

@ -744,9 +744,8 @@ const int ObjectAlignmentInBytes = 8;
\ \
product(int, MonitorUsedDeflationThreshold, 90, DIAGNOSTIC, \ product(int, MonitorUsedDeflationThreshold, 90, DIAGNOSTIC, \
"Percentage of used monitors before triggering deflation (0 is " \ "Percentage of used monitors before triggering deflation (0 is " \
"off). The check is performed on GuaranteedSafepointInterval, " \ "off). The check is performed on AsyncDeflationInterval or " \
"AsyncDeflationInterval or GuaranteedAsyncDeflationInterval, " \ "GuaranteedAsyncDeflationInterval, whichever is lower.") \
"whichever is lower.") \
range(0, 100) \ range(0, 100) \
\ \
product(uintx, NoAsyncDeflationProgressMax, 3, DIAGNOSTIC, \ product(uintx, NoAsyncDeflationProgressMax, 3, DIAGNOSTIC, \
@ -1277,7 +1276,7 @@ const int ObjectAlignmentInBytes = 8;
\ \
/* notice: the max range value here is max_jint, not max_intx */ \ /* notice: the max range value here is max_jint, not max_intx */ \
/* because of overflow issue */ \ /* because of overflow issue */ \
product(intx, GuaranteedSafepointInterval, 1000, DIAGNOSTIC, \ product(intx, GuaranteedSafepointInterval, 0, DIAGNOSTIC, \
"Guarantee a safepoint (at least) every so many milliseconds " \ "Guarantee a safepoint (at least) every so many milliseconds " \
"(0 means none)") \ "(0 means none)") \
range(0, max_jint) \ range(0, max_jint) \

View File

@ -50,11 +50,7 @@ void MonitorDeflationThread::initialize() {
void MonitorDeflationThread::monitor_deflation_thread_entry(JavaThread* jt, TRAPS) { void MonitorDeflationThread::monitor_deflation_thread_entry(JavaThread* jt, TRAPS) {
// We wait for the lowest of these three intervals: // We wait for the lowest of these two 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 // - AsyncDeflationInterval
// Normal threshold-based deflation heuristic checks the conditions at this interval. // Normal threshold-based deflation heuristic checks the conditions at this interval.
// See is_async_deflation_needed(). // See is_async_deflation_needed().
@ -63,9 +59,6 @@ void MonitorDeflationThread::monitor_deflation_thread_entry(JavaThread* jt, TRAP
// See is_async_deflation_needed(). // See is_async_deflation_needed().
// //
intx wait_time = max_intx; intx wait_time = max_intx;
if (GuaranteedSafepointInterval > 0) {
wait_time = MIN2(wait_time, GuaranteedSafepointInterval);
}
if (AsyncDeflationInterval > 0) { if (AsyncDeflationInterval > 0) {
wait_time = MIN2(wait_time, AsyncDeflationInterval); wait_time = MIN2(wait_time, AsyncDeflationInterval);
} }

View File

@ -308,40 +308,26 @@ class HandshakeALotClosure : public HandshakeClosure {
} }
}; };
bool VMThread::handshake_alot() { bool VMThread::handshake_or_safepoint_alot() {
assert(_cur_vm_operation == nullptr, "should not have an op yet"); assert(_cur_vm_operation == nullptr, "should not have an op yet");
assert(_next_vm_operation == nullptr, "should not have an op yet"); assert(_next_vm_operation == nullptr, "should not have an op yet");
if (!HandshakeALot) { if (!HandshakeALot && !SafepointALot) {
return false; return false;
} }
static jlong last_halot_ms = 0; static jlong last_alot_ms = 0;
jlong now_ms = nanos_to_millis(os::javaTimeNanos()); jlong now_ms = nanos_to_millis(os::javaTimeNanos());
// If only HandshakeALot is set, but GuaranteedSafepointInterval is 0, // If HandshakeALot or SafepointALot are set, but GuaranteedSafepointInterval is explicitly
// we emit a handshake if it's been more than a second since the last one. // set to 0 on the command line, we emit the operation if it's been more than a second
// since the last one.
jlong interval = GuaranteedSafepointInterval != 0 ? GuaranteedSafepointInterval : 1000; jlong interval = GuaranteedSafepointInterval != 0 ? GuaranteedSafepointInterval : 1000;
jlong deadline_ms = interval + last_halot_ms; jlong deadline_ms = interval + last_alot_ms;
if (now_ms > deadline_ms) { if (now_ms > deadline_ms) {
last_halot_ms = now_ms; last_alot_ms = now_ms;
return true; return true;
} }
return false; return false;
} }
void VMThread::setup_periodic_safepoint_if_needed() {
assert(_cur_vm_operation == nullptr, "Already have an op");
assert(_next_vm_operation == nullptr, "Already have an op");
// Check for a cleanup before SafepointALot to keep stats correct.
jlong interval_ms = SafepointTracing::time_since_last_safepoint_ms();
bool max_time_exceeded = GuaranteedSafepointInterval != 0 &&
(interval_ms >= GuaranteedSafepointInterval);
if (!max_time_exceeded) {
return;
}
if (SafepointALot) {
_next_vm_operation = &safepointALot_op;
}
}
bool VMThread::set_next_operation(VM_Operation *op) { bool VMThread::set_next_operation(VM_Operation *op) {
if (_next_vm_operation != nullptr) { if (_next_vm_operation != nullptr) {
return false; return false;
@ -465,8 +451,8 @@ void VMThread::wait_for_operation() {
if (_next_vm_operation != nullptr) { if (_next_vm_operation != nullptr) {
return; return;
} }
if (handshake_alot()) { if (handshake_or_safepoint_alot()) {
{ if (HandshakeALot) {
MutexUnlocker mul(VMOperation_lock); MutexUnlocker mul(VMOperation_lock);
HandshakeALotClosure hal_cl; HandshakeALotClosure hal_cl;
Handshake::execute(&hal_cl); Handshake::execute(&hal_cl);
@ -475,15 +461,14 @@ void VMThread::wait_for_operation() {
if (_next_vm_operation != nullptr) { if (_next_vm_operation != nullptr) {
return; return;
} }
if (SafepointALot) {
_next_vm_operation = &safepointALot_op;
return;
}
} }
assert(_next_vm_operation == nullptr, "Must be"); assert(_next_vm_operation == nullptr, "Must be");
assert(_cur_vm_operation == nullptr, "Must be"); assert(_cur_vm_operation == nullptr, "Must be");
setup_periodic_safepoint_if_needed();
if (_next_vm_operation != nullptr) {
return;
}
// We didn't find anything to execute, notify any waiter so they can install an op. // We didn't find anything to execute, notify any waiter so they can install an op.
ml_op_lock.notify_all(); ml_op_lock.notify_all();
ml_op_lock.wait(GuaranteedSafepointInterval); ml_op_lock.wait(GuaranteedSafepointInterval);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2024, 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
@ -70,8 +70,7 @@ class VMThread: public NamedThread {
static VMOperationTimeoutTask* _timeout_task; static VMOperationTimeoutTask* _timeout_task;
static bool handshake_alot(); static bool handshake_or_safepoint_alot();
static void setup_periodic_safepoint_if_needed();
void evaluate_operation(VM_Operation* op); void evaluate_operation(VM_Operation* op);
void inner_execute(VM_Operation* op); void inner_execute(VM_Operation* op);