src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp

changeset 5123
48391ab0687e
parent 5071
f14063dcd52a
child 5237
f2110083203d
     1.1 --- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Thu May 16 13:02:33 2013 +0200
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Thu May 16 09:24:26 2013 -0700
     1.3 @@ -124,9 +124,12 @@
     1.4    _last_young_gc(false),
     1.5    _last_gc_was_young(false),
     1.6  
     1.7 -  _eden_bytes_before_gc(0),
     1.8 -  _survivor_bytes_before_gc(0),
     1.9 -  _capacity_before_gc(0),
    1.10 +  _eden_used_bytes_before_gc(0),
    1.11 +  _survivor_used_bytes_before_gc(0),
    1.12 +  _heap_used_bytes_before_gc(0),
    1.13 +  _metaspace_used_bytes_before_gc(0),
    1.14 +  _eden_capacity_bytes_before_gc(0),
    1.15 +  _heap_capacity_bytes_before_gc(0),
    1.16  
    1.17    _eden_cset_region_length(0),
    1.18    _survivor_cset_region_length(0),
    1.19 @@ -746,7 +749,7 @@
    1.20  
    1.21  void G1CollectorPolicy::record_full_collection_start() {
    1.22    _full_collection_start_sec = os::elapsedTime();
    1.23 -  record_heap_size_info_at_start();
    1.24 +  record_heap_size_info_at_start(true /* full */);
    1.25    // Release the future to-space so that it is available for compaction into.
    1.26    _g1->set_full_collection();
    1.27  }
    1.28 @@ -803,7 +806,7 @@
    1.29    _trace_gen0_time_data.record_start_collection(s_w_t_ms);
    1.30    _stop_world_start = 0.0;
    1.31  
    1.32 -  record_heap_size_info_at_start();
    1.33 +  record_heap_size_info_at_start(false /* full */);
    1.34  
    1.35    phase_times()->record_cur_collection_start_sec(start_time_sec);
    1.36    _pending_cards = _g1->pending_card_num();
    1.37 @@ -938,14 +941,6 @@
    1.38    _mmu_tracker->add_pause(end_time_sec - pause_time_ms/1000.0,
    1.39                            end_time_sec, false);
    1.40  
    1.41 -  size_t freed_bytes =
    1.42 -    _cur_collection_pause_used_at_start_bytes - cur_used_bytes;
    1.43 -  size_t surviving_bytes = _collection_set_bytes_used_before - freed_bytes;
    1.44 -
    1.45 -  double survival_fraction =
    1.46 -    (double)surviving_bytes/
    1.47 -    (double)_collection_set_bytes_used_before;
    1.48 -
    1.49    if (update_stats) {
    1.50      _trace_gen0_time_data.record_end_collection(pause_time_ms, phase_times());
    1.51      // this is where we update the allocation rate of the application
    1.52 @@ -998,6 +993,7 @@
    1.53        }
    1.54      }
    1.55    }
    1.56 +
    1.57    bool new_in_marking_window = _in_marking_window;
    1.58    bool new_in_marking_window_im = false;
    1.59    if (during_initial_mark_pause()) {
    1.60 @@ -1083,8 +1079,10 @@
    1.61      }
    1.62      _rs_length_diff_seq->add((double) rs_length_diff);
    1.63  
    1.64 -    size_t copied_bytes = surviving_bytes;
    1.65 +    size_t freed_bytes = _heap_used_bytes_before_gc - cur_used_bytes;
    1.66 +    size_t copied_bytes = _collection_set_bytes_used_before - freed_bytes;
    1.67      double cost_per_byte_ms = 0.0;
    1.68 +
    1.69      if (copied_bytes > 0) {
    1.70        cost_per_byte_ms = phase_times()->average_last_obj_copy_time() / (double) copied_bytes;
    1.71        if (_in_marking_window) {
    1.72 @@ -1148,51 +1146,61 @@
    1.73    byte_size_in_proper_unit((double)(bytes)),                    \
    1.74    proper_unit_for_byte_size((bytes))
    1.75  
    1.76 -void G1CollectorPolicy::record_heap_size_info_at_start() {
    1.77 +void G1CollectorPolicy::record_heap_size_info_at_start(bool full) {
    1.78    YoungList* young_list = _g1->young_list();
    1.79 -  _eden_bytes_before_gc = young_list->eden_used_bytes();
    1.80 -  _survivor_bytes_before_gc = young_list->survivor_used_bytes();
    1.81 -  _capacity_before_gc = _g1->capacity();
    1.82 -
    1.83 -  _cur_collection_pause_used_at_start_bytes = _g1->used();
    1.84 +  _eden_used_bytes_before_gc = young_list->eden_used_bytes();
    1.85 +  _survivor_used_bytes_before_gc = young_list->survivor_used_bytes();
    1.86 +  _heap_capacity_bytes_before_gc = _g1->capacity();
    1.87 +  _heap_used_bytes_before_gc = _g1->used();
    1.88    _cur_collection_pause_used_regions_at_start = _g1->used_regions();
    1.89  
    1.90 -  size_t eden_capacity_before_gc =
    1.91 -         (_young_list_target_length * HeapRegion::GrainBytes) - _survivor_bytes_before_gc;
    1.92 +  _eden_capacity_bytes_before_gc =
    1.93 +         (_young_list_target_length * HeapRegion::GrainBytes) - _survivor_used_bytes_before_gc;
    1.94  
    1.95 -  _prev_eden_capacity = eden_capacity_before_gc;
    1.96 +  if (full) {
    1.97 +    _metaspace_used_bytes_before_gc = MetaspaceAux::allocated_used_bytes();
    1.98 +  }
    1.99  }
   1.100  
   1.101  void G1CollectorPolicy::print_heap_transition() {
   1.102    _g1->print_size_transition(gclog_or_tty,
   1.103 -    _cur_collection_pause_used_at_start_bytes, _g1->used(), _g1->capacity());
   1.104 +                             _heap_used_bytes_before_gc,
   1.105 +                             _g1->used(),
   1.106 +                             _g1->capacity());
   1.107  }
   1.108  
   1.109 -void G1CollectorPolicy::print_detailed_heap_transition() {
   1.110 -    YoungList* young_list = _g1->young_list();
   1.111 -    size_t eden_bytes = young_list->eden_used_bytes();
   1.112 -    size_t survivor_bytes = young_list->survivor_used_bytes();
   1.113 -    size_t used_before_gc = _cur_collection_pause_used_at_start_bytes;
   1.114 -    size_t used = _g1->used();
   1.115 -    size_t capacity = _g1->capacity();
   1.116 -    size_t eden_capacity =
   1.117 -      (_young_list_target_length * HeapRegion::GrainBytes) - survivor_bytes;
   1.118 +void G1CollectorPolicy::print_detailed_heap_transition(bool full) {
   1.119 +  YoungList* young_list = _g1->young_list();
   1.120  
   1.121 -    gclog_or_tty->print_cr(
   1.122 -      "   [Eden: "EXT_SIZE_FORMAT"("EXT_SIZE_FORMAT")->"EXT_SIZE_FORMAT"("EXT_SIZE_FORMAT") "
   1.123 -      "Survivors: "EXT_SIZE_FORMAT"->"EXT_SIZE_FORMAT" "
   1.124 -      "Heap: "EXT_SIZE_FORMAT"("EXT_SIZE_FORMAT")->"
   1.125 -      EXT_SIZE_FORMAT"("EXT_SIZE_FORMAT")]",
   1.126 -      EXT_SIZE_PARAMS(_eden_bytes_before_gc),
   1.127 -      EXT_SIZE_PARAMS(_prev_eden_capacity),
   1.128 -      EXT_SIZE_PARAMS(eden_bytes),
   1.129 -      EXT_SIZE_PARAMS(eden_capacity),
   1.130 -      EXT_SIZE_PARAMS(_survivor_bytes_before_gc),
   1.131 -      EXT_SIZE_PARAMS(survivor_bytes),
   1.132 -      EXT_SIZE_PARAMS(used_before_gc),
   1.133 -      EXT_SIZE_PARAMS(_capacity_before_gc),
   1.134 -      EXT_SIZE_PARAMS(used),
   1.135 -      EXT_SIZE_PARAMS(capacity));
   1.136 +  size_t eden_used_bytes_after_gc = young_list->eden_used_bytes();
   1.137 +  size_t survivor_used_bytes_after_gc = young_list->survivor_used_bytes();
   1.138 +  size_t heap_used_bytes_after_gc = _g1->used();
   1.139 +
   1.140 +  size_t heap_capacity_bytes_after_gc = _g1->capacity();
   1.141 +  size_t eden_capacity_bytes_after_gc =
   1.142 +    (_young_list_target_length * HeapRegion::GrainBytes) - survivor_used_bytes_after_gc;
   1.143 +
   1.144 +  gclog_or_tty->print(
   1.145 +    "   [Eden: "EXT_SIZE_FORMAT"("EXT_SIZE_FORMAT")->"EXT_SIZE_FORMAT"("EXT_SIZE_FORMAT") "
   1.146 +    "Survivors: "EXT_SIZE_FORMAT"->"EXT_SIZE_FORMAT" "
   1.147 +    "Heap: "EXT_SIZE_FORMAT"("EXT_SIZE_FORMAT")->"
   1.148 +    EXT_SIZE_FORMAT"("EXT_SIZE_FORMAT")]",
   1.149 +    EXT_SIZE_PARAMS(_eden_used_bytes_before_gc),
   1.150 +    EXT_SIZE_PARAMS(_eden_capacity_bytes_before_gc),
   1.151 +    EXT_SIZE_PARAMS(eden_used_bytes_after_gc),
   1.152 +    EXT_SIZE_PARAMS(eden_capacity_bytes_after_gc),
   1.153 +    EXT_SIZE_PARAMS(_survivor_used_bytes_before_gc),
   1.154 +    EXT_SIZE_PARAMS(survivor_used_bytes_after_gc),
   1.155 +    EXT_SIZE_PARAMS(_heap_used_bytes_before_gc),
   1.156 +    EXT_SIZE_PARAMS(_heap_capacity_bytes_before_gc),
   1.157 +    EXT_SIZE_PARAMS(heap_used_bytes_after_gc),
   1.158 +    EXT_SIZE_PARAMS(heap_capacity_bytes_after_gc));
   1.159 +
   1.160 +  if (full) {
   1.161 +    MetaspaceAux::print_metaspace_change(_metaspace_used_bytes_before_gc);
   1.162 +  }
   1.163 +
   1.164 +  gclog_or_tty->cr();
   1.165  }
   1.166  
   1.167  void G1CollectorPolicy::adjust_concurrent_refinement(double update_rs_time,

mercurial