--- old/src/hotspot/share/gc/g1/g1HeapSizingPolicy.cpp 2020-05-19 15:10:02.469034872 +0200 +++ new/src/hotspot/share/gc/g1/g1HeapSizingPolicy.cpp 2020-05-19 15:10:02.385033636 +0200 @@ -63,26 +63,42 @@ return threshold; } +static void log_expansion(double short_term_pause_time_ratio, + double long_term_pause_time_ratio, + double threshold, + double pause_time_ratio, + bool fully_expanded, + size_t resize_bytes) { + + log_debug(gc, ergo, heap)("Heap expansion: " + "short term pause time ratio %1.2f%% long term pause time ratio %1.2f%% " + "threshold %1.2f%% pause time ratio %1.2f%% fully expanded %s " + "resize by " SIZE_FORMAT "B", + short_term_pause_time_ratio * 100.0, + long_term_pause_time_ratio * 100.0, + threshold * 100.0, + pause_time_ratio * 100.0, + BOOL_TO_STR(fully_expanded), + resize_bytes); +} + size_t G1HeapSizingPolicy::expansion_amount() { assert(GCTimeRatio > 0, "must be"); double long_term_pause_time_ratio = _analytics->long_term_pause_time_ratio(); double short_term_pause_time_ratio = _analytics->short_term_pause_time_ratio(); + const double pause_time_threshold = 1.0 / (1.0 + GCTimeRatio); + double threshold = scale_with_heap(pause_time_threshold); + size_t expand_bytes = 0; if (_g1h->capacity() == _g1h->max_capacity()) { - log_trace(gc, ergo, heap)("Cannot expand (heap already fully expanded) " - "long term GC overhead: %1.2f%% committed: " SIZE_FORMAT "B", - long_term_pause_time_ratio * 100.0, _g1h->capacity()); - + log_expansion(short_term_pause_time_ratio, long_term_pause_time_ratio, + threshold, pause_time_threshold, true, 0); clear_ratio_check_data(); return expand_bytes; } - const double pause_time_threshold = 1.0 / (1.0 + GCTimeRatio); - - double threshold = scale_with_heap(pause_time_threshold); - // If the last GC time ratio is over the threshold, increment the count of // times it has been exceeded, and add this ratio to the sum of exceeded // ratios. @@ -158,7 +174,7 @@ // Ensure the expansion size is at least the minimum growth amount // and at most the remaining uncommitted byte size. - expand_bytes = clamp(min_expand_bytes, expand_bytes, uncommitted_bytes); + expand_bytes = clamp(expand_bytes, min_expand_bytes, uncommitted_bytes); clear_ratio_check_data(); } else { @@ -174,8 +190,8 @@ } } - log("Heap expansion:", short_term_pause_time_ratio, long_term_pause_time_ratio, - threshold, pause_time_ratio, false, expand_bytes); + log_expansion(short_term_pause_time_ratio, long_term_pause_time_ratio, + threshold, pause_time_threshold, false, expand_bytes); return expand_bytes; }