< prev index next >

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

Print this page
rev 9595 : 8143215: gcc 4.1.2: fix three issues breaking the build.
Reviewed-by: stuefe, simonis


 471   size_t bytes_to_copy =
 472                (size_t) (accum_surv_rate * (double) HeapRegion::GrainBytes);
 473   double copy_time_ms = predict_object_copy_time_ms(bytes_to_copy);
 474   double young_other_time_ms = predict_young_other_time_ms(young_length);
 475   double pause_time_ms = base_time_ms + copy_time_ms + young_other_time_ms;
 476   if (pause_time_ms > target_pause_time_ms) {
 477     // end condition 2: prediction is over the target pause time
 478     return false;
 479   }
 480 
 481   size_t free_bytes = (base_free_regions - young_length) * HeapRegion::GrainBytes;
 482 
 483   // When copying, we will likely need more bytes free than is live in the region.
 484   // Add some safety margin to factor in the confidence of our guess, and the
 485   // natural expected waste.
 486   // (100.0 / G1ConfidencePercent) is a scale factor that expresses the uncertainty
 487   // of the calculation: the lower the confidence, the more headroom.
 488   // (100 + TargetPLABWastePct) represents the increase in expected bytes during
 489   // copying due to anticipated waste in the PLABs.
 490   double safety_factor = (100.0 / G1ConfidencePercent) * (100 + TargetPLABWastePct) / 100.0;
 491   size_t expected_bytes_to_copy = safety_factor * bytes_to_copy;
 492 
 493   if (expected_bytes_to_copy > free_bytes) {
 494     // end condition 3: out-of-space
 495     return false;
 496   }
 497 
 498   // success!
 499   return true;
 500 }
 501 
 502 void G1CollectorPolicy::record_new_heap_size(uint new_number_of_regions) {
 503   // re-calculate the necessary reserve
 504   double reserve_regions_d = (double) new_number_of_regions * _reserve_factor;
 505   // We use ceiling so that if reserve_regions_d is > 0.0 (but
 506   // smaller than 1.0) we'll get 1.
 507   _reserve_regions = (uint) ceil(reserve_regions_d);
 508 
 509   _young_gen_sizer->heap_size_changed(new_number_of_regions);
 510 }
 511 


 518       double when_ms = _mmu_tracker->when_max_gc_sec(now_sec) * 1000.0;
 519       double alloc_rate_ms = predict_alloc_rate_ms();
 520       desired_min_length = (uint) ceil(alloc_rate_ms * when_ms);
 521     } else {
 522       // otherwise we don't have enough info to make the prediction
 523     }
 524   }
 525   desired_min_length += base_min_length;
 526   // make sure we don't go below any user-defined minimum bound
 527   return MAX2(_young_gen_sizer->min_desired_young_length(), desired_min_length);
 528 }
 529 
 530 uint G1CollectorPolicy::calculate_young_list_desired_max_length() const {
 531   // Here, we might want to also take into account any additional
 532   // constraints (i.e., user-defined minimum bound). Currently, we
 533   // effectively don't set this bound.
 534   return _young_gen_sizer->max_desired_young_length();
 535 }
 536 
 537 uint G1CollectorPolicy::update_young_list_max_and_target_length() {
 538   return update_young_list_max_and_target_length(get_new_prediction(_rs_lengths_seq));
 539 }
 540 
 541 uint G1CollectorPolicy::update_young_list_max_and_target_length(size_t rs_lengths) {
 542   uint unbounded_target_length = update_young_list_target_length(rs_lengths);
 543   update_max_gc_locker_expansion();
 544   return unbounded_target_length;
 545 }
 546 
 547 uint G1CollectorPolicy::update_young_list_target_length(size_t rs_lengths) {
 548   YoungTargetLengths young_lengths = young_list_target_lengths(rs_lengths);
 549   _young_list_target_length = young_lengths.first;
 550   return young_lengths.second;
 551 }
 552 
 553 G1CollectorPolicy::YoungTargetLengths G1CollectorPolicy::young_list_target_lengths(size_t rs_lengths) const {
 554   YoungTargetLengths result;
 555 
 556   // Calculate the absolute and desired min bounds first.
 557 
 558   // This is how many young regions we already have (currently: the survivors).


 726        r = r->get_next_young_region()) {
 727     survivor_regions_evac_time += predict_region_elapsed_time_ms(r, collector_state()->gcs_are_young());
 728   }
 729   return survivor_regions_evac_time;
 730 }
 731 
 732 void G1CollectorPolicy::revise_young_list_target_length_if_necessary() {
 733   guarantee( adaptive_young_list_length(), "should not call this otherwise" );
 734 
 735   size_t rs_lengths = _g1->young_list()->sampled_rs_lengths();
 736   if (rs_lengths > _rs_lengths_prediction) {
 737     // add 10% to avoid having to recalculate often
 738     size_t rs_lengths_prediction = rs_lengths * 1100 / 1000;
 739     update_rs_lengths_prediction(rs_lengths_prediction);
 740 
 741     update_young_list_max_and_target_length(rs_lengths_prediction);
 742   }
 743 }
 744 
 745 void G1CollectorPolicy::update_rs_lengths_prediction() {
 746   update_rs_lengths_prediction(get_new_prediction(_rs_lengths_seq));
 747 }
 748 
 749 void G1CollectorPolicy::update_rs_lengths_prediction(size_t prediction) {
 750   if (collector_state()->gcs_are_young() && adaptive_young_list_length()) {
 751     _rs_lengths_prediction = prediction;
 752   }
 753 }
 754 
 755 HeapWord* G1CollectorPolicy::mem_allocate_work(size_t size,
 756                                                bool is_tlab,
 757                                                bool* gc_overhead_limit_was_exceeded) {
 758   guarantee(false, "Not using this policy feature yet.");
 759   return NULL;
 760 }
 761 
 762 // This method controls how a collector handles one or more
 763 // of its generations being fully allocated.
 764 HeapWord* G1CollectorPolicy::satisfy_failed_allocation(size_t size,
 765                                                        bool is_tlab) {
 766   guarantee(false, "Not using this policy feature yet.");




 471   size_t bytes_to_copy =
 472                (size_t) (accum_surv_rate * (double) HeapRegion::GrainBytes);
 473   double copy_time_ms = predict_object_copy_time_ms(bytes_to_copy);
 474   double young_other_time_ms = predict_young_other_time_ms(young_length);
 475   double pause_time_ms = base_time_ms + copy_time_ms + young_other_time_ms;
 476   if (pause_time_ms > target_pause_time_ms) {
 477     // end condition 2: prediction is over the target pause time
 478     return false;
 479   }
 480 
 481   size_t free_bytes = (base_free_regions - young_length) * HeapRegion::GrainBytes;
 482 
 483   // When copying, we will likely need more bytes free than is live in the region.
 484   // Add some safety margin to factor in the confidence of our guess, and the
 485   // natural expected waste.
 486   // (100.0 / G1ConfidencePercent) is a scale factor that expresses the uncertainty
 487   // of the calculation: the lower the confidence, the more headroom.
 488   // (100 + TargetPLABWastePct) represents the increase in expected bytes during
 489   // copying due to anticipated waste in the PLABs.
 490   double safety_factor = (100.0 / G1ConfidencePercent) * (100 + TargetPLABWastePct) / 100.0;
 491   size_t expected_bytes_to_copy = (size_t)(safety_factor * bytes_to_copy);
 492 
 493   if (expected_bytes_to_copy > free_bytes) {
 494     // end condition 3: out-of-space
 495     return false;
 496   }
 497 
 498   // success!
 499   return true;
 500 }
 501 
 502 void G1CollectorPolicy::record_new_heap_size(uint new_number_of_regions) {
 503   // re-calculate the necessary reserve
 504   double reserve_regions_d = (double) new_number_of_regions * _reserve_factor;
 505   // We use ceiling so that if reserve_regions_d is > 0.0 (but
 506   // smaller than 1.0) we'll get 1.
 507   _reserve_regions = (uint) ceil(reserve_regions_d);
 508 
 509   _young_gen_sizer->heap_size_changed(new_number_of_regions);
 510 }
 511 


 518       double when_ms = _mmu_tracker->when_max_gc_sec(now_sec) * 1000.0;
 519       double alloc_rate_ms = predict_alloc_rate_ms();
 520       desired_min_length = (uint) ceil(alloc_rate_ms * when_ms);
 521     } else {
 522       // otherwise we don't have enough info to make the prediction
 523     }
 524   }
 525   desired_min_length += base_min_length;
 526   // make sure we don't go below any user-defined minimum bound
 527   return MAX2(_young_gen_sizer->min_desired_young_length(), desired_min_length);
 528 }
 529 
 530 uint G1CollectorPolicy::calculate_young_list_desired_max_length() const {
 531   // Here, we might want to also take into account any additional
 532   // constraints (i.e., user-defined minimum bound). Currently, we
 533   // effectively don't set this bound.
 534   return _young_gen_sizer->max_desired_young_length();
 535 }
 536 
 537 uint G1CollectorPolicy::update_young_list_max_and_target_length() {
 538   return update_young_list_max_and_target_length((size_t)get_new_prediction(_rs_lengths_seq));
 539 }
 540 
 541 uint G1CollectorPolicy::update_young_list_max_and_target_length(size_t rs_lengths) {
 542   uint unbounded_target_length = update_young_list_target_length(rs_lengths);
 543   update_max_gc_locker_expansion();
 544   return unbounded_target_length;
 545 }
 546 
 547 uint G1CollectorPolicy::update_young_list_target_length(size_t rs_lengths) {
 548   YoungTargetLengths young_lengths = young_list_target_lengths(rs_lengths);
 549   _young_list_target_length = young_lengths.first;
 550   return young_lengths.second;
 551 }
 552 
 553 G1CollectorPolicy::YoungTargetLengths G1CollectorPolicy::young_list_target_lengths(size_t rs_lengths) const {
 554   YoungTargetLengths result;
 555 
 556   // Calculate the absolute and desired min bounds first.
 557 
 558   // This is how many young regions we already have (currently: the survivors).


 726        r = r->get_next_young_region()) {
 727     survivor_regions_evac_time += predict_region_elapsed_time_ms(r, collector_state()->gcs_are_young());
 728   }
 729   return survivor_regions_evac_time;
 730 }
 731 
 732 void G1CollectorPolicy::revise_young_list_target_length_if_necessary() {
 733   guarantee( adaptive_young_list_length(), "should not call this otherwise" );
 734 
 735   size_t rs_lengths = _g1->young_list()->sampled_rs_lengths();
 736   if (rs_lengths > _rs_lengths_prediction) {
 737     // add 10% to avoid having to recalculate often
 738     size_t rs_lengths_prediction = rs_lengths * 1100 / 1000;
 739     update_rs_lengths_prediction(rs_lengths_prediction);
 740 
 741     update_young_list_max_and_target_length(rs_lengths_prediction);
 742   }
 743 }
 744 
 745 void G1CollectorPolicy::update_rs_lengths_prediction() {
 746   update_rs_lengths_prediction((size_t)get_new_prediction(_rs_lengths_seq));
 747 }
 748 
 749 void G1CollectorPolicy::update_rs_lengths_prediction(size_t prediction) {
 750   if (collector_state()->gcs_are_young() && adaptive_young_list_length()) {
 751     _rs_lengths_prediction = prediction;
 752   }
 753 }
 754 
 755 HeapWord* G1CollectorPolicy::mem_allocate_work(size_t size,
 756                                                bool is_tlab,
 757                                                bool* gc_overhead_limit_was_exceeded) {
 758   guarantee(false, "Not using this policy feature yet.");
 759   return NULL;
 760 }
 761 
 762 // This method controls how a collector handles one or more
 763 // of its generations being fully allocated.
 764 HeapWord* G1CollectorPolicy::satisfy_failed_allocation(size_t size,
 765                                                        bool is_tlab) {
 766   guarantee(false, "Not using this policy feature yet.");


< prev index next >