--- old/src/hotspot/share/gc/g1/g1IHOPControl.cpp 2020-06-10 10:12:05.537064015 +0200 +++ new/src/hotspot/share/gc/g1/g1IHOPControl.cpp 2020-06-10 10:12:05.445060856 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ _target_occupancy = new_target_occupancy; } -void G1IHOPControl::update_allocation_info(double allocation_time_s, size_t allocated_bytes, size_t additional_buffer_size) { +void G1IHOPControl::update_allocation_info(double allocation_time_s, size_t allocated_bytes) { assert(allocation_time_s >= 0.0, "Allocation time must be positive but is %.3f", allocation_time_s); _last_allocation_time_s = allocation_time_s; @@ -89,12 +89,23 @@ _heap_reserve_percent(heap_reserve_percent), _heap_waste_percent(heap_waste_percent), _predictor(predictor), - _marking_times_s(10, 0.95), - _allocation_rate_s(10, 0.95), + _marking_times_s(10), + _allocation_rate_s(10), _last_unrestrained_young_size(0) { } +void G1AdaptiveIHOPControl::update_target_occupancy(size_t new_target_occupancy) { + size_t old_target_occupancy = _target_occupancy; + G1IHOPControl::update_target_occupancy(new_target_occupancy); + + // When resizing the heap, as an estimate of the new value, scale the + // buffer needed linearly. + if (old_target_occupancy != 0) { + _last_unrestrained_young_size = _last_unrestrained_young_size * (new_target_occupancy / (double)old_target_occupancy); + } +} + size_t G1AdaptiveIHOPControl::actual_target_threshold() const { guarantee(_target_occupancy > 0, "Target occupancy still not updated yet."); // The actual target threshold takes the heap reserve and the expected waste in @@ -108,7 +119,7 @@ double safe_total_heap_percentage = MIN2((double)(_heap_reserve_percent + _heap_waste_percent), 100.0); return (size_t)MIN2( - G1CollectedHeap::heap()->max_capacity() * (100.0 - safe_total_heap_percentage) / 100.0, + G1CollectedHeap::heap()->soft_max_capacity() * (100.0 - safe_total_heap_percentage) / 100.0, _target_occupancy * (100.0 - _heap_waste_percent) / 100.0 ); } @@ -146,14 +157,15 @@ } void G1AdaptiveIHOPControl::update_allocation_info(double allocation_time_s, - size_t allocated_bytes, - size_t additional_buffer_size) { - G1IHOPControl::update_allocation_info(allocation_time_s, allocated_bytes, additional_buffer_size); + size_t allocated_bytes) { + G1IHOPControl::update_allocation_info(allocation_time_s, allocated_bytes); double allocation_rate = (double) allocated_bytes / allocation_time_s; _allocation_rate_s.add(allocation_rate); +} - _last_unrestrained_young_size = additional_buffer_size; +void G1AdaptiveIHOPControl::update_additional_buffer(size_t additional_buffer_bytes) { + _last_unrestrained_young_size = additional_buffer_bytes; } void G1AdaptiveIHOPControl::update_marking_length(double marking_length_s) {