8209062: Clean up G1MonitoringSupport
Reviewed-by: phh, sangheki
This commit is contained in:
parent
0d78eb91db
commit
6f880d7f48
src
hotspot/share/gc/g1
g1CollectedHeap.cppg1MemoryPool.cppg1MemoryPool.hppg1MonitoringSupport.cppg1MonitoringSupport.hppvmStructs_g1.hpp
jdk.hotspot.agent/share/classes/sun/jvm/hotspot
@ -4800,7 +4800,7 @@ void G1CollectedHeap::retire_mutator_alloc_region(HeapRegion* alloc_region,
|
||||
_hr_printer.retire(alloc_region);
|
||||
// We update the eden sizes here, when the region is retired,
|
||||
// instead of when it's allocated, since this is the point that its
|
||||
// used space has been recored in _summary_bytes_used.
|
||||
// used space has been recorded in _summary_bytes_used.
|
||||
g1mm()->update_eden_size();
|
||||
}
|
||||
|
||||
|
@ -40,50 +40,41 @@ G1MemoryPoolSuper::G1MemoryPoolSuper(G1CollectedHeap* g1h,
|
||||
assert(UseG1GC, "sanity");
|
||||
}
|
||||
|
||||
G1EdenPool::G1EdenPool(G1CollectedHeap* g1h) :
|
||||
G1EdenPool::G1EdenPool(G1CollectedHeap* g1h, size_t initial_size) :
|
||||
G1MemoryPoolSuper(g1h,
|
||||
"G1 Eden Space",
|
||||
g1h->g1mm()->eden_space_committed(), /* init_size */
|
||||
_undefined_max,
|
||||
initial_size,
|
||||
MemoryUsage::undefined_size(),
|
||||
false /* support_usage_threshold */) { }
|
||||
|
||||
MemoryUsage G1EdenPool::get_memory_usage() {
|
||||
size_t initial_sz = initial_size();
|
||||
size_t max_sz = max_size();
|
||||
size_t used = used_in_bytes();
|
||||
size_t committed = _g1mm->eden_space_committed();
|
||||
|
||||
return MemoryUsage(initial_sz, used, committed, max_sz);
|
||||
return MemoryUsage(initial_size(), used_in_bytes(), committed, max_size());
|
||||
}
|
||||
|
||||
G1SurvivorPool::G1SurvivorPool(G1CollectedHeap* g1h) :
|
||||
G1SurvivorPool::G1SurvivorPool(G1CollectedHeap* g1h, size_t initial_size) :
|
||||
G1MemoryPoolSuper(g1h,
|
||||
"G1 Survivor Space",
|
||||
g1h->g1mm()->survivor_space_committed(), /* init_size */
|
||||
_undefined_max,
|
||||
initial_size,
|
||||
MemoryUsage::undefined_size(),
|
||||
false /* support_usage_threshold */) { }
|
||||
|
||||
MemoryUsage G1SurvivorPool::get_memory_usage() {
|
||||
size_t initial_sz = initial_size();
|
||||
size_t max_sz = max_size();
|
||||
size_t used = used_in_bytes();
|
||||
size_t committed = _g1mm->survivor_space_committed();
|
||||
|
||||
return MemoryUsage(initial_sz, used, committed, max_sz);
|
||||
return MemoryUsage(initial_size(), used_in_bytes(), committed, max_size());
|
||||
}
|
||||
|
||||
G1OldGenPool::G1OldGenPool(G1CollectedHeap* g1h) :
|
||||
G1OldGenPool::G1OldGenPool(G1CollectedHeap* g1h, size_t initial_size, size_t max_size) :
|
||||
G1MemoryPoolSuper(g1h,
|
||||
"G1 Old Gen",
|
||||
g1h->g1mm()->old_space_committed(), /* init_size */
|
||||
g1h->g1mm()->old_gen_max(),
|
||||
initial_size,
|
||||
max_size,
|
||||
true /* support_usage_threshold */) { }
|
||||
|
||||
MemoryUsage G1OldGenPool::get_memory_usage() {
|
||||
size_t initial_sz = initial_size();
|
||||
size_t max_sz = max_size();
|
||||
size_t used = used_in_bytes();
|
||||
size_t committed = _g1mm->old_space_committed();
|
||||
size_t committed = _g1mm->old_gen_committed();
|
||||
|
||||
return MemoryUsage(initial_sz, used, committed, max_sz);
|
||||
return MemoryUsage(initial_size(), used_in_bytes(), committed, max_size());
|
||||
}
|
||||
|
@ -53,7 +53,6 @@ class G1CollectedHeap;
|
||||
// (G1EdenPool, G1SurvivorPool, G1OldGenPool).
|
||||
class G1MemoryPoolSuper : public CollectedMemoryPool {
|
||||
protected:
|
||||
const static size_t _undefined_max = (size_t) -1;
|
||||
G1MonitoringSupport* _g1mm;
|
||||
|
||||
// Would only be called from subclasses.
|
||||
@ -67,42 +66,30 @@ protected:
|
||||
// Memory pool that represents the G1 eden.
|
||||
class G1EdenPool : public G1MemoryPoolSuper {
|
||||
public:
|
||||
G1EdenPool(G1CollectedHeap* g1h);
|
||||
G1EdenPool(G1CollectedHeap* g1h, size_t initial_size);
|
||||
|
||||
size_t used_in_bytes() { return _g1mm->eden_space_used(); }
|
||||
|
||||
size_t used_in_bytes() {
|
||||
return _g1mm->eden_space_used();
|
||||
}
|
||||
size_t max_size() const {
|
||||
return _undefined_max;
|
||||
}
|
||||
MemoryUsage get_memory_usage();
|
||||
};
|
||||
|
||||
// Memory pool that represents the G1 survivor.
|
||||
class G1SurvivorPool : public G1MemoryPoolSuper {
|
||||
public:
|
||||
G1SurvivorPool(G1CollectedHeap* g1h);
|
||||
G1SurvivorPool(G1CollectedHeap* g1h, size_t initial_size);
|
||||
|
||||
size_t used_in_bytes() { return _g1mm->survivor_space_used(); }
|
||||
|
||||
size_t used_in_bytes() {
|
||||
return _g1mm->survivor_space_used();
|
||||
}
|
||||
size_t max_size() const {
|
||||
return _undefined_max;
|
||||
}
|
||||
MemoryUsage get_memory_usage();
|
||||
};
|
||||
|
||||
// Memory pool that represents the G1 old gen.
|
||||
class G1OldGenPool : public G1MemoryPoolSuper {
|
||||
public:
|
||||
G1OldGenPool(G1CollectedHeap* g1h);
|
||||
G1OldGenPool(G1CollectedHeap* g1h, size_t initial_size, size_t max_size);
|
||||
|
||||
size_t used_in_bytes() { return _g1mm->old_gen_used(); }
|
||||
|
||||
size_t used_in_bytes() {
|
||||
return _g1mm->old_space_used();
|
||||
}
|
||||
size_t max_size() const {
|
||||
return _g1mm->old_gen_max();
|
||||
}
|
||||
MemoryUsage get_memory_usage();
|
||||
};
|
||||
|
||||
|
@ -31,84 +31,90 @@
|
||||
#include "memory/metaspaceCounters.hpp"
|
||||
#include "services/memoryPool.hpp"
|
||||
|
||||
G1GenerationCounters::G1GenerationCounters(G1MonitoringSupport* g1mm,
|
||||
const char* name,
|
||||
int ordinal, int spaces,
|
||||
size_t min_capacity,
|
||||
size_t max_capacity,
|
||||
size_t curr_capacity)
|
||||
class G1GenerationCounters : public GenerationCounters {
|
||||
protected:
|
||||
G1MonitoringSupport* _g1mm;
|
||||
|
||||
public:
|
||||
G1GenerationCounters(G1MonitoringSupport* g1mm,
|
||||
const char* name, int ordinal, int spaces,
|
||||
size_t min_capacity, size_t max_capacity,
|
||||
size_t curr_capacity)
|
||||
: GenerationCounters(name, ordinal, spaces, min_capacity,
|
||||
max_capacity, curr_capacity), _g1mm(g1mm) { }
|
||||
};
|
||||
|
||||
// We pad the capacity three times given that the young generation
|
||||
// contains three spaces (eden and two survivors).
|
||||
G1YoungGenerationCounters::G1YoungGenerationCounters(G1MonitoringSupport* g1mm,
|
||||
const char* name)
|
||||
class G1YoungGenerationCounters : public G1GenerationCounters {
|
||||
public:
|
||||
// We pad the capacity three times given that the young generation
|
||||
// contains three spaces (eden and two survivors).
|
||||
G1YoungGenerationCounters(G1MonitoringSupport* g1mm, const char* name, size_t max_size)
|
||||
: G1GenerationCounters(g1mm, name, 0 /* ordinal */, 3 /* spaces */,
|
||||
G1MonitoringSupport::pad_capacity(0, 3) /* min_capacity */,
|
||||
G1MonitoringSupport::pad_capacity(g1mm->young_gen_max(), 3),
|
||||
G1MonitoringSupport::pad_capacity(0, 3) /* curr_capacity */) {
|
||||
if (UsePerfData) {
|
||||
update_all();
|
||||
G1MonitoringSupport::pad_capacity(0, 3) /* min_capacity */,
|
||||
G1MonitoringSupport::pad_capacity(max_size, 3),
|
||||
G1MonitoringSupport::pad_capacity(0, 3) /* curr_capacity */) {
|
||||
if (UsePerfData) {
|
||||
update_all();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
G1OldGenerationCounters::G1OldGenerationCounters(G1MonitoringSupport* g1mm,
|
||||
const char* name)
|
||||
virtual void update_all() {
|
||||
size_t committed =
|
||||
G1MonitoringSupport::pad_capacity(_g1mm->young_gen_committed(), 3);
|
||||
_current_size->set_value(committed);
|
||||
}
|
||||
};
|
||||
|
||||
class G1OldGenerationCounters : public G1GenerationCounters {
|
||||
public:
|
||||
G1OldGenerationCounters(G1MonitoringSupport* g1mm, const char* name, size_t max_size)
|
||||
: G1GenerationCounters(g1mm, name, 1 /* ordinal */, 1 /* spaces */,
|
||||
G1MonitoringSupport::pad_capacity(0) /* min_capacity */,
|
||||
G1MonitoringSupport::pad_capacity(g1mm->old_gen_max()),
|
||||
G1MonitoringSupport::pad_capacity(0) /* curr_capacity */) {
|
||||
if (UsePerfData) {
|
||||
update_all();
|
||||
G1MonitoringSupport::pad_capacity(0) /* min_capacity */,
|
||||
G1MonitoringSupport::pad_capacity(max_size),
|
||||
G1MonitoringSupport::pad_capacity(0) /* curr_capacity */) {
|
||||
if (UsePerfData) {
|
||||
update_all();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void G1YoungGenerationCounters::update_all() {
|
||||
size_t committed =
|
||||
G1MonitoringSupport::pad_capacity(_g1mm->young_gen_committed(), 3);
|
||||
_current_size->set_value(committed);
|
||||
}
|
||||
|
||||
void G1OldGenerationCounters::update_all() {
|
||||
size_t committed =
|
||||
G1MonitoringSupport::pad_capacity(_g1mm->old_gen_committed());
|
||||
_current_size->set_value(committed);
|
||||
}
|
||||
virtual void update_all() {
|
||||
size_t committed =
|
||||
G1MonitoringSupport::pad_capacity(_g1mm->old_gen_committed());
|
||||
_current_size->set_value(committed);
|
||||
}
|
||||
};
|
||||
|
||||
G1MonitoringSupport::G1MonitoringSupport(G1CollectedHeap* g1h) :
|
||||
_g1h(g1h),
|
||||
_memory_manager("G1 Young Generation", "end of minor GC"),
|
||||
_incremental_memory_manager("G1 Young Generation", "end of minor GC"),
|
||||
_full_gc_memory_manager("G1 Old Generation", "end of major GC"),
|
||||
_eden_pool(NULL),
|
||||
_survivor_pool(NULL),
|
||||
_old_pool(NULL),
|
||||
_eden_space_pool(NULL),
|
||||
_survivor_space_pool(NULL),
|
||||
_old_gen_pool(NULL),
|
||||
_incremental_collection_counters(NULL),
|
||||
_full_collection_counters(NULL),
|
||||
_conc_collection_counters(NULL),
|
||||
_young_collection_counters(NULL),
|
||||
_old_collection_counters(NULL),
|
||||
_young_gen_counters(NULL),
|
||||
_old_gen_counters(NULL),
|
||||
_old_space_counters(NULL),
|
||||
_eden_counters(NULL),
|
||||
_from_counters(NULL),
|
||||
_to_counters(NULL),
|
||||
_eden_space_counters(NULL),
|
||||
_from_space_counters(NULL),
|
||||
_to_space_counters(NULL),
|
||||
|
||||
_overall_reserved(0),
|
||||
_overall_committed(0),
|
||||
_overall_used(0),
|
||||
_young_region_num(0),
|
||||
_young_gen_committed(0),
|
||||
_eden_committed(0),
|
||||
_eden_used(0),
|
||||
_survivor_committed(0),
|
||||
_survivor_used(0),
|
||||
_old_committed(0),
|
||||
_old_used(0) {
|
||||
_old_gen_committed(0),
|
||||
|
||||
_eden_space_committed(0),
|
||||
_eden_space_used(0),
|
||||
_survivor_space_committed(0),
|
||||
_survivor_space_used(0),
|
||||
_old_gen_used(0) {
|
||||
|
||||
_overall_reserved = g1h->max_capacity();
|
||||
recalculate_sizes();
|
||||
|
||||
// Counters for GC collections
|
||||
// Counters for garbage collections
|
||||
//
|
||||
// name "collector.0". In a generational collector this would be the
|
||||
// young generation collection.
|
||||
@ -123,112 +129,96 @@ G1MonitoringSupport::G1MonitoringSupport(G1CollectedHeap* g1h) :
|
||||
_conc_collection_counters =
|
||||
new CollectorCounters("G1 stop-the-world phases", 2);
|
||||
|
||||
// timer sampling for all counters supporting sampling only update the
|
||||
// used value. See the take_sample() method. G1 requires both used and
|
||||
// capacity updated so sampling is not currently used. It might
|
||||
// be sufficient to update all counters in take_sample() even though
|
||||
// take_sample() only returns "used". When sampling was used, there
|
||||
// were some anomolous values emitted which may have been the consequence
|
||||
// of not updating all values simultaneously (i.e., see the calculation done
|
||||
// in eden_space_used(), is it possible that the values used to
|
||||
// calculate either eden_used or survivor_used are being updated by
|
||||
// the collector when the sample is being done?).
|
||||
const bool sampled = false;
|
||||
|
||||
// "Generation" and "Space" counters.
|
||||
//
|
||||
// name "generation.1" This is logically the old generation in
|
||||
// generational GC terms. The "1, 1" parameters are for
|
||||
// the n-th generation (=1) with 1 space.
|
||||
// Counters are created from minCapacity, maxCapacity, and capacity
|
||||
_old_collection_counters = new G1OldGenerationCounters(this, "old");
|
||||
_old_gen_counters = new G1OldGenerationCounters(this, "old", _g1h->max_capacity());
|
||||
|
||||
// name "generation.1.space.0"
|
||||
// Counters are created from maxCapacity, capacity, initCapacity,
|
||||
// and used.
|
||||
_old_space_counters = new HSpaceCounters(_old_collection_counters->name_space(),
|
||||
_old_space_counters = new HSpaceCounters(_old_gen_counters->name_space(),
|
||||
"space", 0 /* ordinal */,
|
||||
pad_capacity(overall_reserved()) /* max_capacity */,
|
||||
pad_capacity(old_space_committed()) /* init_capacity */);
|
||||
pad_capacity(g1h->max_capacity()) /* max_capacity */,
|
||||
pad_capacity(_old_gen_committed) /* init_capacity */);
|
||||
|
||||
// Young collection set
|
||||
// name "generation.0". This is logically the young generation.
|
||||
// The "0, 3" are parameters for the n-th generation (=0) with 3 spaces.
|
||||
// See _old_collection_counters for additional counters
|
||||
_young_collection_counters = new G1YoungGenerationCounters(this, "young");
|
||||
_young_gen_counters = new G1YoungGenerationCounters(this, "young", _g1h->max_capacity());
|
||||
|
||||
const char* young_collection_name_space = _young_collection_counters->name_space();
|
||||
const char* young_collection_name_space = _young_gen_counters->name_space();
|
||||
|
||||
// name "generation.0.space.0"
|
||||
// See _old_space_counters for additional counters
|
||||
_eden_counters = new HSpaceCounters(young_collection_name_space,
|
||||
_eden_space_counters = new HSpaceCounters(young_collection_name_space,
|
||||
"eden", 0 /* ordinal */,
|
||||
pad_capacity(overall_reserved()) /* max_capacity */,
|
||||
pad_capacity(eden_space_committed()) /* init_capacity */);
|
||||
pad_capacity(g1h->max_capacity()) /* max_capacity */,
|
||||
pad_capacity(_eden_space_committed) /* init_capacity */);
|
||||
|
||||
// name "generation.0.space.1"
|
||||
// See _old_space_counters for additional counters
|
||||
// Set the arguments to indicate that this survivor space is not used.
|
||||
_from_counters = new HSpaceCounters(young_collection_name_space,
|
||||
_from_space_counters = new HSpaceCounters(young_collection_name_space,
|
||||
"s0", 1 /* ordinal */,
|
||||
pad_capacity(0) /* max_capacity */,
|
||||
pad_capacity(0) /* init_capacity */);
|
||||
// Given that this survivor space is not used, we update it here
|
||||
// once to reflect that its used space is 0 so that we don't have to
|
||||
// worry about updating it again later.
|
||||
_from_space_counters->update_used(0);
|
||||
|
||||
// name "generation.0.space.2"
|
||||
// See _old_space_counters for additional counters
|
||||
_to_counters = new HSpaceCounters(young_collection_name_space,
|
||||
_to_space_counters = new HSpaceCounters(young_collection_name_space,
|
||||
"s1", 2 /* ordinal */,
|
||||
pad_capacity(overall_reserved()) /* max_capacity */,
|
||||
pad_capacity(survivor_space_committed()) /* init_capacity */);
|
||||
|
||||
if (UsePerfData) {
|
||||
// Given that this survivor space is not used, we update it here
|
||||
// once to reflect that its used space is 0 so that we don't have to
|
||||
// worry about updating it again later.
|
||||
_from_counters->update_used(0);
|
||||
}
|
||||
pad_capacity(g1h->max_capacity()) /* max_capacity */,
|
||||
pad_capacity(_survivor_space_committed) /* init_capacity */);
|
||||
}
|
||||
|
||||
G1MonitoringSupport::~G1MonitoringSupport() {
|
||||
delete _eden_pool;
|
||||
delete _survivor_pool;
|
||||
delete _old_pool;
|
||||
delete _eden_space_pool;
|
||||
delete _survivor_space_pool;
|
||||
delete _old_gen_pool;
|
||||
}
|
||||
|
||||
void G1MonitoringSupport::initialize_serviceability() {
|
||||
_eden_pool = new G1EdenPool(_g1h);
|
||||
_survivor_pool = new G1SurvivorPool(_g1h);
|
||||
_old_pool = new G1OldGenPool(_g1h);
|
||||
_eden_space_pool = new G1EdenPool(_g1h, _eden_space_committed);
|
||||
_survivor_space_pool = new G1SurvivorPool(_g1h, _survivor_space_committed);
|
||||
_old_gen_pool = new G1OldGenPool(_g1h, _old_gen_committed, _g1h->max_capacity());
|
||||
|
||||
_full_gc_memory_manager.add_pool(_eden_pool);
|
||||
_full_gc_memory_manager.add_pool(_survivor_pool);
|
||||
_full_gc_memory_manager.add_pool(_old_pool);
|
||||
_full_gc_memory_manager.add_pool(_eden_space_pool);
|
||||
_full_gc_memory_manager.add_pool(_survivor_space_pool);
|
||||
_full_gc_memory_manager.add_pool(_old_gen_pool);
|
||||
|
||||
_memory_manager.add_pool(_eden_pool);
|
||||
_memory_manager.add_pool(_survivor_pool);
|
||||
_memory_manager.add_pool(_old_pool, false /* always_affected_by_gc */);
|
||||
_incremental_memory_manager.add_pool(_eden_space_pool);
|
||||
_incremental_memory_manager.add_pool(_survivor_space_pool);
|
||||
_incremental_memory_manager.add_pool(_old_gen_pool, false /* always_affected_by_gc */);
|
||||
}
|
||||
|
||||
GrowableArray<GCMemoryManager*> G1MonitoringSupport::memory_managers() {
|
||||
GrowableArray<GCMemoryManager*> memory_managers(2);
|
||||
memory_managers.append(&_memory_manager);
|
||||
memory_managers.append(&_incremental_memory_manager);
|
||||
memory_managers.append(&_full_gc_memory_manager);
|
||||
return memory_managers;
|
||||
}
|
||||
|
||||
GrowableArray<MemoryPool*> G1MonitoringSupport::memory_pools() {
|
||||
GrowableArray<MemoryPool*> memory_pools(3);
|
||||
memory_pools.append(_eden_pool);
|
||||
memory_pools.append(_survivor_pool);
|
||||
memory_pools.append(_old_pool);
|
||||
memory_pools.append(_eden_space_pool);
|
||||
memory_pools.append(_survivor_space_pool);
|
||||
memory_pools.append(_old_gen_pool);
|
||||
return memory_pools;
|
||||
}
|
||||
|
||||
void G1MonitoringSupport::recalculate_sizes() {
|
||||
// Recalculate all the sizes from scratch. We assume that this is
|
||||
// called at a point where no concurrent updates to the various
|
||||
// values we read here are possible (i.e., at a STW phase at the end
|
||||
// of a GC).
|
||||
assert_heap_locked_or_at_safepoint(true);
|
||||
|
||||
// Recalculate all the sizes from scratch.
|
||||
|
||||
uint young_list_length = _g1h->young_regions_count();
|
||||
uint survivor_list_length = _g1h->survivor_regions_count();
|
||||
@ -241,14 +231,13 @@ void G1MonitoringSupport::recalculate_sizes() {
|
||||
uint eden_list_max_length = young_list_max_length - survivor_list_length;
|
||||
|
||||
_overall_used = _g1h->used_unlocked();
|
||||
_eden_used = (size_t) eden_list_length * HeapRegion::GrainBytes;
|
||||
_survivor_used = (size_t) survivor_list_length * HeapRegion::GrainBytes;
|
||||
_young_region_num = young_list_length;
|
||||
_old_used = subtract_up_to_zero(_overall_used, _eden_used + _survivor_used);
|
||||
_eden_space_used = (size_t) eden_list_length * HeapRegion::GrainBytes;
|
||||
_survivor_space_used = (size_t) survivor_list_length * HeapRegion::GrainBytes;
|
||||
_old_gen_used = subtract_up_to_zero(_overall_used, _eden_space_used + _survivor_space_used);
|
||||
|
||||
// First calculate the committed sizes that can be calculated independently.
|
||||
_survivor_committed = _survivor_used;
|
||||
_old_committed = HeapRegion::align_up_to_region_byte_size(_old_used);
|
||||
_survivor_space_committed = _survivor_space_used;
|
||||
_old_gen_committed = HeapRegion::align_up_to_region_byte_size(_old_gen_used);
|
||||
|
||||
// Next, start with the overall committed size.
|
||||
_overall_committed = _g1h->capacity();
|
||||
@ -256,76 +245,64 @@ void G1MonitoringSupport::recalculate_sizes() {
|
||||
|
||||
// Remove the committed size we have calculated so far (for the
|
||||
// survivor and old space).
|
||||
assert(committed >= (_survivor_committed + _old_committed), "sanity");
|
||||
committed -= _survivor_committed + _old_committed;
|
||||
assert(committed >= (_survivor_space_committed + _old_gen_committed), "sanity");
|
||||
committed -= _survivor_space_committed + _old_gen_committed;
|
||||
|
||||
// Next, calculate and remove the committed size for the eden.
|
||||
_eden_committed = (size_t) eden_list_max_length * HeapRegion::GrainBytes;
|
||||
_eden_space_committed = (size_t) eden_list_max_length * HeapRegion::GrainBytes;
|
||||
// Somewhat defensive: be robust in case there are inaccuracies in
|
||||
// the calculations
|
||||
_eden_committed = MIN2(_eden_committed, committed);
|
||||
committed -= _eden_committed;
|
||||
_eden_space_committed = MIN2(_eden_space_committed, committed);
|
||||
committed -= _eden_space_committed;
|
||||
|
||||
// Finally, give the rest to the old space...
|
||||
_old_committed += committed;
|
||||
_old_gen_committed += committed;
|
||||
// ..and calculate the young gen committed.
|
||||
_young_gen_committed = _eden_committed + _survivor_committed;
|
||||
_young_gen_committed = _eden_space_committed + _survivor_space_committed;
|
||||
|
||||
assert(_overall_committed ==
|
||||
(_eden_committed + _survivor_committed + _old_committed),
|
||||
(_eden_space_committed + _survivor_space_committed + _old_gen_committed),
|
||||
"the committed sizes should add up");
|
||||
// Somewhat defensive: cap the eden used size to make sure it
|
||||
// never exceeds the committed size.
|
||||
_eden_used = MIN2(_eden_used, _eden_committed);
|
||||
_eden_space_used = MIN2(_eden_space_used, _eden_space_committed);
|
||||
// _survivor_committed and _old_committed are calculated in terms of
|
||||
// the corresponding _*_used value, so the next two conditions
|
||||
// should hold.
|
||||
assert(_survivor_used <= _survivor_committed, "post-condition");
|
||||
assert(_old_used <= _old_committed, "post-condition");
|
||||
}
|
||||
|
||||
void G1MonitoringSupport::recalculate_eden_size() {
|
||||
// When a new eden region is allocated, only the eden_used size is
|
||||
// affected (since we have recalculated everything else at the last GC).
|
||||
|
||||
uint young_region_num = _g1h->young_regions_count();
|
||||
if (young_region_num > _young_region_num) {
|
||||
uint diff = young_region_num - _young_region_num;
|
||||
_eden_used += (size_t) diff * HeapRegion::GrainBytes;
|
||||
// Somewhat defensive: cap the eden used size to make sure it
|
||||
// never exceeds the committed size.
|
||||
_eden_used = MIN2(_eden_used, _eden_committed);
|
||||
_young_region_num = young_region_num;
|
||||
}
|
||||
assert(_survivor_space_used <= _survivor_space_committed, "post-condition");
|
||||
assert(_old_gen_used <= _old_gen_committed, "post-condition");
|
||||
}
|
||||
|
||||
void G1MonitoringSupport::update_sizes() {
|
||||
recalculate_sizes();
|
||||
if (UsePerfData) {
|
||||
_eden_counters->update_capacity(pad_capacity(eden_space_committed()));
|
||||
_eden_counters->update_used(eden_space_used());
|
||||
// only the "to" survivor space is active, so we don't need to
|
||||
_eden_space_counters->update_capacity(pad_capacity(_eden_space_committed));
|
||||
_eden_space_counters->update_used(_eden_space_used);
|
||||
// only the "to" survivor space is active, so we don't need to
|
||||
// update the counters for the "from" survivor space
|
||||
_to_counters->update_capacity(pad_capacity(survivor_space_committed()));
|
||||
_to_counters->update_used(survivor_space_used());
|
||||
_old_space_counters->update_capacity(pad_capacity(old_space_committed()));
|
||||
_old_space_counters->update_used(old_space_used());
|
||||
_old_collection_counters->update_all();
|
||||
_young_collection_counters->update_all();
|
||||
_to_space_counters->update_capacity(pad_capacity(_survivor_space_committed));
|
||||
_to_space_counters->update_used(_survivor_space_used);
|
||||
_old_space_counters->update_capacity(pad_capacity(_old_gen_committed));
|
||||
_old_space_counters->update_used(_old_gen_used);
|
||||
|
||||
_young_gen_counters->update_all();
|
||||
_old_gen_counters->update_all();
|
||||
|
||||
MetaspaceCounters::update_performance_counters();
|
||||
CompressedClassSpaceCounters::update_performance_counters();
|
||||
}
|
||||
}
|
||||
|
||||
void G1MonitoringSupport::update_eden_size() {
|
||||
recalculate_eden_size();
|
||||
// Recalculate everything - this is fast enough.
|
||||
recalculate_sizes();
|
||||
if (UsePerfData) {
|
||||
_eden_counters->update_used(eden_space_used());
|
||||
_eden_space_counters->update_used(_eden_space_used);
|
||||
}
|
||||
}
|
||||
|
||||
G1MonitoringScope::G1MonitoringScope(G1MonitoringSupport* g1mm, bool full_gc, bool all_memory_pools_affected) :
|
||||
_tcs(full_gc ? g1mm->_full_collection_counters : g1mm->_incremental_collection_counters),
|
||||
_tms(full_gc ? &g1mm->_full_gc_memory_manager : &g1mm->_memory_manager,
|
||||
_tms(full_gc ? &g1mm->_full_gc_memory_manager : &g1mm->_incremental_memory_manager,
|
||||
G1CollectedHeap::heap()->gc_cause(), all_memory_pools_affected) {
|
||||
}
|
||||
|
@ -125,12 +125,12 @@ class G1MonitoringSupport : public CHeapObj<mtGC> {
|
||||
G1CollectedHeap* _g1h;
|
||||
|
||||
// java.lang.management MemoryManager and MemoryPool support
|
||||
GCMemoryManager _memory_manager;
|
||||
GCMemoryManager _incremental_memory_manager;
|
||||
GCMemoryManager _full_gc_memory_manager;
|
||||
|
||||
MemoryPool* _eden_pool;
|
||||
MemoryPool* _survivor_pool;
|
||||
MemoryPool* _old_pool;
|
||||
MemoryPool* _eden_space_pool;
|
||||
MemoryPool* _survivor_space_pool;
|
||||
MemoryPool* _old_gen_pool;
|
||||
|
||||
// jstat performance counters
|
||||
// incremental collections both young and mixed
|
||||
@ -142,37 +142,36 @@ class G1MonitoringSupport : public CHeapObj<mtGC> {
|
||||
// young collection set counters. The _eden_counters,
|
||||
// _from_counters, and _to_counters are associated with
|
||||
// this "generational" counter.
|
||||
GenerationCounters* _young_collection_counters;
|
||||
GenerationCounters* _young_gen_counters;
|
||||
// old collection set counters. The _old_space_counters
|
||||
// below are associated with this "generational" counter.
|
||||
GenerationCounters* _old_collection_counters;
|
||||
GenerationCounters* _old_gen_counters;
|
||||
// Counters for the capacity and used for
|
||||
// the whole heap
|
||||
HSpaceCounters* _old_space_counters;
|
||||
// the young collection
|
||||
HSpaceCounters* _eden_counters;
|
||||
HSpaceCounters* _eden_space_counters;
|
||||
// the survivor collection (only one, _to_counters, is actively used)
|
||||
HSpaceCounters* _from_counters;
|
||||
HSpaceCounters* _to_counters;
|
||||
HSpaceCounters* _from_space_counters;
|
||||
HSpaceCounters* _to_space_counters;
|
||||
|
||||
// When it's appropriate to recalculate the various sizes (at the
|
||||
// end of a GC, when a new eden region is allocated, etc.) we store
|
||||
// them here so that we can easily report them when needed and not
|
||||
// have to recalculate them every time.
|
||||
|
||||
size_t _overall_reserved;
|
||||
size_t _overall_committed;
|
||||
size_t _overall_used;
|
||||
|
||||
uint _young_region_num;
|
||||
size_t _young_gen_committed;
|
||||
size_t _eden_committed;
|
||||
size_t _eden_used;
|
||||
size_t _survivor_committed;
|
||||
size_t _survivor_used;
|
||||
size_t _old_gen_committed;
|
||||
|
||||
size_t _old_committed;
|
||||
size_t _old_used;
|
||||
size_t _eden_space_committed;
|
||||
size_t _eden_space_used;
|
||||
size_t _survivor_space_committed;
|
||||
size_t _survivor_space_used;
|
||||
|
||||
size_t _old_gen_used;
|
||||
|
||||
// It returns x - y if x > y, 0 otherwise.
|
||||
// As described in the comment above, some of the inputs to the
|
||||
@ -191,10 +190,10 @@ class G1MonitoringSupport : public CHeapObj<mtGC> {
|
||||
|
||||
// Recalculate all the sizes.
|
||||
void recalculate_sizes();
|
||||
// Recalculate only what's necessary when a new eden region is allocated.
|
||||
|
||||
void recalculate_eden_size();
|
||||
|
||||
public:
|
||||
public:
|
||||
G1MonitoringSupport(G1CollectedHeap* g1h);
|
||||
~G1MonitoringSupport();
|
||||
|
||||
@ -220,8 +219,7 @@ class G1MonitoringSupport : public CHeapObj<mtGC> {
|
||||
// Recalculate all the sizes from scratch and update all the jstat
|
||||
// counters accordingly.
|
||||
void update_sizes();
|
||||
// Recalculate only what's necessary when a new eden region is
|
||||
// allocated and update any jstat counters that need to be updated.
|
||||
|
||||
void update_eden_size();
|
||||
|
||||
CollectorCounters* conc_collection_counters() {
|
||||
@ -233,21 +231,15 @@ class G1MonitoringSupport : public CHeapObj<mtGC> {
|
||||
// jstat counters
|
||||
// Tracing
|
||||
|
||||
size_t overall_reserved() { return _overall_reserved; }
|
||||
size_t overall_committed() { return _overall_committed; }
|
||||
size_t overall_used() { return _overall_used; }
|
||||
size_t young_gen_committed() { return _young_gen_committed; }
|
||||
|
||||
size_t young_gen_committed() { return _young_gen_committed; }
|
||||
size_t young_gen_max() { return overall_reserved(); }
|
||||
size_t eden_space_committed() { return _eden_committed; }
|
||||
size_t eden_space_used() { return _eden_used; }
|
||||
size_t survivor_space_committed() { return _survivor_committed; }
|
||||
size_t survivor_space_used() { return _survivor_used; }
|
||||
size_t eden_space_committed() { return _eden_space_committed; }
|
||||
size_t eden_space_used() { return _eden_space_used; }
|
||||
size_t survivor_space_committed() { return _survivor_space_committed; }
|
||||
size_t survivor_space_used() { return _survivor_space_used; }
|
||||
|
||||
size_t old_gen_committed() { return old_space_committed(); }
|
||||
size_t old_gen_max() { return overall_reserved(); }
|
||||
size_t old_space_committed() { return _old_committed; }
|
||||
size_t old_space_used() { return _old_used; }
|
||||
size_t old_gen_committed() { return _old_gen_committed; }
|
||||
size_t old_gen_used() { return _old_gen_used; }
|
||||
};
|
||||
|
||||
// Scope object for java.lang.management support.
|
||||
@ -258,27 +250,4 @@ public:
|
||||
G1MonitoringScope(G1MonitoringSupport* g1mm, bool full_gc, bool all_memory_pools_affected);
|
||||
};
|
||||
|
||||
class G1GenerationCounters: public GenerationCounters {
|
||||
protected:
|
||||
G1MonitoringSupport* _g1mm;
|
||||
|
||||
public:
|
||||
G1GenerationCounters(G1MonitoringSupport* g1mm,
|
||||
const char* name, int ordinal, int spaces,
|
||||
size_t min_capacity, size_t max_capacity,
|
||||
size_t curr_capacity);
|
||||
};
|
||||
|
||||
class G1YoungGenerationCounters: public G1GenerationCounters {
|
||||
public:
|
||||
G1YoungGenerationCounters(G1MonitoringSupport* g1mm, const char* name);
|
||||
virtual void update_all();
|
||||
};
|
||||
|
||||
class G1OldGenerationCounters: public G1GenerationCounters {
|
||||
public:
|
||||
G1OldGenerationCounters(G1MonitoringSupport* g1mm, const char* name);
|
||||
virtual void update_all();
|
||||
};
|
||||
|
||||
#endif // SHARE_VM_GC_G1_G1MONITORINGSUPPORT_HPP
|
||||
|
@ -59,12 +59,12 @@
|
||||
nonstatic_field(G1CollectedHeap, _archive_set, HeapRegionSetBase) \
|
||||
nonstatic_field(G1CollectedHeap, _humongous_set, HeapRegionSetBase) \
|
||||
\
|
||||
nonstatic_field(G1MonitoringSupport, _eden_committed, size_t) \
|
||||
nonstatic_field(G1MonitoringSupport, _eden_used, size_t) \
|
||||
nonstatic_field(G1MonitoringSupport, _survivor_committed, size_t) \
|
||||
nonstatic_field(G1MonitoringSupport, _survivor_used, size_t) \
|
||||
nonstatic_field(G1MonitoringSupport, _old_committed, size_t) \
|
||||
nonstatic_field(G1MonitoringSupport, _old_used, size_t) \
|
||||
nonstatic_field(G1MonitoringSupport, _eden_space_committed, size_t) \
|
||||
nonstatic_field(G1MonitoringSupport, _eden_space_used, size_t) \
|
||||
nonstatic_field(G1MonitoringSupport, _survivor_space_committed, size_t) \
|
||||
nonstatic_field(G1MonitoringSupport, _survivor_space_used, size_t) \
|
||||
nonstatic_field(G1MonitoringSupport, _old_gen_committed, size_t) \
|
||||
nonstatic_field(G1MonitoringSupport, _old_gen_used, size_t) \
|
||||
\
|
||||
nonstatic_field(HeapRegionSetBase, _length, uint) \
|
||||
\
|
||||
|
@ -37,18 +37,18 @@ import sun.jvm.hotspot.types.TypeDataBase;
|
||||
// Mirror class for G1MonitoringSupport.
|
||||
|
||||
public class G1MonitoringSupport extends VMObject {
|
||||
// size_t _eden_committed;
|
||||
static private CIntegerField edenCommittedField;
|
||||
// size_t _eden_used;
|
||||
static private CIntegerField edenUsedField;
|
||||
// size_t _survivor_committed;
|
||||
static private CIntegerField survivorCommittedField;
|
||||
// size_t _survivor_used;
|
||||
static private CIntegerField survivorUsedField;
|
||||
// size_t _old_committed;
|
||||
static private CIntegerField oldCommittedField;
|
||||
// size_t _old_used;
|
||||
static private CIntegerField oldUsedField;
|
||||
// size_t _eden_space_committed;
|
||||
static private CIntegerField edenSpaceCommittedField;
|
||||
// size_t _eden_space_used;
|
||||
static private CIntegerField edenSpaceUsedField;
|
||||
// size_t _survivor_space_committed;
|
||||
static private CIntegerField survivorSpaceCommittedField;
|
||||
// size_t _survivor_space_used;
|
||||
static private CIntegerField survivorSpaceUsedField;
|
||||
// size_t _old_gen_committed;
|
||||
static private CIntegerField oldGenCommittedField;
|
||||
// size_t _old_gen_used;
|
||||
static private CIntegerField oldGenUsedField;
|
||||
|
||||
static {
|
||||
VM.registerVMInitializedObserver(new Observer() {
|
||||
@ -61,44 +61,44 @@ public class G1MonitoringSupport extends VMObject {
|
||||
static private synchronized void initialize(TypeDataBase db) {
|
||||
Type type = db.lookupType("G1MonitoringSupport");
|
||||
|
||||
edenCommittedField = type.getCIntegerField("_eden_committed");
|
||||
edenUsedField = type.getCIntegerField("_eden_used");
|
||||
survivorCommittedField = type.getCIntegerField("_survivor_committed");
|
||||
survivorUsedField = type.getCIntegerField("_survivor_used");
|
||||
oldCommittedField = type.getCIntegerField("_old_committed");
|
||||
oldUsedField = type.getCIntegerField("_old_used");
|
||||
edenSpaceCommittedField = type.getCIntegerField("_eden_space_committed");
|
||||
edenSpaceUsedField = type.getCIntegerField("_eden_space_used");
|
||||
survivorSpaceCommittedField = type.getCIntegerField("_survivor_space_committed");
|
||||
survivorSpaceUsedField = type.getCIntegerField("_survivor_space_used");
|
||||
oldGenCommittedField = type.getCIntegerField("_old_gen_committed");
|
||||
oldGenUsedField = type.getCIntegerField("_old_gen_used");
|
||||
}
|
||||
|
||||
public long edenCommitted() {
|
||||
return edenCommittedField.getValue(addr);
|
||||
public long edenSpaceCommitted() {
|
||||
return edenSpaceCommittedField.getValue(addr);
|
||||
}
|
||||
|
||||
public long edenUsed() {
|
||||
return edenUsedField.getValue(addr);
|
||||
public long edenSpaceUsed() {
|
||||
return edenSpaceUsedField.getValue(addr);
|
||||
}
|
||||
|
||||
public long edenRegionNum() {
|
||||
return edenUsed() / HeapRegion.grainBytes();
|
||||
public long edenSpaceRegionNum() {
|
||||
return edenSpaceUsed() / HeapRegion.grainBytes();
|
||||
}
|
||||
|
||||
public long survivorCommitted() {
|
||||
return survivorCommittedField.getValue(addr);
|
||||
public long survivorSpaceCommitted() {
|
||||
return survivorSpaceCommittedField.getValue(addr);
|
||||
}
|
||||
|
||||
public long survivorUsed() {
|
||||
return survivorUsedField.getValue(addr);
|
||||
public long survivorSpaceUsed() {
|
||||
return survivorSpaceUsedField.getValue(addr);
|
||||
}
|
||||
|
||||
public long survivorRegionNum() {
|
||||
return survivorUsed() / HeapRegion.grainBytes();
|
||||
public long survivorSpaceRegionNum() {
|
||||
return survivorSpaceUsed() / HeapRegion.grainBytes();
|
||||
}
|
||||
|
||||
public long oldCommitted() {
|
||||
return oldCommittedField.getValue(addr);
|
||||
public long oldGenCommitted() {
|
||||
return oldGenCommittedField.getValue(addr);
|
||||
}
|
||||
|
||||
public long oldUsed() {
|
||||
return oldUsedField.getValue(addr);
|
||||
public long oldGenUsed() {
|
||||
return oldGenUsedField.getValue(addr);
|
||||
}
|
||||
|
||||
public G1MonitoringSupport(Address addr) {
|
||||
|
@ -225,21 +225,21 @@ public class HeapSummary extends Tool {
|
||||
|
||||
public void printG1HeapSummary(G1CollectedHeap g1h) {
|
||||
G1MonitoringSupport g1mm = g1h.g1mm();
|
||||
long edenRegionNum = g1mm.edenRegionNum();
|
||||
long survivorRegionNum = g1mm.survivorRegionNum();
|
||||
long edenSpaceRegionNum = g1mm.edenSpaceRegionNum();
|
||||
long survivorSpaceRegionNum = g1mm.survivorSpaceRegionNum();
|
||||
HeapRegionSetBase oldSet = g1h.oldSet();
|
||||
HeapRegionSetBase archiveSet = g1h.archiveSet();
|
||||
HeapRegionSetBase humongousSet = g1h.humongousSet();
|
||||
long oldRegionNum = oldSet.length() + archiveSet.length() + humongousSet.length();
|
||||
long oldGenRegionNum = oldSet.length() + archiveSet.length() + humongousSet.length();
|
||||
printG1Space("G1 Heap:", g1h.n_regions(),
|
||||
g1h.used(), g1h.capacity());
|
||||
System.out.println("G1 Young Generation:");
|
||||
printG1Space("Eden Space:", edenRegionNum,
|
||||
g1mm.edenUsed(), g1mm.edenCommitted());
|
||||
printG1Space("Survivor Space:", survivorRegionNum,
|
||||
g1mm.survivorUsed(), g1mm.survivorCommitted());
|
||||
printG1Space("G1 Old Generation:", oldRegionNum,
|
||||
g1mm.oldUsed(), g1mm.oldCommitted());
|
||||
printG1Space("Eden Space:", edenSpaceRegionNum,
|
||||
g1mm.edenSpaceUsed(), g1mm.edenSpaceCommitted());
|
||||
printG1Space("Survivor Space:", survivorSpaceRegionNum,
|
||||
g1mm.survivorSpaceUsed(), g1mm.survivorSpaceCommitted());
|
||||
printG1Space("G1 Old Generation:", oldGenRegionNum,
|
||||
g1mm.oldGenUsed(), g1mm.oldGenCommitted());
|
||||
}
|
||||
|
||||
private void printG1Space(String spaceName, long regionNum,
|
||||
|
Loading…
x
Reference in New Issue
Block a user