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

Wed, 08 Jun 2011 15:31:51 -0400

author
tonyp
date
Wed, 08 Jun 2011 15:31:51 -0400
changeset 2961
053d84a76d3d
parent 2960
e66f38dd58a9
child 2962
ae5b2f1dcf12

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

src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp file | annotate | diff | comparison | revisions
src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp file | annotate | diff | comparison | revisions
src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp file | annotate | diff | comparison | revisions
src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Wed Jun 08 08:39:53 2011 -0700
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Wed Jun 08 15:31:51 2011 -0400
     1.3 @@ -3456,6 +3456,8 @@
     1.4            }
     1.5          }
     1.6        }
     1.7 +      // We have to do this after we decide whether to expand the heap or not.
     1.8 +      g1_policy()->print_heap_transition();
     1.9  
    1.10        if (mark_in_progress()) {
    1.11          concurrent_mark()->update_g1_committed();
     2.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Wed Jun 08 08:39:53 2011 -0700
     2.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Wed Jun 08 15:31:51 2011 -0400
     2.3 @@ -103,6 +103,19 @@
     2.4    size_t       length() { return _length; }
     2.5    size_t       survivor_length() { return _survivor_length; }
     2.6  
     2.7 +  // Currently we do not keep track of the used byte sum for the
     2.8 +  // young list and the survivors and it'd be quite a lot of work to
     2.9 +  // do so. When we'll eventually replace the young list with
    2.10 +  // instances of HeapRegionLinkedList we'll get that for free. So,
    2.11 +  // we'll report the more accurate information then.
    2.12 +  size_t       eden_used_bytes() {
    2.13 +    assert(length() >= survivor_length(), "invariant");
    2.14 +    return (length() - survivor_length()) * HeapRegion::GrainBytes;
    2.15 +  }
    2.16 +  size_t       survivor_used_bytes() {
    2.17 +    return survivor_length() * HeapRegion::GrainBytes;
    2.18 +  }
    2.19 +
    2.20    void rs_length_sampling_init();
    2.21    bool rs_length_sampling_more();
    2.22    void rs_length_sampling_next();
     3.1 --- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Wed Jun 08 08:39:53 2011 -0700
     3.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Wed Jun 08 15:31:51 2011 -0400
     3.3 @@ -239,6 +239,10 @@
     3.4    _should_revert_to_full_young_gcs(false),
     3.5    _last_full_young_gc(false),
     3.6  
     3.7 +  _eden_bytes_before_gc(0),
     3.8 +  _survivor_bytes_before_gc(0),
     3.9 +  _capacity_before_gc(0),
    3.10 +
    3.11    _prev_collection_pause_used_at_end_bytes(0),
    3.12  
    3.13    _collection_set(NULL),
    3.14 @@ -897,6 +901,11 @@
    3.15    _bytes_in_to_space_after_gc = 0;
    3.16    _bytes_in_collection_set_before_gc = 0;
    3.17  
    3.18 +  YoungList* young_list = _g1->young_list();
    3.19 +  _eden_bytes_before_gc = young_list->eden_used_bytes();
    3.20 +  _survivor_bytes_before_gc = young_list->survivor_used_bytes();
    3.21 +  _capacity_before_gc = _g1->capacity();
    3.22 +
    3.23  #ifdef DEBUG
    3.24    // initialise these to something well known so that we can spot
    3.25    // if they are not set properly
    3.26 @@ -1460,14 +1469,6 @@
    3.27        }
    3.28      }
    3.29    }
    3.30 -  if (PrintGCDetails)
    3.31 -    gclog_or_tty->print("   [");
    3.32 -  if (PrintGC || PrintGCDetails)
    3.33 -    _g1->print_size_transition(gclog_or_tty,
    3.34 -                               _cur_collection_pause_used_at_start_bytes,
    3.35 -                               _g1->used(), _g1->capacity());
    3.36 -  if (PrintGCDetails)
    3.37 -    gclog_or_tty->print_cr("]");
    3.38  
    3.39    _all_pause_times_ms->add(elapsed_ms);
    3.40    if (update_stats) {
    3.41 @@ -1672,6 +1673,40 @@
    3.42    // </NEW PREDICTION>
    3.43  }
    3.44  
    3.45 +#define EXT_SIZE_FORMAT "%d%s"
    3.46 +#define EXT_SIZE_PARAMS(bytes)                                  \
    3.47 +  byte_size_in_proper_unit((bytes)),                            \
    3.48 +  proper_unit_for_byte_size((bytes))
    3.49 +
    3.50 +void G1CollectorPolicy::print_heap_transition() {
    3.51 +  if (PrintGCDetails) {
    3.52 +    YoungList* young_list = _g1->young_list();
    3.53 +    size_t eden_bytes = young_list->eden_used_bytes();
    3.54 +    size_t survivor_bytes = young_list->survivor_used_bytes();
    3.55 +    size_t used_before_gc = _cur_collection_pause_used_at_start_bytes;
    3.56 +    size_t used = _g1->used();
    3.57 +    size_t capacity = _g1->capacity();
    3.58 +
    3.59 +    gclog_or_tty->print_cr(
    3.60 +         "   [Eden: "EXT_SIZE_FORMAT"->"EXT_SIZE_FORMAT" "
    3.61 +             "Survivors: "EXT_SIZE_FORMAT"->"EXT_SIZE_FORMAT" "
    3.62 +             "Heap: "EXT_SIZE_FORMAT"("EXT_SIZE_FORMAT")->"
    3.63 +                     EXT_SIZE_FORMAT"("EXT_SIZE_FORMAT")]",
    3.64 +             EXT_SIZE_PARAMS(_eden_bytes_before_gc),
    3.65 +               EXT_SIZE_PARAMS(eden_bytes),
    3.66 +             EXT_SIZE_PARAMS(_survivor_bytes_before_gc),
    3.67 +               EXT_SIZE_PARAMS(survivor_bytes),
    3.68 +             EXT_SIZE_PARAMS(used_before_gc),
    3.69 +             EXT_SIZE_PARAMS(_capacity_before_gc),
    3.70 +               EXT_SIZE_PARAMS(used),
    3.71 +               EXT_SIZE_PARAMS(capacity));
    3.72 +  } else if (PrintGC) {
    3.73 +    _g1->print_size_transition(gclog_or_tty,
    3.74 +                               _cur_collection_pause_used_at_start_bytes,
    3.75 +                               _g1->used(), _g1->capacity());
    3.76 +  }
    3.77 +}
    3.78 +
    3.79  // <NEW PREDICTION>
    3.80  
    3.81  void G1CollectorPolicy::adjust_concurrent_refinement(double update_rs_time,
     4.1 --- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp	Wed Jun 08 08:39:53 2011 -0700
     4.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp	Wed Jun 08 15:31:51 2011 -0400
     4.3 @@ -891,6 +891,7 @@
     4.4    virtual void record_collection_pause_end_G1_strong_roots();
     4.5  
     4.6    virtual void record_collection_pause_end();
     4.7 +  void print_heap_transition();
     4.8  
     4.9    // Record the fact that a full collection occurred.
    4.10    virtual void record_full_collection_start();
    4.11 @@ -1179,6 +1180,11 @@
    4.12    // The limit on the number of regions allocated for survivors.
    4.13    size_t _max_survivor_regions;
    4.14  
    4.15 +  // For reporting purposes.
    4.16 +  size_t _eden_bytes_before_gc;
    4.17 +  size_t _survivor_bytes_before_gc;
    4.18 +  size_t _capacity_before_gc;
    4.19 +
    4.20    // The amount of survor regions after a collection.
    4.21    size_t _recorded_survivor_regions;
    4.22    // List of survivor regions.

mercurial