mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 11:34:38 +02:00
6794422: Perm gen expansion policy for concurrent collectors
Concurrent collectors should expand the perm gen without a full STW GC, but possibly by triggering a concurrent collection. Temporary band-aid for G1 where no concurrent collection is kicked off since the perm gen is not collected concurrently. Reviewed-by: johnc
This commit is contained in:
parent
603e50f355
commit
8fbdf5c7f0
5 changed files with 52 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -50,6 +50,18 @@ HeapWord* CMSPermGen::mem_allocate(size_t size) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HeapWord* CMSPermGen::request_expand_and_allocate(Generation* gen,
|
||||||
|
size_t size,
|
||||||
|
GCCause::Cause prev_cause /* ignored */) {
|
||||||
|
HeapWord* obj = gen->expand_and_allocate(size, false);
|
||||||
|
if (gen->capacity() >= _capacity_expansion_limit) {
|
||||||
|
set_capacity_expansion_limit(gen->capacity() + MaxPermHeapExpansion);
|
||||||
|
assert(((ConcurrentMarkSweepGeneration*)gen)->should_concurrent_collect(),
|
||||||
|
"Should kick off a collection if one not in progress");
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
void CMSPermGen::compute_new_size() {
|
void CMSPermGen::compute_new_size() {
|
||||||
_gen->compute_new_size();
|
_gen->compute_new_size();
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,10 @@ class CMSPermGen: public PermGen {
|
||||||
// The "generation" view.
|
// The "generation" view.
|
||||||
ConcurrentMarkSweepGeneration* _gen;
|
ConcurrentMarkSweepGeneration* _gen;
|
||||||
|
|
||||||
|
// Override default implementation from PermGen
|
||||||
|
virtual HeapWord* request_expand_and_allocate(Generation* gen, size_t size,
|
||||||
|
GCCause::Cause prev_cause);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CMSPermGen(ReservedSpace rs, size_t initial_byte_size,
|
CMSPermGen(ReservedSpace rs, size_t initial_byte_size,
|
||||||
CardTableRS* ct, FreeBlockDictionary::DictionaryChoice);
|
CardTableRS* ct, FreeBlockDictionary::DictionaryChoice);
|
||||||
|
|
|
@ -3456,6 +3456,7 @@ permGen.hpp gcCause.hpp
|
||||||
permGen.hpp generation.hpp
|
permGen.hpp generation.hpp
|
||||||
permGen.hpp handles.hpp
|
permGen.hpp handles.hpp
|
||||||
permGen.hpp iterator.hpp
|
permGen.hpp iterator.hpp
|
||||||
|
permGen.hpp mutexLocker.hpp
|
||||||
permGen.hpp virtualspace.hpp
|
permGen.hpp virtualspace.hpp
|
||||||
|
|
||||||
placeholders.cpp fieldType.hpp
|
placeholders.cpp fieldType.hpp
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -25,6 +25,17 @@
|
||||||
#include "incls/_precompiled.incl"
|
#include "incls/_precompiled.incl"
|
||||||
#include "incls/_permGen.cpp.incl"
|
#include "incls/_permGen.cpp.incl"
|
||||||
|
|
||||||
|
HeapWord* PermGen::request_expand_and_allocate(Generation* gen, size_t size,
|
||||||
|
GCCause::Cause prev_cause) {
|
||||||
|
if (gen->capacity() < _capacity_expansion_limit ||
|
||||||
|
prev_cause != GCCause::_no_gc || UseG1GC) { // last disjunct is a temporary hack for G1
|
||||||
|
return gen->expand_and_allocate(size, false);
|
||||||
|
}
|
||||||
|
// We have reached the limit of capacity expansion where
|
||||||
|
// we will not expand further until a GC is done; request denied.
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
HeapWord* PermGen::mem_allocate_in_gen(size_t size, Generation* gen) {
|
HeapWord* PermGen::mem_allocate_in_gen(size_t size, Generation* gen) {
|
||||||
GCCause::Cause next_cause = GCCause::_permanent_generation_full;
|
GCCause::Cause next_cause = GCCause::_permanent_generation_full;
|
||||||
GCCause::Cause prev_cause = GCCause::_no_gc;
|
GCCause::Cause prev_cause = GCCause::_no_gc;
|
||||||
|
@ -37,10 +48,14 @@ HeapWord* PermGen::mem_allocate_in_gen(size_t size, Generation* gen) {
|
||||||
if ((obj = gen->allocate(size, false)) != NULL) {
|
if ((obj = gen->allocate(size, false)) != NULL) {
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
if (gen->capacity() < _capacity_expansion_limit ||
|
// Attempt to expand and allocate the requested space:
|
||||||
prev_cause != GCCause::_no_gc) {
|
// specific subtypes may use specific policy to either expand
|
||||||
obj = gen->expand_and_allocate(size, false);
|
// or not. The default policy (see above) is to expand until
|
||||||
}
|
// _capacity_expansion_limit, and no further unless a GC is done.
|
||||||
|
// Concurrent collectors may decide to kick off a concurrent
|
||||||
|
// collection under appropriate conditions.
|
||||||
|
obj = request_expand_and_allocate(gen, size, prev_cause);
|
||||||
|
|
||||||
if (obj != NULL || prev_cause == GCCause::_last_ditch_collection) {
|
if (obj != NULL || prev_cause == GCCause::_last_ditch_collection) {
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
@ -119,5 +134,5 @@ void CompactingPermGen::compute_new_size() {
|
||||||
if (_gen->capacity() > desired_capacity) {
|
if (_gen->capacity() > desired_capacity) {
|
||||||
_gen->shrink(_gen->capacity() - desired_capacity);
|
_gen->shrink(_gen->capacity() - desired_capacity);
|
||||||
}
|
}
|
||||||
_capacity_expansion_limit = _gen->capacity() + MaxPermHeapExpansion;
|
set_capacity_expansion_limit(_gen->capacity() + MaxPermHeapExpansion);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -30,15 +30,26 @@ class Generation;
|
||||||
class GenRemSet;
|
class GenRemSet;
|
||||||
class CSpaceCounters;
|
class CSpaceCounters;
|
||||||
|
|
||||||
// PermGen models the part of the heap
|
// PermGen models the part of the heap used to allocate class meta-data.
|
||||||
|
|
||||||
class PermGen : public CHeapObj {
|
class PermGen : public CHeapObj {
|
||||||
friend class VMStructs;
|
friend class VMStructs;
|
||||||
protected:
|
protected:
|
||||||
size_t _capacity_expansion_limit; // maximum expansion allowed without a
|
size_t _capacity_expansion_limit; // maximum expansion allowed without a
|
||||||
// full gc occurring
|
// full gc occurring
|
||||||
|
void set_capacity_expansion_limit(size_t limit) {
|
||||||
|
assert_locked_or_safepoint(Heap_lock);
|
||||||
|
_capacity_expansion_limit = limit;
|
||||||
|
}
|
||||||
|
|
||||||
HeapWord* mem_allocate_in_gen(size_t size, Generation* gen);
|
HeapWord* mem_allocate_in_gen(size_t size, Generation* gen);
|
||||||
|
// Along with mem_allocate_in_gen() above, implements policy for
|
||||||
|
// "scheduling" allocation/expansion/collection of the perm gen.
|
||||||
|
// The virtual method request_...() below can be overridden by
|
||||||
|
// subtypes that want to implement a different expansion/collection
|
||||||
|
// policy from the default provided.
|
||||||
|
virtual HeapWord* request_expand_and_allocate(Generation* gen, size_t size,
|
||||||
|
GCCause::Cause prev_cause);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Name {
|
enum Name {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue