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:

Split Close
Expand all
Collapse all
          --- old/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp
          +++ new/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp
↓ open down ↓ 487 lines elided ↑ open up ↑
 488  488  
 489  489    double predict_yg_surv_rate(int age) {
 490  490      return predict_yg_surv_rate(age, _short_lived_surv_rate_group);
 491  491    }
 492  492  
 493  493    double accum_yg_surv_rate_pred(int age) {
 494  494      return _short_lived_surv_rate_group->accum_surv_rate_pred(age);
 495  495    }
 496  496  
 497  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  498    // Statistics kept per GC stoppage, pause or full.
 505  499    TruncatedSeq* _recent_prev_end_times_for_all_gcs_sec;
 506  500  
 507  501    // Add a new GC of the given duration and end time to the record.
 508  502    void update_recent_gc_times(double end_time_sec, double elapsed_ms);
 509  503  
 510  504    // The head of the list (via "next_in_collection_set()") representing the
 511  505    // current collection set. Set from the incrementally built collection
 512  506    // set at the start of the pause.
 513  507    HeapRegion* _collection_set;
 514  508  
 515  509    // The number of bytes in the collection set before the pause. Set from
 516  510    // the incrementally built collection set at the start of an evacuation
 517      -  // pause.
      511 +  // pause, and incremented in finalize_cset() when adding old regions
      512 +  // (if any) to the collection set.
 518  513    size_t _collection_set_bytes_used_before;
 519  514  
      515 +  // The number of bytes copied during the GC.
      516 +  size_t _bytes_copied_during_gc;
      517 +
 520  518    // The associated information that is maintained while the incremental
 521  519    // collection set is being built with young regions. Used to populate
 522  520    // the recorded info for the evacuation pause.
 523  521  
 524  522    enum CSetBuildType {
 525  523      Active,             // We are actively building the collection set
 526  524      Inactive            // We are not actively building the collection set
 527  525    };
 528  526  
 529  527    CSetBuildType _inc_cset_build_state;
↓ open down ↓ 109 lines elided ↑ open up ↑
 639  637                                            uint desired_max_length);
 640  638  
 641  639    // Check whether a given young length (young_length) fits into the
 642  640    // given target pause time and whether the prediction for the amount
 643  641    // of objects to be copied for the given length will fit into the
 644  642    // given free space (expressed by base_free_regions).  It is used by
 645  643    // calculate_young_list_target_length().
 646  644    bool predict_will_fit(uint young_length, double base_time_ms,
 647  645                          uint base_free_regions, double target_pause_time_ms);
 648  646  
 649      -  // Count the number of bytes used in the CS.
 650      -  void count_CS_bytes_used();
 651      -
 652  647  public:
 653  648  
 654  649    G1CollectorPolicy();
 655  650  
 656  651    virtual G1CollectorPolicy* as_g1_policy() { return this; }
 657  652  
 658  653    virtual CollectorPolicy::Name kind() {
 659  654      return CollectorPolicy::G1CollectorPolicyKind;
 660  655    }
 661  656  
 662  657    G1GCPhaseTimes* phase_times() const { return _phase_times; }
 663  658  
 664  659    // Check the current value of the young list RSet lengths and
 665  660    // compare it against the last prediction. If the current value is
 666  661    // higher, recalculate the young list target length prediction.
 667  662    void revise_young_list_target_length_if_necessary();
 668  663  
 669      -  size_t bytes_in_collection_set() {
 670      -    return _bytes_in_collection_set_before_gc;
 671      -  }
 672      -
 673  664    // This should be called after the heap is resized.
 674  665    void record_new_heap_size(uint new_number_of_regions);
 675  666  
 676  667    void init();
 677  668  
 678  669    // Create jstat counters for the policy.
 679  670    virtual void initialize_gc_policy_counters();
 680  671  
 681  672    virtual HeapWord* mem_allocate_work(size_t size,
 682  673                                        bool is_tlab,
↓ open down ↓ 281 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX