提交 6f6d15c2 编写于 作者: A apetrusenko

6942253: G1: replace G1ParallelGCAllocBufferSize with YoungPLABSize and OldPLABSize

Summary: Replaces the G1-specific parameter with the existing ones that are used by the other GCs (YoungPLABSize and OldPLABSize)
Reviewed-by: tonyp, johnc
上级 9c11a804
......@@ -2946,6 +2946,25 @@ G1CollectedHeap::do_collection_pause_at_safepoint() {
}
}
size_t G1CollectedHeap::desired_plab_sz(GCAllocPurpose purpose)
{
size_t gclab_word_size;
switch (purpose) {
case GCAllocForSurvived:
gclab_word_size = YoungPLABSize;
break;
case GCAllocForTenured:
gclab_word_size = OldPLABSize;
break;
default:
assert(false, "unknown GCAllocPurpose");
gclab_word_size = OldPLABSize;
break;
}
return gclab_word_size;
}
void G1CollectedHeap::set_gc_alloc_region(int purpose, HeapRegion* r) {
assert(purpose >= 0 && purpose < GCAllocPurposeCount, "invalid purpose");
// make sure we don't call set_gc_alloc_region() multiple times on
......@@ -3680,6 +3699,8 @@ G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, int queue_num)
_g1_rem(g1h->g1_rem_set()),
_hash_seed(17), _queue_num(queue_num),
_term_attempts(0),
_surviving_alloc_buffer(g1h->desired_plab_sz(GCAllocForSurvived)),
_tenured_alloc_buffer(g1h->desired_plab_sz(GCAllocForTenured)),
_age_table(false),
#if G1_DETAILED_STATS
_pushes(0), _pops(0), _steals(0),
......@@ -3706,6 +3727,9 @@ G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, int queue_num)
_overflowed_refs = new OverflowQueue(10);
_alloc_buffers[GCAllocForSurvived] = &_surviving_alloc_buffer;
_alloc_buffers[GCAllocForTenured] = &_tenured_alloc_buffer;
_start = os::elapsedTime();
}
......
......@@ -232,6 +232,9 @@ private:
// current collection.
HeapRegion* _gc_alloc_region_list;
// Determines PLAB size for a particular allocation purpose.
static size_t desired_plab_sz(GCAllocPurpose purpose);
// When called by par thread, require par_alloc_during_gc_lock() to be held.
void push_gc_alloc_region(HeapRegion* hr);
......@@ -1367,12 +1370,18 @@ private:
return BitsPerWord << shifter();
}
static size_t gclab_word_size() {
return G1ParallelGCAllocBufferSize / HeapWordSize;
size_t gclab_word_size() const {
return _gclab_word_size;
}
// Calculates actual GCLab size in words
size_t gclab_real_word_size() const {
return bitmap_size_in_bits(pointer_delta(_real_end_word, _start_word))
/ BitsPerWord;
}
static size_t bitmap_size_in_bits() {
size_t bits_in_bitmap = gclab_word_size() >> shifter();
static size_t bitmap_size_in_bits(size_t gclab_word_size) {
size_t bits_in_bitmap = gclab_word_size >> shifter();
// We are going to ensure that the beginning of a word in this
// bitmap also corresponds to the beginning of a word in the
// global marking bitmap. To handle the case where a GCLab
......@@ -1382,13 +1391,13 @@ private:
return bits_in_bitmap + BitsPerWord - 1;
}
public:
GCLabBitMap(HeapWord* heap_start)
: BitMap(bitmap_size_in_bits()),
GCLabBitMap(HeapWord* heap_start, size_t gclab_word_size)
: BitMap(bitmap_size_in_bits(gclab_word_size)),
_cm(G1CollectedHeap::heap()->concurrent_mark()),
_shifter(shifter()),
_bitmap_word_covers_words(bitmap_word_covers_words()),
_heap_start(heap_start),
_gclab_word_size(gclab_word_size()),
_gclab_word_size(gclab_word_size),
_real_start_word(NULL),
_real_end_word(NULL),
_start_word(NULL)
......@@ -1483,7 +1492,7 @@ public:
mark_bitmap->mostly_disjoint_range_union(this,
0, // always start from the start of the bitmap
_start_word,
size_in_words());
gclab_real_word_size());
_cm->grayRegionIfNecessary(MemRegion(_real_start_word, _real_end_word));
#ifndef PRODUCT
......@@ -1495,9 +1504,10 @@ public:
}
}
static size_t bitmap_size_in_words() {
return (bitmap_size_in_bits() + BitsPerWord - 1) / BitsPerWord;
size_t bitmap_size_in_words() const {
return (bitmap_size_in_bits(gclab_word_size()) + BitsPerWord - 1) / BitsPerWord;
}
};
class G1ParGCAllocBuffer: public ParGCAllocBuffer {
......@@ -1507,10 +1517,10 @@ private:
GCLabBitMap _bitmap;
public:
G1ParGCAllocBuffer() :
ParGCAllocBuffer(G1ParallelGCAllocBufferSize / HeapWordSize),
G1ParGCAllocBuffer(size_t gclab_word_size) :
ParGCAllocBuffer(gclab_word_size),
_during_marking(G1CollectedHeap::heap()->mark_in_progress()),
_bitmap(G1CollectedHeap::heap()->reserved_region().start()),
_bitmap(G1CollectedHeap::heap()->reserved_region().start(), gclab_word_size),
_retired(false)
{ }
......@@ -1549,8 +1559,10 @@ protected:
typedef GrowableArray<StarTask> OverflowQueue;
OverflowQueue* _overflowed_refs;
G1ParGCAllocBuffer _alloc_buffers[GCAllocPurposeCount];
ageTable _age_table;
G1ParGCAllocBuffer _surviving_alloc_buffer;
G1ParGCAllocBuffer _tenured_alloc_buffer;
G1ParGCAllocBuffer* _alloc_buffers[GCAllocPurposeCount];
ageTable _age_table;
size_t _alloc_buffer_waste;
size_t _undo_waste;
......@@ -1619,7 +1631,7 @@ public:
ageTable* age_table() { return &_age_table; }
G1ParGCAllocBuffer* alloc_buffer(GCAllocPurpose purpose) {
return &_alloc_buffers[purpose];
return _alloc_buffers[purpose];
}
size_t alloc_buffer_waste() { return _alloc_buffer_waste; }
......@@ -1684,15 +1696,15 @@ public:
HeapWord* allocate_slow(GCAllocPurpose purpose, size_t word_sz) {
HeapWord* obj = NULL;
if (word_sz * 100 <
(size_t)(G1ParallelGCAllocBufferSize / HeapWordSize) *
ParallelGCBufferWastePct) {
size_t gclab_word_size = _g1h->desired_plab_sz(purpose);
if (word_sz * 100 < gclab_word_size * ParallelGCBufferWastePct) {
G1ParGCAllocBuffer* alloc_buf = alloc_buffer(purpose);
assert(gclab_word_size == alloc_buf->word_sz(),
"dynamic resizing is not supported");
add_to_alloc_buffer_waste(alloc_buf->words_remaining());
alloc_buf->retire(false, false);
HeapWord* buf =
_g1h->par_allocate_during_gc(purpose, G1ParallelGCAllocBufferSize / HeapWordSize);
HeapWord* buf = _g1h->par_allocate_during_gc(purpose, gclab_word_size);
if (buf == NULL) return NULL; // Let caller handle allocation failure.
// Otherwise.
alloc_buf->set_buf(buf);
......@@ -1786,9 +1798,9 @@ public:
void retire_alloc_buffers() {
for (int ap = 0; ap < GCAllocPurposeCount; ++ap) {
size_t waste = _alloc_buffers[ap].words_remaining();
size_t waste = _alloc_buffers[ap]->words_remaining();
add_to_alloc_buffer_waste(waste);
_alloc_buffers[ap].retire(true, false);
_alloc_buffers[ap]->retire(true, false);
}
}
......
......@@ -209,6 +209,15 @@ G1CollectorPolicy::G1CollectorPolicy() :
HeapRegion::setup_heap_region_size(Arguments::min_heap_size());
HeapRegionRemSet::setup_remset_size();
// Verify PLAB sizes
const uint region_size = HeapRegion::GrainWords;
if (YoungPLABSize > region_size || OldPLABSize > region_size) {
char buffer[128];
jio_snprintf(buffer, sizeof(buffer), "%sPLABSize should be at most %u",
OldPLABSize > region_size ? "Old" : "Young", region_size);
vm_exit_during_initialization(buffer);
}
_recent_prev_end_times_for_all_gcs_sec->add(os::elapsedTime());
_prev_collection_pause_end_ms = os::elapsedTime() * 1000.0;
......
......@@ -28,9 +28,6 @@
#define G1_FLAGS(develop, develop_pd, product, product_pd, diagnostic, experimental, notproduct, manageable, product_rw) \
\
product(intx, G1ParallelGCAllocBufferSize, 8*K, \
"Size of parallel G1 allocation buffers in to-space.") \
\
product(intx, G1ConfidencePercent, 50, \
"Confidence level for MMU/pause predictions") \
\
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册