68 G1RemSetTrackingPolicy _remset_tracker;
69 G1MMUTracker* _mmu_tracker;
70 G1IHOPControl* _ihop_control;
71
72 GCPolicyCounters* _policy_counters;
73
74 double _full_collection_start_sec;
75
76 jlong _collection_pause_end_millis;
77
78 uint _young_list_target_length;
79 uint _young_list_fixed_length;
80
81 // The max number of regions we can extend the eden by while the GC
82 // locker is active. This should be >= _young_list_target_length;
83 uint _young_list_max_length;
84
85 // The survivor rate groups below must be initialized after the predictor because they
86 // indirectly use it through the "this" object passed to their constructor.
87 G1SurvRateGroup* _eden_surv_rate_group;
88 G1SurvRateGroup* _survivor_surv_rate_group;
89
90 double _reserve_factor;
91 // This will be set when the heap is expanded
92 // for the first time during initialization.
93 uint _reserve_regions;
94
95 G1YoungGenSizer* _young_gen_sizer;
96
97 uint _free_regions_at_end_of_collection;
98
99 size_t _rs_length;
100
101 size_t _rs_length_prediction;
102
103 size_t _pending_cards_at_gc_start;
104 size_t _pending_cards_at_prev_gc_end;
105 size_t _total_mutator_refined_cards;
106 size_t _total_concurrent_refined_cards;
107 Tickspan _total_concurrent_refinement_time;
108
114
115 bool should_update_surv_rate_group_predictors() {
116 return collector_state()->in_young_only_phase() && !collector_state()->mark_or_rebuild_in_progress();
117 }
118
119 double logged_cards_processing_time() const;
120 public:
121 const G1Predictions& predictor() const { return _predictor; }
122 const G1Analytics* analytics() const { return const_cast<const G1Analytics*>(_analytics); }
123
124 G1RemSetTrackingPolicy* remset_tracker() { return &_remset_tracker; }
125
126 // Add the given number of bytes to the total number of allocated bytes in the old gen.
127 void add_bytes_allocated_in_old_since_last_gc(size_t bytes) { _bytes_allocated_in_old_since_last_gc += bytes; }
128
129 void set_region_eden(HeapRegion* hr) {
130 hr->set_eden();
131 hr->install_surv_rate_group(_eden_surv_rate_group);
132 }
133
134 void set_region_survivor(HeapRegion* hr) {
135 assert(hr->is_survivor(), "pre-condition");
136 hr->install_surv_rate_group(_survivor_surv_rate_group);
137 }
138
139 void record_rs_length(size_t rs_length) {
140 _rs_length = rs_length;
141 }
142
143 double predict_base_elapsed_time_ms(size_t num_pending_cards) const;
144
145 private:
146 double predict_base_elapsed_time_ms(size_t num_pending_cards, size_t rs_length) const;
147
148 double predict_region_copy_time_ms(HeapRegion* hr) const;
149
150 public:
151
152 double predict_eden_copy_time_ms(uint count, size_t* bytes_to_copy = NULL) const;
153 double predict_region_non_copy_time_ms(HeapRegion* hr, bool for_young_gc) const;
154 double predict_region_total_time_ms(HeapRegion* hr, bool for_young_gc) const;
155
156 void cset_regions_freed() {
157 bool update = should_update_surv_rate_group_predictors();
158
159 _eden_surv_rate_group->all_surviving_words_recorded(predictor(), update);
160 _survivor_surv_rate_group->all_surviving_words_recorded(predictor(), update);
161 }
162
163 G1MMUTracker* mmu_tracker() {
164 return _mmu_tracker;
165 }
166
167 const G1MMUTracker* mmu_tracker() const {
168 return _mmu_tracker;
169 }
170
171 double max_pause_time_ms() const {
172 return _mmu_tracker->max_gc_time() * 1000.0;
173 }
174
175 private:
176 G1CollectionSet* _collection_set;
177 double average_time_ms(G1GCPhaseTimes::GCParPhases phase) const;
178 double other_time_ms(double pause_time_ms) const;
179
180 double young_other_time_ms() const;
388 }
389
390 bool use_adaptive_young_list_length() const;
391
392 void transfer_survivors_to_cset(const G1SurvivorRegions* survivors);
393
394 private:
395 //
396 // Survivor regions policy.
397 //
398
399 // Current tenuring threshold, set to 0 if the collector reaches the
400 // maximum amount of survivors regions.
401 uint _tenuring_threshold;
402
403 // The limit on the number of regions allocated for survivors.
404 uint _max_survivor_regions;
405
406 AgeTable _survivors_age_table;
407
408 size_t desired_survivor_size(uint max_regions) const;
409
410 // Fraction used when predicting how many optional regions to include in
411 // the CSet. This fraction of the available time is used for optional regions,
412 // the rest is used to add old regions to the normal CSet.
413 double optional_prediction_fraction() { return 0.2; }
414
415 public:
416 // Fraction used when evacuating the optional regions. This fraction of the
417 // remaining time is used to choose what regions to include in the evacuation.
418 double optional_evacuation_fraction() { return 0.75; }
419
420 uint tenuring_threshold() const { return _tenuring_threshold; }
421
422 uint max_survivor_regions() {
423 return _max_survivor_regions;
424 }
425
426 void note_start_adding_survivor_regions() {
427 _survivor_surv_rate_group->start_adding_regions();
428 }
429
430 void note_stop_adding_survivor_regions() {
431 _survivor_surv_rate_group->stop_adding_regions();
432 }
433
434 void record_age_table(AgeTable* age_table) {
435 _survivors_age_table.merge(age_table);
436 }
437
438 void print_age_table();
439
440 void update_max_gc_locker_expansion();
441
442 void update_survivors_policy();
443
444 virtual bool force_upgrade_to_full() {
445 return false;
446 }
447 };
448
449 #endif // SHARE_GC_G1_G1POLICY_HPP
|
68 G1RemSetTrackingPolicy _remset_tracker;
69 G1MMUTracker* _mmu_tracker;
70 G1IHOPControl* _ihop_control;
71
72 GCPolicyCounters* _policy_counters;
73
74 double _full_collection_start_sec;
75
76 jlong _collection_pause_end_millis;
77
78 uint _young_list_target_length;
79 uint _young_list_fixed_length;
80
81 // The max number of regions we can extend the eden by while the GC
82 // locker is active. This should be >= _young_list_target_length;
83 uint _young_list_max_length;
84
85 // The survivor rate groups below must be initialized after the predictor because they
86 // indirectly use it through the "this" object passed to their constructor.
87 G1SurvRateGroup* _eden_surv_rate_group;
88
89 size_t _survivor_used_bytes_at_start;
90 size_t _survivor_used_bytes_at_end;
91
92 double _reserve_factor;
93 // This will be set when the heap is expanded
94 // for the first time during initialization.
95 uint _reserve_regions;
96
97 G1YoungGenSizer* _young_gen_sizer;
98
99 uint _free_regions_at_end_of_collection;
100
101 size_t _rs_length;
102
103 size_t _rs_length_prediction;
104
105 size_t _pending_cards_at_gc_start;
106 size_t _pending_cards_at_prev_gc_end;
107 size_t _total_mutator_refined_cards;
108 size_t _total_concurrent_refined_cards;
109 Tickspan _total_concurrent_refinement_time;
110
116
117 bool should_update_surv_rate_group_predictors() {
118 return collector_state()->in_young_only_phase() && !collector_state()->mark_or_rebuild_in_progress();
119 }
120
121 double logged_cards_processing_time() const;
122 public:
123 const G1Predictions& predictor() const { return _predictor; }
124 const G1Analytics* analytics() const { return const_cast<const G1Analytics*>(_analytics); }
125
126 G1RemSetTrackingPolicy* remset_tracker() { return &_remset_tracker; }
127
128 // Add the given number of bytes to the total number of allocated bytes in the old gen.
129 void add_bytes_allocated_in_old_since_last_gc(size_t bytes) { _bytes_allocated_in_old_since_last_gc += bytes; }
130
131 void set_region_eden(HeapRegion* hr) {
132 hr->set_eden();
133 hr->install_surv_rate_group(_eden_surv_rate_group);
134 }
135
136 void record_rs_length(size_t rs_length) {
137 _rs_length = rs_length;
138 }
139
140 double predict_base_elapsed_time_ms(size_t num_pending_cards) const;
141
142 private:
143 double predict_base_elapsed_time_ms(size_t num_pending_cards, size_t rs_length) const;
144
145 double predict_region_copy_time_ms(HeapRegion* hr) const;
146
147 public:
148
149 double predict_eden_copy_time_ms(uint count, size_t* bytes_to_copy = NULL) const;
150 double predict_region_non_copy_time_ms(HeapRegion* hr, bool for_young_gc) const;
151 double predict_region_total_time_ms(HeapRegion* hr, bool for_young_gc) const;
152
153 void cset_regions_freed() {
154 bool update = should_update_surv_rate_group_predictors();
155
156 _eden_surv_rate_group->all_surviving_words_recorded(predictor(), update);
157 }
158
159 G1MMUTracker* mmu_tracker() {
160 return _mmu_tracker;
161 }
162
163 const G1MMUTracker* mmu_tracker() const {
164 return _mmu_tracker;
165 }
166
167 double max_pause_time_ms() const {
168 return _mmu_tracker->max_gc_time() * 1000.0;
169 }
170
171 private:
172 G1CollectionSet* _collection_set;
173 double average_time_ms(G1GCPhaseTimes::GCParPhases phase) const;
174 double other_time_ms(double pause_time_ms) const;
175
176 double young_other_time_ms() const;
384 }
385
386 bool use_adaptive_young_list_length() const;
387
388 void transfer_survivors_to_cset(const G1SurvivorRegions* survivors);
389
390 private:
391 //
392 // Survivor regions policy.
393 //
394
395 // Current tenuring threshold, set to 0 if the collector reaches the
396 // maximum amount of survivors regions.
397 uint _tenuring_threshold;
398
399 // The limit on the number of regions allocated for survivors.
400 uint _max_survivor_regions;
401
402 AgeTable _survivors_age_table;
403
404 size_t _surviving_survivor_words;
405
406 size_t desired_survivor_size(uint max_regions) const;
407
408 // Fraction used when predicting how many optional regions to include in
409 // the CSet. This fraction of the available time is used for optional regions,
410 // the rest is used to add old regions to the normal CSet.
411 double optional_prediction_fraction() { return 0.2; }
412
413 public:
414 // Fraction used when evacuating the optional regions. This fraction of the
415 // remaining time is used to choose what regions to include in the evacuation.
416 double optional_evacuation_fraction() { return 0.75; }
417
418 uint tenuring_threshold() const { return _tenuring_threshold; }
419
420 uint max_survivor_regions() {
421 return _max_survivor_regions;
422 }
423
424 void record_age_table(AgeTable* age_table) {
425 _survivors_age_table.merge(age_table);
426 }
427
428 void record_surviving_survivor_words(size_t words) {
429 _surviving_survivor_words += words;
430 }
431
432 void print_age_table();
433
434 void update_max_gc_locker_expansion();
435
436 void update_survivors_policy();
437
438 virtual bool force_upgrade_to_full() {
439 return false;
440 }
441 };
442
443 #endif // SHARE_GC_G1_G1POLICY_HPP
|