< prev index next >

src/hotspot/share/gc/g1/g1Policy.cpp

Print this page
rev 57039 : imported patch 8227739-merge-scan-rs-update-rs-cost
rev 57040 : imported patch 8227739-sjohanss-review
rev 57044 : imported patch 8227434-g1-predictions-overflow
rev 57051 : imported patch 8233588-cleanup-survrategroup
rev 57053 : imported patch 8231579-incremental-calculation-wrong
rev 57058 : imported patch 8234587-rename-g1survrategroup


  45 #include "logging/logStream.hpp"
  46 #include "runtime/arguments.hpp"
  47 #include "runtime/java.hpp"
  48 #include "runtime/mutexLocker.hpp"
  49 #include "utilities/debug.hpp"
  50 #include "utilities/growableArray.hpp"
  51 #include "utilities/pair.hpp"
  52 
  53 G1Policy::G1Policy(STWGCTimer* gc_timer) :
  54   _predictor(G1ConfidencePercent / 100.0),
  55   _analytics(new G1Analytics(&_predictor)),
  56   _remset_tracker(),
  57   _mmu_tracker(new G1MMUTrackerQueue(GCPauseIntervalMillis / 1000.0, MaxGCPauseMillis / 1000.0)),
  58   _ihop_control(create_ihop_control(&_predictor)),
  59   _policy_counters(new GCPolicyCounters("GarbageFirst", 1, 2)),
  60   _full_collection_start_sec(0.0),
  61   _collection_pause_end_millis(os::javaTimeNanos() / NANOSECS_PER_MILLISEC),
  62   _young_list_target_length(0),
  63   _young_list_fixed_length(0),
  64   _young_list_max_length(0),
  65   _eden_surv_rate_group(new SurvRateGroup()),
  66   _survivor_surv_rate_group(new SurvRateGroup()),
  67   _reserve_factor((double) G1ReservePercent / 100.0),
  68   _reserve_regions(0),
  69   _young_gen_sizer(G1YoungGenSizer::create_gen_sizer()),
  70   _free_regions_at_end_of_collection(0),
  71   _rs_length(0),
  72   _rs_length_prediction(0),
  73   _pending_cards_at_gc_start(0),
  74   _pending_cards_at_prev_gc_end(0),
  75   _total_mutator_refined_cards(0),
  76   _total_concurrent_refined_cards(0),
  77   _total_concurrent_refinement_time(),
  78   _bytes_allocated_in_old_since_last_gc(0),
  79   _initial_mark_to_mixed(),
  80   _collection_set(NULL),
  81   _g1h(NULL),
  82   _phase_times(new G1GCPhaseTimes(gc_timer, ParallelGCThreads)),
  83   _mark_remark_start_sec(0),
  84   _mark_cleanup_start_sec(0),
  85   _tenuring_threshold(MaxTenuringThreshold),
  86   _max_survivor_regions(0),


 443   double full_gc_time_sec = end_sec - _full_collection_start_sec;
 444   double full_gc_time_ms = full_gc_time_sec * 1000.0;
 445 
 446   _analytics->update_recent_gc_times(end_sec, full_gc_time_ms);
 447 
 448   collector_state()->set_in_full_gc(false);
 449 
 450   // "Nuke" the heuristics that control the young/mixed GC
 451   // transitions and make sure we start with young GCs after the Full GC.
 452   collector_state()->set_in_young_only_phase(true);
 453   collector_state()->set_in_young_gc_before_mixed(false);
 454   collector_state()->set_initiate_conc_mark_if_possible(need_to_start_conc_mark("end of Full GC", 0));
 455   collector_state()->set_in_initial_mark_gc(false);
 456   collector_state()->set_mark_or_rebuild_in_progress(false);
 457   collector_state()->set_clearing_next_bitmap(false);
 458 
 459   _eden_surv_rate_group->start_adding_regions();
 460   // also call this on any additional surv rate groups
 461 
 462   _free_regions_at_end_of_collection = _g1h->num_free_regions();
 463   // Reset survivors SurvRateGroup.
 464   _survivor_surv_rate_group->reset();
 465   update_young_list_max_and_target_length();
 466   update_rs_length_prediction();
 467   _pending_cards_at_prev_gc_end = _g1h->pending_card_num();
 468 
 469   _bytes_allocated_in_old_since_last_gc = 0;
 470 
 471   record_pause(FullGC, _full_collection_start_sec, end_sec);
 472 }
 473 
 474 void G1Policy::record_concurrent_refinement_data(bool is_full_collection) {
 475   _pending_cards_at_gc_start = _g1h->pending_card_num();
 476 
 477   // Record info about concurrent refinement thread processing.
 478   G1ConcurrentRefine* cr = _g1h->concurrent_refine();
 479   G1ConcurrentRefine::RefinementStats cr_stats = cr->total_refinement_stats();
 480 
 481   Tickspan cr_time = cr_stats._time - _total_concurrent_refinement_time;
 482   _total_concurrent_refinement_time = cr_stats._time;
 483 


1374     assert(r != NULL, "Region must exist");
1375     prediction_ms += predict_region_total_time_ms(r, false);
1376 
1377     if (prediction_ms > time_remaining_ms) {
1378       log_debug(gc, ergo, cset)("Prediction %.3fms for region %u does not fit remaining time: %.3fms.",
1379                                 prediction_ms, r->hrm_index(), time_remaining_ms);
1380       break;
1381     }
1382     // This region will be included in the next optional evacuation.
1383 
1384     time_remaining_ms -= prediction_ms;
1385     num_optional_regions++;
1386     r = candidates->at(++candidate_idx);
1387   }
1388 
1389   log_debug(gc, ergo, cset)("Prepared %u regions out of %u for optional evacuation. Predicted time: %.3fms",
1390                             num_optional_regions, max_optional_regions, prediction_ms);
1391 }
1392 
1393 void G1Policy::transfer_survivors_to_cset(const G1SurvivorRegions* survivors) {
1394 
1395   // Add survivor regions to SurvRateGroup.
1396   note_start_adding_survivor_regions();
1397 
1398   HeapRegion* last = NULL;
1399   for (GrowableArrayIterator<HeapRegion*> it = survivors->regions()->begin();
1400        it != survivors->regions()->end();
1401        ++it) {
1402     HeapRegion* curr = *it;
1403     set_region_survivor(curr);
1404 
1405     // The region is a non-empty survivor so let's add it to
1406     // the incremental collection set for the next evacuation
1407     // pause.
1408     _collection_set->add_survivor_regions(curr);
1409 
1410     last = curr;
1411   }
1412   note_stop_adding_survivor_regions();
1413 
1414   // Don't clear the survivor list handles until the start of
1415   // the next evacuation pause - we need it in order to re-tag


  45 #include "logging/logStream.hpp"
  46 #include "runtime/arguments.hpp"
  47 #include "runtime/java.hpp"
  48 #include "runtime/mutexLocker.hpp"
  49 #include "utilities/debug.hpp"
  50 #include "utilities/growableArray.hpp"
  51 #include "utilities/pair.hpp"
  52 
  53 G1Policy::G1Policy(STWGCTimer* gc_timer) :
  54   _predictor(G1ConfidencePercent / 100.0),
  55   _analytics(new G1Analytics(&_predictor)),
  56   _remset_tracker(),
  57   _mmu_tracker(new G1MMUTrackerQueue(GCPauseIntervalMillis / 1000.0, MaxGCPauseMillis / 1000.0)),
  58   _ihop_control(create_ihop_control(&_predictor)),
  59   _policy_counters(new GCPolicyCounters("GarbageFirst", 1, 2)),
  60   _full_collection_start_sec(0.0),
  61   _collection_pause_end_millis(os::javaTimeNanos() / NANOSECS_PER_MILLISEC),
  62   _young_list_target_length(0),
  63   _young_list_fixed_length(0),
  64   _young_list_max_length(0),
  65   _eden_surv_rate_group(new G1SurvRateGroup()),
  66   _survivor_surv_rate_group(new G1SurvRateGroup()),
  67   _reserve_factor((double) G1ReservePercent / 100.0),
  68   _reserve_regions(0),
  69   _young_gen_sizer(G1YoungGenSizer::create_gen_sizer()),
  70   _free_regions_at_end_of_collection(0),
  71   _rs_length(0),
  72   _rs_length_prediction(0),
  73   _pending_cards_at_gc_start(0),
  74   _pending_cards_at_prev_gc_end(0),
  75   _total_mutator_refined_cards(0),
  76   _total_concurrent_refined_cards(0),
  77   _total_concurrent_refinement_time(),
  78   _bytes_allocated_in_old_since_last_gc(0),
  79   _initial_mark_to_mixed(),
  80   _collection_set(NULL),
  81   _g1h(NULL),
  82   _phase_times(new G1GCPhaseTimes(gc_timer, ParallelGCThreads)),
  83   _mark_remark_start_sec(0),
  84   _mark_cleanup_start_sec(0),
  85   _tenuring_threshold(MaxTenuringThreshold),
  86   _max_survivor_regions(0),


 443   double full_gc_time_sec = end_sec - _full_collection_start_sec;
 444   double full_gc_time_ms = full_gc_time_sec * 1000.0;
 445 
 446   _analytics->update_recent_gc_times(end_sec, full_gc_time_ms);
 447 
 448   collector_state()->set_in_full_gc(false);
 449 
 450   // "Nuke" the heuristics that control the young/mixed GC
 451   // transitions and make sure we start with young GCs after the Full GC.
 452   collector_state()->set_in_young_only_phase(true);
 453   collector_state()->set_in_young_gc_before_mixed(false);
 454   collector_state()->set_initiate_conc_mark_if_possible(need_to_start_conc_mark("end of Full GC", 0));
 455   collector_state()->set_in_initial_mark_gc(false);
 456   collector_state()->set_mark_or_rebuild_in_progress(false);
 457   collector_state()->set_clearing_next_bitmap(false);
 458 
 459   _eden_surv_rate_group->start_adding_regions();
 460   // also call this on any additional surv rate groups
 461 
 462   _free_regions_at_end_of_collection = _g1h->num_free_regions();

 463   _survivor_surv_rate_group->reset();
 464   update_young_list_max_and_target_length();
 465   update_rs_length_prediction();
 466   _pending_cards_at_prev_gc_end = _g1h->pending_card_num();
 467 
 468   _bytes_allocated_in_old_since_last_gc = 0;
 469 
 470   record_pause(FullGC, _full_collection_start_sec, end_sec);
 471 }
 472 
 473 void G1Policy::record_concurrent_refinement_data(bool is_full_collection) {
 474   _pending_cards_at_gc_start = _g1h->pending_card_num();
 475 
 476   // Record info about concurrent refinement thread processing.
 477   G1ConcurrentRefine* cr = _g1h->concurrent_refine();
 478   G1ConcurrentRefine::RefinementStats cr_stats = cr->total_refinement_stats();
 479 
 480   Tickspan cr_time = cr_stats._time - _total_concurrent_refinement_time;
 481   _total_concurrent_refinement_time = cr_stats._time;
 482 


1373     assert(r != NULL, "Region must exist");
1374     prediction_ms += predict_region_total_time_ms(r, false);
1375 
1376     if (prediction_ms > time_remaining_ms) {
1377       log_debug(gc, ergo, cset)("Prediction %.3fms for region %u does not fit remaining time: %.3fms.",
1378                                 prediction_ms, r->hrm_index(), time_remaining_ms);
1379       break;
1380     }
1381     // This region will be included in the next optional evacuation.
1382 
1383     time_remaining_ms -= prediction_ms;
1384     num_optional_regions++;
1385     r = candidates->at(++candidate_idx);
1386   }
1387 
1388   log_debug(gc, ergo, cset)("Prepared %u regions out of %u for optional evacuation. Predicted time: %.3fms",
1389                             num_optional_regions, max_optional_regions, prediction_ms);
1390 }
1391 
1392 void G1Policy::transfer_survivors_to_cset(const G1SurvivorRegions* survivors) {


1393   note_start_adding_survivor_regions();
1394 
1395   HeapRegion* last = NULL;
1396   for (GrowableArrayIterator<HeapRegion*> it = survivors->regions()->begin();
1397        it != survivors->regions()->end();
1398        ++it) {
1399     HeapRegion* curr = *it;
1400     set_region_survivor(curr);
1401 
1402     // The region is a non-empty survivor so let's add it to
1403     // the incremental collection set for the next evacuation
1404     // pause.
1405     _collection_set->add_survivor_regions(curr);
1406 
1407     last = curr;
1408   }
1409   note_stop_adding_survivor_regions();
1410 
1411   // Don't clear the survivor list handles until the start of
1412   // the next evacuation pause - we need it in order to re-tag
< prev index next >