8242901: Duplicate PSYoung/OldGen max size functions
Use (nonvirtual) min/max_gen_size consistently, and remove duplicates. Reviewed-by: stefank, sjohanss
This commit is contained in:
parent
168cdcf65d
commit
659aa08fbc
@ -100,8 +100,8 @@ jint ParallelScavengeHeap::initialize() {
|
||||
MaxOldSize,
|
||||
"old", 1);
|
||||
|
||||
assert(young_gen()->gen_size_limit() == young_rs.size(),"Consistency check");
|
||||
assert(old_gen()->gen_size_limit() == old_rs.size(), "Consistency check");
|
||||
assert(young_gen()->max_gen_size() == young_rs.size(),"Consistency check");
|
||||
assert(old_gen()->max_gen_size() == old_rs.size(), "Consistency check");
|
||||
|
||||
double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0;
|
||||
double max_gc_minor_pause_sec = ((double) MaxGCMinorPauseMillis)/1000.0;
|
||||
@ -207,7 +207,7 @@ bool ParallelScavengeHeap::is_maximal_no_gc() const {
|
||||
size_t ParallelScavengeHeap::max_capacity() const {
|
||||
size_t estimated = reserved_region().byte_size();
|
||||
if (UseAdaptiveSizePolicy) {
|
||||
estimated -= _size_policy->max_survivor_size(young_gen()->max_size());
|
||||
estimated -= _size_policy->max_survivor_size(young_gen()->max_gen_size());
|
||||
} else {
|
||||
estimated -= young_gen()->to_space()->capacity_in_bytes();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 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
|
||||
@ -51,8 +51,10 @@ EdenMutableSpacePool::EdenMutableSpacePool(PSYoungGen* young_gen,
|
||||
const char* name,
|
||||
bool support_usage_threshold) :
|
||||
CollectedMemoryPool(name, space->capacity_in_bytes(),
|
||||
(young_gen->max_size() - young_gen->from_space()->capacity_in_bytes() - young_gen->to_space()->capacity_in_bytes()),
|
||||
support_usage_threshold),
|
||||
(young_gen->max_gen_size() -
|
||||
young_gen->from_space()->capacity_in_bytes() -
|
||||
young_gen->to_space()->capacity_in_bytes()),
|
||||
support_usage_threshold),
|
||||
_young_gen(young_gen),
|
||||
_space(space) {
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 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
|
||||
@ -59,7 +59,9 @@ public:
|
||||
size_t used_in_bytes() { return space()->used_in_bytes(); }
|
||||
size_t max_size() const {
|
||||
// Eden's max_size = max_size of Young Gen - the current committed size of survivor spaces
|
||||
return _young_gen->max_size() - _young_gen->from_space()->capacity_in_bytes() - _young_gen->to_space()->capacity_in_bytes();
|
||||
return _young_gen->max_gen_size() -
|
||||
_young_gen->from_space()->capacity_in_bytes() -
|
||||
_young_gen->to_space()->capacity_in_bytes();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -40,25 +40,27 @@
|
||||
|
||||
PSOldGen::PSOldGen(ReservedSpace rs, size_t initial_size, size_t min_size,
|
||||
size_t max_size, const char* perf_data_name, int level):
|
||||
_init_gen_size(initial_size), _min_gen_size(min_size),
|
||||
_min_gen_size(min_size),
|
||||
_max_gen_size(max_size)
|
||||
{
|
||||
initialize(rs, GenAlignment, perf_data_name, level);
|
||||
initialize(rs, initial_size, GenAlignment, perf_data_name, level);
|
||||
}
|
||||
|
||||
void PSOldGen::initialize(ReservedSpace rs, size_t alignment,
|
||||
void PSOldGen::initialize(ReservedSpace rs, size_t initial_size, size_t alignment,
|
||||
const char* perf_data_name, int level) {
|
||||
initialize_virtual_space(rs, alignment);
|
||||
initialize_virtual_space(rs, initial_size, alignment);
|
||||
initialize_work(perf_data_name, level);
|
||||
|
||||
// The old gen can grow to gen_size_limit(). _reserve reflects only
|
||||
// The old gen can grow to max_gen_size(). _reserve reflects only
|
||||
// the current maximum that can be committed.
|
||||
assert(_reserved.byte_size() <= gen_size_limit(), "Consistency check");
|
||||
assert(_reserved.byte_size() <= max_gen_size(), "Consistency check");
|
||||
|
||||
initialize_performance_counters(perf_data_name, level);
|
||||
}
|
||||
|
||||
void PSOldGen::initialize_virtual_space(ReservedSpace rs, size_t alignment) {
|
||||
void PSOldGen::initialize_virtual_space(ReservedSpace rs,
|
||||
size_t initial_size,
|
||||
size_t alignment) {
|
||||
|
||||
if(ParallelArguments::is_heterogeneous_heap()) {
|
||||
_virtual_space = new PSFileBackedVirtualSpace(rs, alignment, AllocateOldGenAt);
|
||||
@ -68,7 +70,7 @@ void PSOldGen::initialize_virtual_space(ReservedSpace rs, size_t alignment) {
|
||||
} else {
|
||||
_virtual_space = new PSVirtualSpace(rs, alignment);
|
||||
}
|
||||
if (!_virtual_space->expand_by(_init_gen_size)) {
|
||||
if (!_virtual_space->expand_by(initial_size)) {
|
||||
vm_exit_during_initialization("Could not reserve enough space for "
|
||||
"object heap");
|
||||
}
|
||||
@ -80,8 +82,8 @@ void PSOldGen::initialize_work(const char* perf_data_name, int level) {
|
||||
//
|
||||
|
||||
MemRegion limit_reserved((HeapWord*)virtual_space()->low_boundary(),
|
||||
heap_word_size(_max_gen_size));
|
||||
assert(limit_reserved.byte_size() == _max_gen_size,
|
||||
heap_word_size(max_gen_size()));
|
||||
assert(limit_reserved.byte_size() == max_gen_size(),
|
||||
"word vs bytes confusion");
|
||||
//
|
||||
// Object start stuff
|
||||
@ -137,8 +139,8 @@ void PSOldGen::initialize_work(const char* perf_data_name, int level) {
|
||||
|
||||
void PSOldGen::initialize_performance_counters(const char* perf_data_name, int level) {
|
||||
// Generation Counters, generation 'level', 1 subspace
|
||||
_gen_counters = new PSGenerationCounters(perf_data_name, level, 1, _min_gen_size,
|
||||
_max_gen_size, virtual_space());
|
||||
_gen_counters = new PSGenerationCounters(perf_data_name, level, 1, min_gen_size(),
|
||||
max_gen_size(), virtual_space());
|
||||
_space_counters = new SpaceCounters(perf_data_name, 0,
|
||||
virtual_space()->reserved_size(),
|
||||
_object_space, _gen_counters);
|
||||
@ -299,12 +301,12 @@ void PSOldGen::resize(size_t desired_free_space) {
|
||||
size_t new_size = used_in_bytes() + desired_free_space;
|
||||
if (new_size < used_in_bytes()) {
|
||||
// Overflowed the addition.
|
||||
new_size = gen_size_limit();
|
||||
new_size = max_gen_size();
|
||||
}
|
||||
// Adjust according to our min and max
|
||||
new_size = clamp(new_size, min_gen_size(), gen_size_limit());
|
||||
new_size = clamp(new_size, min_gen_size(), max_gen_size());
|
||||
|
||||
assert(gen_size_limit() >= reserved().byte_size(), "max new size problem?");
|
||||
assert(max_gen_size() >= reserved().byte_size(), "max new size problem?");
|
||||
new_size = align_up(new_size, alignment);
|
||||
|
||||
const size_t current_size = capacity_in_bytes();
|
||||
@ -314,7 +316,7 @@ void PSOldGen::resize(size_t desired_free_space) {
|
||||
" new size: " SIZE_FORMAT " current size " SIZE_FORMAT
|
||||
" gen limits: " SIZE_FORMAT " / " SIZE_FORMAT,
|
||||
desired_free_space, used_in_bytes(), new_size, current_size,
|
||||
gen_size_limit(), min_gen_size());
|
||||
max_gen_size(), min_gen_size());
|
||||
|
||||
if (new_size == current_size) {
|
||||
// No change requested
|
||||
@ -358,10 +360,6 @@ void PSOldGen::post_resize() {
|
||||
"Sanity");
|
||||
}
|
||||
|
||||
size_t PSOldGen::gen_size_limit() {
|
||||
return _max_gen_size;
|
||||
}
|
||||
|
||||
void PSOldGen::print() const { print_on(tty);}
|
||||
void PSOldGen::print_on(outputStream* st) const {
|
||||
st->print(" %-15s", name());
|
||||
|
@ -49,7 +49,6 @@ class PSOldGen : public CHeapObj<mtGC> {
|
||||
SpaceCounters* _space_counters;
|
||||
|
||||
// Sizing information, in bytes, set in constructor
|
||||
const size_t _init_gen_size;
|
||||
const size_t _min_gen_size;
|
||||
const size_t _max_gen_size;
|
||||
|
||||
@ -110,9 +109,9 @@ class PSOldGen : public CHeapObj<mtGC> {
|
||||
|
||||
void post_resize();
|
||||
|
||||
void initialize(ReservedSpace rs, size_t alignment,
|
||||
void initialize(ReservedSpace rs, size_t initial_size, size_t alignment,
|
||||
const char* perf_data_name, int level);
|
||||
void initialize_virtual_space(ReservedSpace rs, size_t alignment);
|
||||
void initialize_virtual_space(ReservedSpace rs, size_t initial_size, size_t alignment);
|
||||
void initialize_work(const char* perf_data_name, int level);
|
||||
void initialize_performance_counters(const char* perf_data_name, int level);
|
||||
|
||||
@ -121,14 +120,9 @@ class PSOldGen : public CHeapObj<mtGC> {
|
||||
PSOldGen(ReservedSpace rs, size_t initial_size, size_t min_size,
|
||||
size_t max_size, const char* perf_data_name, int level);
|
||||
|
||||
MemRegion reserved() const { return _reserved; }
|
||||
virtual size_t max_gen_size() { return _max_gen_size; }
|
||||
size_t min_gen_size() { return _min_gen_size; }
|
||||
|
||||
// Returns limit on the maximum size of the generation. This
|
||||
// is the same as _max_gen_size for PSOldGen but need not be
|
||||
// for a derived class.
|
||||
virtual size_t gen_size_limit();
|
||||
MemRegion reserved() const { return _reserved; }
|
||||
size_t max_gen_size() const { return _max_gen_size; }
|
||||
size_t min_gen_size() const { return _min_gen_size; }
|
||||
|
||||
bool is_in(const void* p) const {
|
||||
return _virtual_space->contains((void *)p);
|
||||
|
@ -1864,7 +1864,7 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) {
|
||||
}
|
||||
|
||||
// Calculate optimal free space amounts
|
||||
assert(young_gen->max_size() >
|
||||
assert(young_gen->max_gen_size() >
|
||||
young_gen->from_space()->capacity_in_bytes() +
|
||||
young_gen->to_space()->capacity_in_bytes(),
|
||||
"Sizes of space in young gen are out-of-bounds");
|
||||
@ -1874,7 +1874,7 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) {
|
||||
size_t old_live = old_gen->used_in_bytes();
|
||||
size_t cur_eden = young_gen->eden_space()->capacity_in_bytes();
|
||||
size_t max_old_gen_size = old_gen->max_gen_size();
|
||||
size_t max_eden_size = young_gen->max_size() -
|
||||
size_t max_eden_size = young_gen->max_gen_size() -
|
||||
young_gen->from_space()->capacity_in_bytes() -
|
||||
young_gen->to_space()->capacity_in_bytes();
|
||||
|
||||
|
@ -592,7 +592,7 @@ bool PSScavenge::invoke_no_policy() {
|
||||
counters->update_survivor_overflowed(_survivor_overflow);
|
||||
}
|
||||
|
||||
size_t max_young_size = young_gen->max_size();
|
||||
size_t max_young_size = young_gen->max_gen_size();
|
||||
|
||||
// Deciding a free ratio in the young generation is tricky, so if
|
||||
// MinHeapFreeRatio or MaxHeapFreeRatio are in use (implicating
|
||||
@ -600,7 +600,8 @@ bool PSScavenge::invoke_no_policy() {
|
||||
// should then limit our young generation size using NewRatio to have it
|
||||
// follow the old generation size.
|
||||
if (MinHeapFreeRatio != 0 || MaxHeapFreeRatio != 100) {
|
||||
max_young_size = MIN2(old_gen->capacity_in_bytes() / NewRatio, young_gen->max_size());
|
||||
max_young_size = MIN2(old_gen->capacity_in_bytes() / NewRatio,
|
||||
young_gen->max_gen_size());
|
||||
}
|
||||
|
||||
size_t survivor_limit =
|
||||
@ -625,12 +626,12 @@ bool PSScavenge::invoke_no_policy() {
|
||||
// Don't check if the size_policy is ready at this
|
||||
// level. Let the size_policy check that internally.
|
||||
if (UseAdaptiveGenerationSizePolicyAtMinorCollection &&
|
||||
(AdaptiveSizePolicy::should_update_eden_stats(gc_cause))) {
|
||||
AdaptiveSizePolicy::should_update_eden_stats(gc_cause)) {
|
||||
// Calculate optimal free space amounts
|
||||
assert(young_gen->max_size() >
|
||||
young_gen->from_space()->capacity_in_bytes() +
|
||||
young_gen->to_space()->capacity_in_bytes(),
|
||||
"Sizes of space in young gen are out-of-bounds");
|
||||
assert(young_gen->max_gen_size() >
|
||||
young_gen->from_space()->capacity_in_bytes() +
|
||||
young_gen->to_space()->capacity_in_bytes(),
|
||||
"Sizes of space in young gen are out-of-bounds");
|
||||
|
||||
size_t young_live = young_gen->used_in_bytes();
|
||||
size_t eden_live = young_gen->eden_space()->used_in_bytes();
|
||||
|
@ -41,7 +41,6 @@ PSYoungGen::PSYoungGen(ReservedSpace rs, size_t initial_size, size_t min_size, s
|
||||
_eden_space(NULL),
|
||||
_from_space(NULL),
|
||||
_to_space(NULL),
|
||||
_init_gen_size(initial_size),
|
||||
_min_gen_size(min_size),
|
||||
_max_gen_size(max_size),
|
||||
_gen_counters(NULL),
|
||||
@ -49,20 +48,21 @@ PSYoungGen::PSYoungGen(ReservedSpace rs, size_t initial_size, size_t min_size, s
|
||||
_from_counters(NULL),
|
||||
_to_counters(NULL)
|
||||
{
|
||||
initialize(rs, GenAlignment);
|
||||
initialize(rs, initial_size, GenAlignment);
|
||||
}
|
||||
|
||||
void PSYoungGen::initialize_virtual_space(ReservedSpace rs, size_t alignment) {
|
||||
assert(_init_gen_size != 0, "Should have a finite size");
|
||||
void PSYoungGen::initialize_virtual_space(ReservedSpace rs,
|
||||
size_t initial_size,
|
||||
size_t alignment) {
|
||||
assert(initial_size != 0, "Should have a finite size");
|
||||
_virtual_space = new PSVirtualSpace(rs, alignment);
|
||||
if (!virtual_space()->expand_by(_init_gen_size)) {
|
||||
vm_exit_during_initialization("Could not reserve enough space for "
|
||||
"object heap");
|
||||
if (!virtual_space()->expand_by(initial_size)) {
|
||||
vm_exit_during_initialization("Could not reserve enough space for object heap");
|
||||
}
|
||||
}
|
||||
|
||||
void PSYoungGen::initialize(ReservedSpace rs, size_t alignment) {
|
||||
initialize_virtual_space(rs, alignment);
|
||||
void PSYoungGen::initialize(ReservedSpace rs, size_t initial_size, size_t alignment) {
|
||||
initialize_virtual_space(rs, initial_size, alignment);
|
||||
initialize_work();
|
||||
}
|
||||
|
||||
@ -70,6 +70,7 @@ void PSYoungGen::initialize_work() {
|
||||
|
||||
_reserved = MemRegion((HeapWord*)virtual_space()->low_boundary(),
|
||||
(HeapWord*)virtual_space()->high_boundary());
|
||||
assert(_reserved.byte_size() == max_gen_size(), "invariant");
|
||||
|
||||
MemRegion cmr((HeapWord*)virtual_space()->low(),
|
||||
(HeapWord*)virtual_space()->high());
|
||||
@ -91,8 +92,8 @@ void PSYoungGen::initialize_work() {
|
||||
_to_space = new MutableSpace(virtual_space()->alignment());
|
||||
|
||||
// Generation Counters - generation 0, 3 subspaces
|
||||
_gen_counters = new PSGenerationCounters("new", 0, 3, _min_gen_size,
|
||||
_max_gen_size, _virtual_space);
|
||||
_gen_counters = new PSGenerationCounters("new", 0, 3, min_gen_size(),
|
||||
max_gen_size(), virtual_space());
|
||||
|
||||
// Compute maximum space sizes for performance counters
|
||||
size_t alignment = SpaceAlignment;
|
||||
@ -258,7 +259,7 @@ void PSYoungGen::resize(size_t eden_size, size_t survivor_size) {
|
||||
" used: " SIZE_FORMAT " capacity: " SIZE_FORMAT
|
||||
" gen limits: " SIZE_FORMAT " / " SIZE_FORMAT,
|
||||
eden_size, survivor_size, used_in_bytes(), capacity_in_bytes(),
|
||||
_max_gen_size, min_gen_size());
|
||||
max_gen_size(), min_gen_size());
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,18 +270,18 @@ bool PSYoungGen::resize_generation(size_t eden_size, size_t survivor_size) {
|
||||
bool size_changed = false;
|
||||
|
||||
// There used to be this guarantee there.
|
||||
// guarantee ((eden_size + 2*survivor_size) <= _max_gen_size, "incorrect input arguments");
|
||||
// guarantee ((eden_size + 2*survivor_size) <= max_gen_size(), "incorrect input arguments");
|
||||
// Code below forces this requirement. In addition the desired eden
|
||||
// size and desired survivor sizes are desired goals and may
|
||||
// exceed the total generation size.
|
||||
|
||||
assert(min_gen_size() <= orig_size && orig_size <= max_size(), "just checking");
|
||||
assert(min_gen_size() <= orig_size && orig_size <= max_gen_size(), "just checking");
|
||||
|
||||
// Adjust new generation size
|
||||
const size_t eden_plus_survivors =
|
||||
align_up(eden_size + 2 * survivor_size, alignment);
|
||||
size_t desired_size = clamp(eden_plus_survivors, min_gen_size(), max_size());
|
||||
assert(desired_size <= max_size(), "just checking");
|
||||
size_t desired_size = clamp(eden_plus_survivors, min_gen_size(), max_gen_size());
|
||||
assert(desired_size <= max_gen_size(), "just checking");
|
||||
|
||||
if (desired_size > orig_size) {
|
||||
// Grow the generation
|
||||
@ -312,7 +313,7 @@ bool PSYoungGen::resize_generation(size_t eden_size, size_t survivor_size) {
|
||||
size_changed = true;
|
||||
}
|
||||
} else {
|
||||
if (orig_size == gen_size_limit()) {
|
||||
if (orig_size == max_gen_size()) {
|
||||
log_trace(gc)("PSYoung generation size at maximum: " SIZE_FORMAT "K", orig_size/K);
|
||||
} else if (orig_size == min_gen_size()) {
|
||||
log_trace(gc)("PSYoung generation size at minium: " SIZE_FORMAT "K", orig_size/K);
|
||||
@ -326,7 +327,7 @@ bool PSYoungGen::resize_generation(size_t eden_size, size_t survivor_size) {
|
||||
}
|
||||
|
||||
guarantee(eden_plus_survivors <= virtual_space()->committed_size() ||
|
||||
virtual_space()->committed_size() == max_size(), "Sanity");
|
||||
virtual_space()->committed_size() == max_gen_size(), "Sanity");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ class PSYoungGen : public CHeapObj<mtGC> {
|
||||
MutableSpace* _to_space;
|
||||
|
||||
// Sizing information, in bytes, set in constructor
|
||||
const size_t _init_gen_size;
|
||||
const size_t _min_gen_size;
|
||||
const size_t _max_gen_size;
|
||||
|
||||
@ -78,9 +77,9 @@ class PSYoungGen : public CHeapObj<mtGC> {
|
||||
// the location the live data in the generation.
|
||||
size_t available_to_live();
|
||||
|
||||
void initialize(ReservedSpace rs, size_t alignment);
|
||||
void initialize(ReservedSpace rs, size_t inital_size, size_t alignment);
|
||||
void initialize_work();
|
||||
void initialize_virtual_space(ReservedSpace rs, size_t alignment);
|
||||
void initialize_virtual_space(ReservedSpace rs, size_t initial_size, size_t alignment);
|
||||
|
||||
public:
|
||||
// Initialize the generation.
|
||||
@ -104,9 +103,6 @@ class PSYoungGen : public CHeapObj<mtGC> {
|
||||
MutableSpace* to_space() const { return _to_space; }
|
||||
PSVirtualSpace* virtual_space() const { return _virtual_space; }
|
||||
|
||||
// For Adaptive size policy
|
||||
size_t min_gen_size() { return _min_gen_size; }
|
||||
|
||||
// Called during/after GC
|
||||
void swap_spaces();
|
||||
|
||||
@ -125,11 +121,8 @@ class PSYoungGen : public CHeapObj<mtGC> {
|
||||
size_t used_in_words() const;
|
||||
size_t free_in_words() const;
|
||||
|
||||
// The max this generation can grow to
|
||||
size_t max_size() const { return _reserved.byte_size(); }
|
||||
|
||||
// The max this generation can grow to
|
||||
size_t gen_size_limit() const { return _max_gen_size; }
|
||||
size_t min_gen_size() const { return _min_gen_size; }
|
||||
size_t max_gen_size() const { return _max_gen_size; }
|
||||
|
||||
bool is_maximal_no_gc() const {
|
||||
return true; // Never expands except at a GC
|
||||
|
@ -56,14 +56,12 @@
|
||||
nonstatic_field(PSYoungGen, _eden_space, MutableSpace*) \
|
||||
nonstatic_field(PSYoungGen, _from_space, MutableSpace*) \
|
||||
nonstatic_field(PSYoungGen, _to_space, MutableSpace*) \
|
||||
nonstatic_field(PSYoungGen, _init_gen_size, const size_t) \
|
||||
nonstatic_field(PSYoungGen, _min_gen_size, const size_t) \
|
||||
nonstatic_field(PSYoungGen, _max_gen_size, const size_t) \
|
||||
\
|
||||
nonstatic_field(PSOldGen, _reserved, MemRegion) \
|
||||
nonstatic_field(PSOldGen, _virtual_space, PSVirtualSpace*) \
|
||||
nonstatic_field(PSOldGen, _object_space, MutableSpace*) \
|
||||
nonstatic_field(PSOldGen, _init_gen_size, const size_t) \
|
||||
nonstatic_field(PSOldGen, _min_gen_size, const size_t) \
|
||||
nonstatic_field(PSOldGen, _max_gen_size, const size_t) \
|
||||
\
|
||||
|
Loading…
Reference in New Issue
Block a user