mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-24 14:49:58 +00:00
8234312: ZGC: Adjust warmup criteria
Reviewed-by: eosterlund, stefank
This commit is contained in:
parent
6744eb2b54
commit
3cb52969a2
@ -75,7 +75,7 @@ bool ZDirector::rule_warmup() const {
|
||||
// duration, which is needed by the other rules.
|
||||
const size_t max_capacity = ZHeap::heap()->soft_max_capacity();
|
||||
const size_t used = ZHeap::heap()->used();
|
||||
const double used_threshold_percent = (ZStatCycle::ncycles() + 1) * 0.1;
|
||||
const double used_threshold_percent = (ZStatCycle::nwarmup_cycles() + 1) * 0.1;
|
||||
const size_t used_threshold = max_capacity * used_threshold_percent;
|
||||
|
||||
log_debug(gc, director)("Rule: Warmup %.0f%%, Used: " SIZE_FORMAT "MB, UsedThreshold: " SIZE_FORMAT "MB",
|
||||
@ -85,7 +85,7 @@ bool ZDirector::rule_warmup() const {
|
||||
}
|
||||
|
||||
bool ZDirector::rule_allocation_rate() const {
|
||||
if (ZStatCycle::is_first()) {
|
||||
if (!ZStatCycle::is_normalized_duration_trustable()) {
|
||||
// Rule disabled
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -250,17 +250,11 @@ void ZDriver::collect(GCCause::Cause cause) {
|
||||
case GCCause::_z_allocation_stall:
|
||||
case GCCause::_z_proactive:
|
||||
case GCCause::_z_high_usage:
|
||||
case GCCause::_metadata_GC_threshold:
|
||||
// Start asynchronous GC
|
||||
_gc_cycle_port.send_async(cause);
|
||||
break;
|
||||
|
||||
case GCCause::_metadata_GC_threshold:
|
||||
// Start asynchronous GC, but only if the GC is warm
|
||||
if (ZStatCycle::is_warm()) {
|
||||
_gc_cycle_port.send_async(cause);
|
||||
}
|
||||
break;
|
||||
|
||||
case GCCause::_gc_locker:
|
||||
// Restart VM operation previously blocked by the GC locker
|
||||
_gc_locker_port.signal();
|
||||
@ -352,13 +346,15 @@ void ZDriver::check_out_of_memory() {
|
||||
|
||||
class ZDriverGCScope : public StackObj {
|
||||
private:
|
||||
GCIdMark _gc_id;
|
||||
GCCauseSetter _gc_cause_setter;
|
||||
ZStatTimer _timer;
|
||||
GCIdMark _gc_id;
|
||||
GCCause::Cause _gc_cause;
|
||||
GCCauseSetter _gc_cause_setter;
|
||||
ZStatTimer _timer;
|
||||
|
||||
public:
|
||||
ZDriverGCScope(GCCause::Cause cause) :
|
||||
_gc_id(),
|
||||
_gc_cause(cause),
|
||||
_gc_cause_setter(ZCollectedHeap::heap(), cause),
|
||||
_timer(ZPhaseCycle) {
|
||||
// Update statistics
|
||||
@ -371,7 +367,7 @@ public:
|
||||
(double)ZHeap::heap()->nconcurrent_no_boost_worker_threads();
|
||||
|
||||
// Update statistics
|
||||
ZStatCycle::at_end(boost_factor);
|
||||
ZStatCycle::at_end(_gc_cause, boost_factor);
|
||||
|
||||
// Update data used by soft reference policy
|
||||
Universe::update_heap_info_at_gc();
|
||||
|
||||
@ -1024,7 +1024,7 @@ public:
|
||||
//
|
||||
// Stat cycle
|
||||
//
|
||||
uint64_t ZStatCycle::_ncycles = 0;
|
||||
uint64_t ZStatCycle::_nwarmup_cycles = 0;
|
||||
Ticks ZStatCycle::_start_of_last;
|
||||
Ticks ZStatCycle::_end_of_last;
|
||||
NumberSeq ZStatCycle::_normalized_duration(0.3 /* alpha */);
|
||||
@ -1033,9 +1033,12 @@ void ZStatCycle::at_start() {
|
||||
_start_of_last = Ticks::now();
|
||||
}
|
||||
|
||||
void ZStatCycle::at_end(double boost_factor) {
|
||||
void ZStatCycle::at_end(GCCause::Cause cause, double boost_factor) {
|
||||
_end_of_last = Ticks::now();
|
||||
_ncycles++;
|
||||
|
||||
if (cause == GCCause::_z_warmup) {
|
||||
_nwarmup_cycles++;
|
||||
}
|
||||
|
||||
// Calculate normalized cycle duration. The measured duration is
|
||||
// normalized using the boost factor to avoid artificial deflation
|
||||
@ -1045,16 +1048,18 @@ void ZStatCycle::at_end(double boost_factor) {
|
||||
_normalized_duration.add(normalized_duration);
|
||||
}
|
||||
|
||||
bool ZStatCycle::is_first() {
|
||||
return _ncycles == 0;
|
||||
}
|
||||
|
||||
bool ZStatCycle::is_warm() {
|
||||
return _ncycles >= 3;
|
||||
return _nwarmup_cycles >= 3;
|
||||
}
|
||||
|
||||
uint64_t ZStatCycle::ncycles() {
|
||||
return _ncycles;
|
||||
uint64_t ZStatCycle::nwarmup_cycles() {
|
||||
return _nwarmup_cycles;
|
||||
}
|
||||
|
||||
bool ZStatCycle::is_normalized_duration_trustable() {
|
||||
// The normalized duration is considered trustable if we have
|
||||
// completed at least one warmup cycle
|
||||
return _nwarmup_cycles > 0;
|
||||
}
|
||||
|
||||
const AbsSeq& ZStatCycle::normalized_duration() {
|
||||
@ -1062,8 +1067,8 @@ const AbsSeq& ZStatCycle::normalized_duration() {
|
||||
}
|
||||
|
||||
double ZStatCycle::time_since_last() {
|
||||
if (_ncycles == 0) {
|
||||
// Return time since VM start-up
|
||||
if (_end_of_last.value() == 0) {
|
||||
// No end recorded yet, return time since VM start
|
||||
return os::elapsedTime();
|
||||
}
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
#define SHARE_GC_Z_ZSTAT_HPP
|
||||
|
||||
#include "gc/shared/concurrentGCThread.hpp"
|
||||
#include "gc/shared/gcCause.hpp"
|
||||
#include "gc/shared/gcTimer.hpp"
|
||||
#include "gc/z/zMetronome.hpp"
|
||||
#include "logging/logHandle.hpp"
|
||||
@ -365,19 +366,21 @@ public:
|
||||
//
|
||||
class ZStatCycle : public AllStatic {
|
||||
private:
|
||||
static uint64_t _ncycles;
|
||||
static uint64_t _nwarmup_cycles;
|
||||
static Ticks _start_of_last;
|
||||
static Ticks _end_of_last;
|
||||
static NumberSeq _normalized_duration;
|
||||
|
||||
public:
|
||||
static void at_start();
|
||||
static void at_end(double boost_factor);
|
||||
static void at_end(GCCause::Cause cause, double boost_factor);
|
||||
|
||||
static bool is_first();
|
||||
static bool is_warm();
|
||||
static uint64_t ncycles();
|
||||
static uint64_t nwarmup_cycles();
|
||||
|
||||
static bool is_normalized_duration_trustable();
|
||||
static const AbsSeq& normalized_duration();
|
||||
|
||||
static double time_since_last();
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user