提交 96951cce 编写于 作者: T tonyp

7032531: G1: enhance GC logging to include more accurate eden / survivor size transitions

Summary: This changeset extends the logging information generated by +PrintGCDetails to also print out separate size transitions for the eden, survivors, and old regions.
Reviewed-by: ysr, brutisso
上级 62955820
...@@ -3456,6 +3456,8 @@ G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) { ...@@ -3456,6 +3456,8 @@ G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) {
} }
} }
} }
// We have to do this after we decide whether to expand the heap or not.
g1_policy()->print_heap_transition();
if (mark_in_progress()) { if (mark_in_progress()) {
concurrent_mark()->update_g1_committed(); concurrent_mark()->update_g1_committed();
......
...@@ -103,6 +103,19 @@ public: ...@@ -103,6 +103,19 @@ public:
size_t length() { return _length; } size_t length() { return _length; }
size_t survivor_length() { return _survivor_length; } size_t survivor_length() { return _survivor_length; }
// Currently we do not keep track of the used byte sum for the
// young list and the survivors and it'd be quite a lot of work to
// do so. When we'll eventually replace the young list with
// instances of HeapRegionLinkedList we'll get that for free. So,
// we'll report the more accurate information then.
size_t eden_used_bytes() {
assert(length() >= survivor_length(), "invariant");
return (length() - survivor_length()) * HeapRegion::GrainBytes;
}
size_t survivor_used_bytes() {
return survivor_length() * HeapRegion::GrainBytes;
}
void rs_length_sampling_init(); void rs_length_sampling_init();
bool rs_length_sampling_more(); bool rs_length_sampling_more();
void rs_length_sampling_next(); void rs_length_sampling_next();
......
...@@ -239,6 +239,10 @@ G1CollectorPolicy::G1CollectorPolicy() : ...@@ -239,6 +239,10 @@ G1CollectorPolicy::G1CollectorPolicy() :
_should_revert_to_full_young_gcs(false), _should_revert_to_full_young_gcs(false),
_last_full_young_gc(false), _last_full_young_gc(false),
_eden_bytes_before_gc(0),
_survivor_bytes_before_gc(0),
_capacity_before_gc(0),
_prev_collection_pause_used_at_end_bytes(0), _prev_collection_pause_used_at_end_bytes(0),
_collection_set(NULL), _collection_set(NULL),
...@@ -897,6 +901,11 @@ void G1CollectorPolicy::record_collection_pause_start(double start_time_sec, ...@@ -897,6 +901,11 @@ void G1CollectorPolicy::record_collection_pause_start(double start_time_sec,
_bytes_in_to_space_after_gc = 0; _bytes_in_to_space_after_gc = 0;
_bytes_in_collection_set_before_gc = 0; _bytes_in_collection_set_before_gc = 0;
YoungList* young_list = _g1->young_list();
_eden_bytes_before_gc = young_list->eden_used_bytes();
_survivor_bytes_before_gc = young_list->survivor_used_bytes();
_capacity_before_gc = _g1->capacity();
#ifdef DEBUG #ifdef DEBUG
// initialise these to something well known so that we can spot // initialise these to something well known so that we can spot
// if they are not set properly // if they are not set properly
...@@ -1460,14 +1469,6 @@ void G1CollectorPolicy::record_collection_pause_end() { ...@@ -1460,14 +1469,6 @@ void G1CollectorPolicy::record_collection_pause_end() {
} }
} }
} }
if (PrintGCDetails)
gclog_or_tty->print(" [");
if (PrintGC || PrintGCDetails)
_g1->print_size_transition(gclog_or_tty,
_cur_collection_pause_used_at_start_bytes,
_g1->used(), _g1->capacity());
if (PrintGCDetails)
gclog_or_tty->print_cr("]");
_all_pause_times_ms->add(elapsed_ms); _all_pause_times_ms->add(elapsed_ms);
if (update_stats) { if (update_stats) {
...@@ -1672,6 +1673,40 @@ void G1CollectorPolicy::record_collection_pause_end() { ...@@ -1672,6 +1673,40 @@ void G1CollectorPolicy::record_collection_pause_end() {
// </NEW PREDICTION> // </NEW PREDICTION>
} }
#define EXT_SIZE_FORMAT "%d%s"
#define EXT_SIZE_PARAMS(bytes) \
byte_size_in_proper_unit((bytes)), \
proper_unit_for_byte_size((bytes))
void G1CollectorPolicy::print_heap_transition() {
if (PrintGCDetails) {
YoungList* young_list = _g1->young_list();
size_t eden_bytes = young_list->eden_used_bytes();
size_t survivor_bytes = young_list->survivor_used_bytes();
size_t used_before_gc = _cur_collection_pause_used_at_start_bytes;
size_t used = _g1->used();
size_t capacity = _g1->capacity();
gclog_or_tty->print_cr(
" [Eden: "EXT_SIZE_FORMAT"->"EXT_SIZE_FORMAT" "
"Survivors: "EXT_SIZE_FORMAT"->"EXT_SIZE_FORMAT" "
"Heap: "EXT_SIZE_FORMAT"("EXT_SIZE_FORMAT")->"
EXT_SIZE_FORMAT"("EXT_SIZE_FORMAT")]",
EXT_SIZE_PARAMS(_eden_bytes_before_gc),
EXT_SIZE_PARAMS(eden_bytes),
EXT_SIZE_PARAMS(_survivor_bytes_before_gc),
EXT_SIZE_PARAMS(survivor_bytes),
EXT_SIZE_PARAMS(used_before_gc),
EXT_SIZE_PARAMS(_capacity_before_gc),
EXT_SIZE_PARAMS(used),
EXT_SIZE_PARAMS(capacity));
} else if (PrintGC) {
_g1->print_size_transition(gclog_or_tty,
_cur_collection_pause_used_at_start_bytes,
_g1->used(), _g1->capacity());
}
}
// <NEW PREDICTION> // <NEW PREDICTION>
void G1CollectorPolicy::adjust_concurrent_refinement(double update_rs_time, void G1CollectorPolicy::adjust_concurrent_refinement(double update_rs_time,
......
...@@ -891,6 +891,7 @@ public: ...@@ -891,6 +891,7 @@ public:
virtual void record_collection_pause_end_G1_strong_roots(); virtual void record_collection_pause_end_G1_strong_roots();
virtual void record_collection_pause_end(); virtual void record_collection_pause_end();
void print_heap_transition();
// Record the fact that a full collection occurred. // Record the fact that a full collection occurred.
virtual void record_full_collection_start(); virtual void record_full_collection_start();
...@@ -1179,6 +1180,11 @@ protected: ...@@ -1179,6 +1180,11 @@ protected:
// The limit on the number of regions allocated for survivors. // The limit on the number of regions allocated for survivors.
size_t _max_survivor_regions; size_t _max_survivor_regions;
// For reporting purposes.
size_t _eden_bytes_before_gc;
size_t _survivor_bytes_before_gc;
size_t _capacity_before_gc;
// The amount of survor regions after a collection. // The amount of survor regions after a collection.
size_t _recorded_survivor_regions; size_t _recorded_survivor_regions;
// List of survivor regions. // List of survivor regions.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册