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

Print this page
rev 3486 : 7185699: G1: Prediction model discrepancies
Summary: Correct the result value of G1CollectedHeap::pending_card_num(). Change the code that calculates the GC efficiency of a non-young heap region to use historical data from mixed GCs and the actual number of live bytes when predicting how long it would take to collect the region.
Reviewed-by:


 478   double predict_yg_surv_rate(int age, SurvRateGroup* surv_rate_group) {
 479     TruncatedSeq* seq = surv_rate_group->get_seq(age);
 480     if (seq->num() == 0)
 481       gclog_or_tty->print("BARF! age is %d", age);
 482     guarantee( seq->num() > 0, "invariant" );
 483     double pred = get_new_prediction(seq);
 484     if (pred > 1.0)
 485       pred = 1.0;
 486     return pred;
 487   }
 488 
 489   double predict_yg_surv_rate(int age) {
 490     return predict_yg_surv_rate(age, _short_lived_surv_rate_group);
 491   }
 492 
 493   double accum_yg_surv_rate_pred(int age) {
 494     return _short_lived_surv_rate_group->accum_surv_rate_pred(age);
 495   }
 496 
 497 private:
 498   size_t _bytes_in_collection_set_before_gc;
 499   size_t _bytes_copied_during_gc;
 500 
 501   // Used to count used bytes in CS.
 502   friend class CountCSClosure;
 503 
 504   // Statistics kept per GC stoppage, pause or full.
 505   TruncatedSeq* _recent_prev_end_times_for_all_gcs_sec;
 506 
 507   // Add a new GC of the given duration and end time to the record.
 508   void update_recent_gc_times(double end_time_sec, double elapsed_ms);
 509 
 510   // The head of the list (via "next_in_collection_set()") representing the
 511   // current collection set. Set from the incrementally built collection
 512   // set at the start of the pause.
 513   HeapRegion* _collection_set;
 514 
 515   // The number of bytes in the collection set before the pause. Set from
 516   // the incrementally built collection set at the start of an evacuation
 517   // pause.

 518   size_t _collection_set_bytes_used_before;
 519 



 520   // The associated information that is maintained while the incremental
 521   // collection set is being built with young regions. Used to populate
 522   // the recorded info for the evacuation pause.
 523 
 524   enum CSetBuildType {
 525     Active,             // We are actively building the collection set
 526     Inactive            // We are not actively building the collection set
 527   };
 528 
 529   CSetBuildType _inc_cset_build_state;
 530 
 531   // The head of the incrementally built collection set.
 532   HeapRegion* _inc_cset_head;
 533 
 534   // The tail of the incrementally built collection set.
 535   HeapRegion* _inc_cset_tail;
 536 
 537   // The number of bytes in the incrementally built collection set.
 538   // Used to set _collection_set_bytes_used_before at the start of
 539   // an evacuation pause.


 629 
 630   // Calculate and return the maximum young list target length that
 631   // can fit into the pause time goal. The parameters are: rs_lengths
 632   // represent the prediction of how large the young RSet lengths will
 633   // be, base_min_length is the alreay existing number of regions in
 634   // the young list, min_length and max_length are the desired min and
 635   // max young list length according to the user's inputs.
 636   uint calculate_young_list_target_length(size_t rs_lengths,
 637                                           uint base_min_length,
 638                                           uint desired_min_length,
 639                                           uint desired_max_length);
 640 
 641   // Check whether a given young length (young_length) fits into the
 642   // given target pause time and whether the prediction for the amount
 643   // of objects to be copied for the given length will fit into the
 644   // given free space (expressed by base_free_regions).  It is used by
 645   // calculate_young_list_target_length().
 646   bool predict_will_fit(uint young_length, double base_time_ms,
 647                         uint base_free_regions, double target_pause_time_ms);
 648 
 649   // Count the number of bytes used in the CS.
 650   void count_CS_bytes_used();
 651 
 652 public:
 653 
 654   G1CollectorPolicy();
 655 
 656   virtual G1CollectorPolicy* as_g1_policy() { return this; }
 657 
 658   virtual CollectorPolicy::Name kind() {
 659     return CollectorPolicy::G1CollectorPolicyKind;
 660   }
 661 
 662   G1GCPhaseTimes* phase_times() const { return _phase_times; }
 663 
 664   // Check the current value of the young list RSet lengths and
 665   // compare it against the last prediction. If the current value is
 666   // higher, recalculate the young list target length prediction.
 667   void revise_young_list_target_length_if_necessary();
 668 
 669   size_t bytes_in_collection_set() {
 670     return _bytes_in_collection_set_before_gc;
 671   }
 672 
 673   // This should be called after the heap is resized.
 674   void record_new_heap_size(uint new_number_of_regions);
 675 
 676   void init();
 677 
 678   // Create jstat counters for the policy.
 679   virtual void initialize_gc_policy_counters();
 680 
 681   virtual HeapWord* mem_allocate_work(size_t size,
 682                                       bool is_tlab,
 683                                       bool* gc_overhead_limit_was_exceeded);
 684 
 685   // This method controls how a collector handles one or more
 686   // of its generations being fully allocated.
 687   virtual HeapWord* satisfy_failed_allocation(size_t size,
 688                                               bool is_tlab);
 689 
 690   BarrierSet::Name barrier_set_name() { return BarrierSet::G1SATBCTLogging; }
 691 
 692   GenRemSet::Name  rem_set_name()     { return GenRemSet::CardTable; }




 478   double predict_yg_surv_rate(int age, SurvRateGroup* surv_rate_group) {
 479     TruncatedSeq* seq = surv_rate_group->get_seq(age);
 480     if (seq->num() == 0)
 481       gclog_or_tty->print("BARF! age is %d", age);
 482     guarantee( seq->num() > 0, "invariant" );
 483     double pred = get_new_prediction(seq);
 484     if (pred > 1.0)
 485       pred = 1.0;
 486     return pred;
 487   }
 488 
 489   double predict_yg_surv_rate(int age) {
 490     return predict_yg_surv_rate(age, _short_lived_surv_rate_group);
 491   }
 492 
 493   double accum_yg_surv_rate_pred(int age) {
 494     return _short_lived_surv_rate_group->accum_surv_rate_pred(age);
 495   }
 496 
 497 private:






 498   // Statistics kept per GC stoppage, pause or full.
 499   TruncatedSeq* _recent_prev_end_times_for_all_gcs_sec;
 500 
 501   // Add a new GC of the given duration and end time to the record.
 502   void update_recent_gc_times(double end_time_sec, double elapsed_ms);
 503 
 504   // The head of the list (via "next_in_collection_set()") representing the
 505   // current collection set. Set from the incrementally built collection
 506   // set at the start of the pause.
 507   HeapRegion* _collection_set;
 508 
 509   // The number of bytes in the collection set before the pause. Set from
 510   // the incrementally built collection set at the start of an evacuation
 511   // pause, and incremented in finalize_cset() when adding old regions
 512   // (if any) to the collection set.
 513   size_t _collection_set_bytes_used_before;
 514 
 515   // The number of bytes copied during the GC.
 516   size_t _bytes_copied_during_gc;
 517 
 518   // The associated information that is maintained while the incremental
 519   // collection set is being built with young regions. Used to populate
 520   // the recorded info for the evacuation pause.
 521 
 522   enum CSetBuildType {
 523     Active,             // We are actively building the collection set
 524     Inactive            // We are not actively building the collection set
 525   };
 526 
 527   CSetBuildType _inc_cset_build_state;
 528 
 529   // The head of the incrementally built collection set.
 530   HeapRegion* _inc_cset_head;
 531 
 532   // The tail of the incrementally built collection set.
 533   HeapRegion* _inc_cset_tail;
 534 
 535   // The number of bytes in the incrementally built collection set.
 536   // Used to set _collection_set_bytes_used_before at the start of
 537   // an evacuation pause.


 627 
 628   // Calculate and return the maximum young list target length that
 629   // can fit into the pause time goal. The parameters are: rs_lengths
 630   // represent the prediction of how large the young RSet lengths will
 631   // be, base_min_length is the alreay existing number of regions in
 632   // the young list, min_length and max_length are the desired min and
 633   // max young list length according to the user's inputs.
 634   uint calculate_young_list_target_length(size_t rs_lengths,
 635                                           uint base_min_length,
 636                                           uint desired_min_length,
 637                                           uint desired_max_length);
 638 
 639   // Check whether a given young length (young_length) fits into the
 640   // given target pause time and whether the prediction for the amount
 641   // of objects to be copied for the given length will fit into the
 642   // given free space (expressed by base_free_regions).  It is used by
 643   // calculate_young_list_target_length().
 644   bool predict_will_fit(uint young_length, double base_time_ms,
 645                         uint base_free_regions, double target_pause_time_ms);
 646 



 647 public:
 648 
 649   G1CollectorPolicy();
 650 
 651   virtual G1CollectorPolicy* as_g1_policy() { return this; }
 652 
 653   virtual CollectorPolicy::Name kind() {
 654     return CollectorPolicy::G1CollectorPolicyKind;
 655   }
 656 
 657   G1GCPhaseTimes* phase_times() const { return _phase_times; }
 658 
 659   // Check the current value of the young list RSet lengths and
 660   // compare it against the last prediction. If the current value is
 661   // higher, recalculate the young list target length prediction.
 662   void revise_young_list_target_length_if_necessary();
 663 




 664   // This should be called after the heap is resized.
 665   void record_new_heap_size(uint new_number_of_regions);
 666 
 667   void init();
 668 
 669   // Create jstat counters for the policy.
 670   virtual void initialize_gc_policy_counters();
 671 
 672   virtual HeapWord* mem_allocate_work(size_t size,
 673                                       bool is_tlab,
 674                                       bool* gc_overhead_limit_was_exceeded);
 675 
 676   // This method controls how a collector handles one or more
 677   // of its generations being fully allocated.
 678   virtual HeapWord* satisfy_failed_allocation(size_t size,
 679                                               bool is_tlab);
 680 
 681   BarrierSet::Name barrier_set_name() { return BarrierSet::G1SATBCTLogging; }
 682 
 683   GenRemSet::Name  rem_set_name()     { return GenRemSet::CardTable; }