Print this page


Split Split Close
Expand all
Collapse all
          --- old/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp
          +++ new/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp
   1    1  /*
   2      - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
        2 + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
   3    3   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4    4   *
   5    5   * This code is free software; you can redistribute it and/or modify it
   6    6   * under the terms of the GNU General Public License version 2 only, as
   7    7   * published by the Free Software Foundation.
   8    8   *
   9    9   * This code is distributed in the hope that it will be useful, but WITHOUT
  10   10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11   11   * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12   12   * version 2 for more details (a copy is included in the LICENSE file that
↓ open down ↓ 386 lines elided ↑ open up ↑
 399  399  
 400  400    initialize_gc_policy_counters();
 401  401  
 402  402    if (adaptive_young_list_length()) {
 403  403      _young_list_fixed_length = 0;
 404  404    } else {
 405  405      _young_list_fixed_length = _young_gen_sizer->min_desired_young_length();
 406  406    }
 407  407    _free_regions_at_end_of_collection = _g1->free_regions();
 408  408    update_young_list_target_length();
 409      -  _prev_eden_capacity = _young_list_target_length * HeapRegion::GrainBytes;
 410  409  
 411  410    // We may immediately start allocating regions and placing them on the
 412  411    // collection set list. Initialize the per-collection set info
 413  412    start_incremental_cset_building();
 414  413  }
 415  414  
 416  415  // Create the jstat counters for the policy.
 417  416  void G1CollectorPolicy::initialize_gc_policy_counters() {
 418  417    _gc_policy_counters = new GCPolicyCounters("GarbageFirst", 1, 3);
 419  418  }
↓ open down ↓ 319 lines elided ↑ open up ↑
 739  738        prev_age = age;
 740  739      }
 741  740    }
 742  741  
 743  742    return ret;
 744  743  }
 745  744  #endif // PRODUCT
 746  745  
 747  746  void G1CollectorPolicy::record_full_collection_start() {
 748  747    _full_collection_start_sec = os::elapsedTime();
      748 +  record_heap_size_info_at_start();
 749  749    // Release the future to-space so that it is available for compaction into.
 750  750    _g1->set_full_collection();
 751  751  }
 752  752  
 753  753  void G1CollectorPolicy::record_full_collection_end() {
 754  754    // Consider this like a collection pause for the purposes of allocation
 755  755    // since last pause.
 756  756    double end_sec = os::elapsedTime();
 757  757    double full_gc_time_sec = end_sec - _full_collection_start_sec;
 758  758    double full_gc_time_ms = full_gc_time_sec * 1000.0;
↓ open down ↓ 22 lines elided ↑ open up ↑
 781  781    // Reset survivors SurvRateGroup.
 782  782    _survivor_surv_rate_group->reset();
 783  783    update_young_list_target_length();
 784  784    _collectionSetChooser->clear();
 785  785  }
 786  786  
 787  787  void G1CollectorPolicy::record_stop_world_start() {
 788  788    _stop_world_start = os::elapsedTime();
 789  789  }
 790  790  
 791      -void G1CollectorPolicy::record_collection_pause_start(double start_time_sec,
 792      -                                                      size_t start_used) {
      791 +void G1CollectorPolicy::record_collection_pause_start(double start_time_sec) {
 793  792    // We only need to do this here as the policy will only be applied
 794  793    // to the GC we're about to start. so, no point is calculating this
 795  794    // every time we calculate / recalculate the target young length.
 796  795    update_survivors_policy();
 797  796  
 798  797    assert(_g1->used() == _g1->recalculate_used(),
 799  798           err_msg("sanity, used: "SIZE_FORMAT" recalculate_used: "SIZE_FORMAT,
 800  799                   _g1->used(), _g1->recalculate_used()));
 801  800  
 802  801    double s_w_t_ms = (start_time_sec - _stop_world_start) * 1000.0;
 803  802    _trace_gen0_time_data.record_start_collection(s_w_t_ms);
 804  803    _stop_world_start = 0.0;
 805  804  
      805 +  record_heap_size_info_at_start();
      806 +
 806  807    phase_times()->record_cur_collection_start_sec(start_time_sec);
 807      -  _cur_collection_pause_used_at_start_bytes = start_used;
 808      -  _cur_collection_pause_used_regions_at_start = _g1->used_regions();
 809  808    _pending_cards = _g1->pending_card_num();
 810  809  
 811  810    _collection_set_bytes_used_before = 0;
 812  811    _bytes_copied_during_gc = 0;
 813  812  
 814      -  YoungList* young_list = _g1->young_list();
 815      -  _eden_bytes_before_gc = young_list->eden_used_bytes();
 816      -  _survivor_bytes_before_gc = young_list->survivor_used_bytes();
 817      -  _capacity_before_gc = _g1->capacity();
 818      -
 819  813    _last_gc_was_young = false;
 820  814  
 821  815    // do that for any other surv rate groups
 822  816    _short_lived_surv_rate_group->stop_adding_regions();
 823  817    _survivors_age_table.clear();
 824  818  
 825  819    assert( verify_young_ages(), "region age verification" );
 826  820  }
 827  821  
 828  822  void G1CollectorPolicy::record_concurrent_mark_init_end(double
↓ open down ↓ 320 lines elided ↑ open up ↑
1149 1143                                 phase_times()->sum_last_update_rs_processed_buffers(), update_rs_time_goal_ms);
1150 1144  
1151 1145    _collectionSetChooser->verify();
1152 1146  }
1153 1147  
1154 1148  #define EXT_SIZE_FORMAT "%.1f%s"
1155 1149  #define EXT_SIZE_PARAMS(bytes)                                  \
1156 1150    byte_size_in_proper_unit((double)(bytes)),                    \
1157 1151    proper_unit_for_byte_size((bytes))
1158 1152  
     1153 +void G1CollectorPolicy::record_heap_size_info_at_start() {
     1154 +  YoungList* young_list = _g1->young_list();
     1155 +  _eden_bytes_before_gc = young_list->eden_used_bytes();
     1156 +  _survivor_bytes_before_gc = young_list->survivor_used_bytes();
     1157 +  _capacity_before_gc = _g1->capacity();
     1158 +
     1159 +  _cur_collection_pause_used_at_start_bytes = _g1->used();
     1160 +  _cur_collection_pause_used_regions_at_start = _g1->used_regions();
     1161 +
     1162 +  size_t eden_capacity_before_gc =
     1163 +         (_young_list_target_length * HeapRegion::GrainBytes) - _survivor_bytes_before_gc;
     1164 +
     1165 +  _prev_eden_capacity = eden_capacity_before_gc;
     1166 +}
     1167 +
1159 1168  void G1CollectorPolicy::print_heap_transition() {
1160 1169    _g1->print_size_transition(gclog_or_tty,
1161 1170      _cur_collection_pause_used_at_start_bytes, _g1->used(), _g1->capacity());
1162 1171  }
1163 1172  
1164 1173  void G1CollectorPolicy::print_detailed_heap_transition() {
1165 1174      YoungList* young_list = _g1->young_list();
1166 1175      size_t eden_bytes = young_list->eden_used_bytes();
1167 1176      size_t survivor_bytes = young_list->survivor_used_bytes();
1168 1177      size_t used_before_gc = _cur_collection_pause_used_at_start_bytes;
↓ open down ↓ 10 lines elided ↑ open up ↑
1179 1188        EXT_SIZE_PARAMS(_eden_bytes_before_gc),
1180 1189        EXT_SIZE_PARAMS(_prev_eden_capacity),
1181 1190        EXT_SIZE_PARAMS(eden_bytes),
1182 1191        EXT_SIZE_PARAMS(eden_capacity),
1183 1192        EXT_SIZE_PARAMS(_survivor_bytes_before_gc),
1184 1193        EXT_SIZE_PARAMS(survivor_bytes),
1185 1194        EXT_SIZE_PARAMS(used_before_gc),
1186 1195        EXT_SIZE_PARAMS(_capacity_before_gc),
1187 1196        EXT_SIZE_PARAMS(used),
1188 1197        EXT_SIZE_PARAMS(capacity));
1189      -
1190      -    _prev_eden_capacity = eden_capacity;
1191 1198  }
1192 1199  
1193 1200  void G1CollectorPolicy::adjust_concurrent_refinement(double update_rs_time,
1194 1201                                                       double update_rs_processed_buffers,
1195 1202                                                       double goal_ms) {
1196 1203    DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
1197 1204    ConcurrentG1Refine *cg1r = G1CollectedHeap::heap()->concurrent_g1_refine();
1198 1205  
1199 1206    if (G1UseAdaptiveConcRefinement) {
1200 1207      const int k_gy = 3, k_gr = 6;
↓ open down ↓ 1028 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX