mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
8270100: Fix some inaccurate GC logging
Reviewed-by: ayang, tschatzl
This commit is contained in:
parent
b1bb05bcf4
commit
fb86d13ec4
@ -313,29 +313,31 @@ bool DefNewGeneration::expand(size_t bytes) {
|
||||
return success;
|
||||
}
|
||||
|
||||
size_t DefNewGeneration::adjust_for_thread_increase(size_t new_size_candidate,
|
||||
size_t new_size_before,
|
||||
size_t alignment) const {
|
||||
size_t desired_new_size = new_size_before;
|
||||
|
||||
if (NewSizeThreadIncrease > 0) {
|
||||
int threads_count;
|
||||
size_t DefNewGeneration::calculate_thread_increase_size(int threads_count) const {
|
||||
size_t thread_increase_size = 0;
|
||||
|
||||
// 1. Check an overflow at 'threads_count * NewSizeThreadIncrease'.
|
||||
threads_count = Threads::number_of_non_daemon_threads();
|
||||
// Check an overflow at 'threads_count * NewSizeThreadIncrease'.
|
||||
if (threads_count > 0 && NewSizeThreadIncrease <= max_uintx / threads_count) {
|
||||
thread_increase_size = threads_count * NewSizeThreadIncrease;
|
||||
}
|
||||
return thread_increase_size;
|
||||
}
|
||||
|
||||
// 2. Check an overflow at 'new_size_candidate + thread_increase_size'.
|
||||
if (new_size_candidate <= max_uintx - thread_increase_size) {
|
||||
new_size_candidate += thread_increase_size;
|
||||
size_t DefNewGeneration::adjust_for_thread_increase(size_t new_size_candidate,
|
||||
size_t new_size_before,
|
||||
size_t alignment,
|
||||
size_t thread_increase_size) const {
|
||||
size_t desired_new_size = new_size_before;
|
||||
|
||||
// 3. Check an overflow at 'align_up'.
|
||||
size_t aligned_max = ((max_uintx - alignment) & ~(alignment-1));
|
||||
if (new_size_candidate <= aligned_max) {
|
||||
desired_new_size = align_up(new_size_candidate, alignment);
|
||||
}
|
||||
if (NewSizeThreadIncrease > 0 && thread_increase_size > 0) {
|
||||
|
||||
// 1. Check an overflow at 'new_size_candidate + thread_increase_size'.
|
||||
if (new_size_candidate <= max_uintx - thread_increase_size) {
|
||||
new_size_candidate += thread_increase_size;
|
||||
|
||||
// 2. Check an overflow at 'align_up'.
|
||||
size_t aligned_max = ((max_uintx - alignment) & ~(alignment-1));
|
||||
if (new_size_candidate <= aligned_max) {
|
||||
desired_new_size = align_up(new_size_candidate, alignment);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -364,13 +366,14 @@ void DefNewGeneration::compute_new_size() {
|
||||
// All space sizes must be multiples of Generation::GenGrain.
|
||||
size_t alignment = Generation::GenGrain;
|
||||
|
||||
int threads_count = 0;
|
||||
size_t thread_increase_size = 0;
|
||||
int threads_count = Threads::number_of_non_daemon_threads();
|
||||
size_t thread_increase_size = calculate_thread_increase_size(threads_count);
|
||||
|
||||
size_t new_size_candidate = old_size / NewRatio;
|
||||
// Compute desired new generation size based on NewRatio and NewSizeThreadIncrease
|
||||
// and reverts to previous value if any overflow happens
|
||||
size_t desired_new_size = adjust_for_thread_increase(new_size_candidate, new_size_before, alignment);
|
||||
size_t desired_new_size = adjust_for_thread_increase(new_size_candidate, new_size_before,
|
||||
alignment, thread_increase_size);
|
||||
|
||||
// Adjust new generation size
|
||||
desired_new_size = clamp(desired_new_size, min_new_size, max_new_size);
|
||||
|
||||
@ -341,7 +341,10 @@ protected:
|
||||
// If any overflow happens, revert to previous new size.
|
||||
size_t adjust_for_thread_increase(size_t new_size_candidate,
|
||||
size_t new_size_before,
|
||||
size_t alignment) const;
|
||||
size_t alignment,
|
||||
size_t thread_increase_size) const;
|
||||
|
||||
size_t calculate_thread_increase_size(int threads_count) const;
|
||||
|
||||
|
||||
// Scavenge support
|
||||
|
||||
@ -51,7 +51,8 @@ TenuredGeneration::TenuredGeneration(ReservedSpace rs,
|
||||
HeapWord* end = (HeapWord*) _virtual_space.high();
|
||||
_the_space = new TenuredSpace(_bts, MemRegion(bottom, end));
|
||||
_the_space->reset_saved_mark();
|
||||
_shrink_factor = 0;
|
||||
// If we don't shrink the heap in steps, '_shrink_factor' is always 100%.
|
||||
_shrink_factor = ShrinkHeapInSteps ? 0 : 100;
|
||||
_capacity_at_prologue = 0;
|
||||
|
||||
_gc_stats = new GCStats();
|
||||
|
||||
@ -41,9 +41,11 @@ CardGeneration::CardGeneration(ReservedSpace rs,
|
||||
size_t initial_byte_size,
|
||||
CardTableRS* remset) :
|
||||
Generation(rs, initial_byte_size), _rs(remset),
|
||||
_shrink_factor(0), _min_heap_delta_bytes(), _capacity_at_prologue(),
|
||||
_min_heap_delta_bytes(), _capacity_at_prologue(),
|
||||
_used_at_prologue()
|
||||
{
|
||||
// If we don't shrink the heap in steps, '_shrink_factor' is always 100%.
|
||||
_shrink_factor = ShrinkHeapInSteps ? 0 : 100;
|
||||
HeapWord* start = (HeapWord*)rs.base();
|
||||
size_t reserved_byte_size = rs.size();
|
||||
assert((uintptr_t(start) & 3) == 0, "bad alignment");
|
||||
@ -186,7 +188,12 @@ void CardGeneration::invalidate_remembered_set() {
|
||||
void CardGeneration::compute_new_size() {
|
||||
assert(_shrink_factor <= 100, "invalid shrink factor");
|
||||
size_t current_shrink_factor = _shrink_factor;
|
||||
_shrink_factor = 0;
|
||||
if (ShrinkHeapInSteps) {
|
||||
// Always reset '_shrink_factor' if the heap is shrunk in steps.
|
||||
// If we shrink the heap in this iteration, '_shrink_factor' will
|
||||
// be recomputed based on the old value further down in this fuction.
|
||||
_shrink_factor = 0;
|
||||
}
|
||||
|
||||
// We don't have floating point command-line arguments
|
||||
// Note: argument processing ensures that MinHeapFreeRatio < 100.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user