diff --git a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index a3b60ef8487f8dcfbbd3ebaf230db6c2110686a7..288d63a15f317b11e7ccf7e86b8c69e30c4b320d 100644 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -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()) { concurrent_mark()->update_g1_committed(); diff --git a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp index 4577b27ed7d3e8cd083c496812edc8de48d2f2f2..2062e435da9677815ad537a97774a5b6039cf8be 100644 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @@ -103,6 +103,19 @@ public: size_t length() { return _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(); bool rs_length_sampling_more(); void rs_length_sampling_next(); diff --git a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp index 1421e2d2e57406bced7c1a15f7663efb3b55667d..1895b09f3390e7eda80df5ac487467c896cca3de 100644 --- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp +++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp @@ -239,6 +239,10 @@ G1CollectorPolicy::G1CollectorPolicy() : _should_revert_to_full_young_gcs(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), _collection_set(NULL), @@ -897,6 +901,11 @@ void G1CollectorPolicy::record_collection_pause_start(double start_time_sec, _bytes_in_to_space_after_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 // initialise these to something well known so that we can spot // if they are not set properly @@ -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); if (update_stats) { @@ -1672,6 +1673,40 @@ void G1CollectorPolicy::record_collection_pause_end() { // } +#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()); + } +} + // void G1CollectorPolicy::adjust_concurrent_refinement(double update_rs_time, diff --git a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp index 79c5ee225dbf2f78dfbbbe7ab173065ca4322f6f..c44f6bb02e26b3f7b75851d8b1a5da57c5abce8d 100644 --- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp +++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp @@ -891,6 +891,7 @@ public: virtual void record_collection_pause_end_G1_strong_roots(); virtual void record_collection_pause_end(); + void print_heap_transition(); // Record the fact that a full collection occurred. virtual void record_full_collection_start(); @@ -1179,6 +1180,11 @@ protected: // The limit on the number of regions allocated for survivors. 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. size_t _recorded_survivor_regions; // List of survivor regions.