25 #ifndef SHARE_VM_GC_G1_G1COLLECTORPOLICY_HPP |
25 #ifndef SHARE_VM_GC_G1_G1COLLECTORPOLICY_HPP |
26 #define SHARE_VM_GC_G1_G1COLLECTORPOLICY_HPP |
26 #define SHARE_VM_GC_G1_G1COLLECTORPOLICY_HPP |
27 |
27 |
28 #include "gc/g1/collectionSetChooser.hpp" |
28 #include "gc/g1/collectionSetChooser.hpp" |
29 #include "gc/g1/g1Allocator.hpp" |
29 #include "gc/g1/g1Allocator.hpp" |
|
30 #include "gc/g1/g1CollectorState.hpp" |
30 #include "gc/g1/g1MMUTracker.hpp" |
31 #include "gc/g1/g1MMUTracker.hpp" |
31 #include "gc/shared/collectorPolicy.hpp" |
32 #include "gc/shared/collectorPolicy.hpp" |
32 |
33 |
33 // A G1CollectorPolicy makes policy decisions that determine the |
34 // A G1CollectorPolicy makes policy decisions that determine the |
34 // characteristics of the collector. Examples include: |
35 // characteristics of the collector. Examples include: |
191 TraceYoungGenTimeData _trace_young_gen_time_data; |
192 TraceYoungGenTimeData _trace_young_gen_time_data; |
192 TraceOldGenTimeData _trace_old_gen_time_data; |
193 TraceOldGenTimeData _trace_old_gen_time_data; |
193 |
194 |
194 double _stop_world_start; |
195 double _stop_world_start; |
195 |
196 |
196 // indicates whether we are in young or mixed GC mode |
|
197 bool _gcs_are_young; |
|
198 |
|
199 uint _young_list_target_length; |
197 uint _young_list_target_length; |
200 uint _young_list_fixed_length; |
198 uint _young_list_fixed_length; |
201 |
199 |
202 // The max number of regions we can extend the eden by while the GC |
200 // The max number of regions we can extend the eden by while the GC |
203 // locker is active. This should be >= _young_list_target_length; |
201 // locker is active. This should be >= _young_list_target_length; |
204 uint _young_list_max_length; |
202 uint _young_list_max_length; |
205 |
203 |
206 bool _last_gc_was_young; |
|
207 |
|
208 bool _during_marking; |
|
209 bool _in_marking_window; |
|
210 bool _in_marking_window_im; |
|
211 |
|
212 SurvRateGroup* _short_lived_surv_rate_group; |
204 SurvRateGroup* _short_lived_surv_rate_group; |
213 SurvRateGroup* _survivor_surv_rate_group; |
205 SurvRateGroup* _survivor_surv_rate_group; |
214 // add here any more surv rate groups |
206 // add here any more surv rate groups |
215 |
207 |
216 double _gc_overhead_perc; |
208 double _gc_overhead_perc; |
217 |
209 |
218 double _reserve_factor; |
210 double _reserve_factor; |
219 uint _reserve_regions; |
211 uint _reserve_regions; |
220 |
|
221 bool during_marking() { |
|
222 return _during_marking; |
|
223 } |
|
224 |
212 |
225 enum PredictionConstants { |
213 enum PredictionConstants { |
226 TruncatedSeqLength = 10 |
214 TruncatedSeqLength = 10 |
227 }; |
215 }; |
228 |
216 |
361 return (size_t) ((double) rs_length * |
349 return (size_t) ((double) rs_length * |
362 predict_mixed_cards_per_entry_ratio()); |
350 predict_mixed_cards_per_entry_ratio()); |
363 } |
351 } |
364 |
352 |
365 double predict_rs_scan_time_ms(size_t card_num) { |
353 double predict_rs_scan_time_ms(size_t card_num) { |
366 if (gcs_are_young()) { |
354 if (collector_state()->gcs_are_young()) { |
367 return (double) card_num * get_new_prediction(_cost_per_entry_ms_seq); |
355 return (double) card_num * get_new_prediction(_cost_per_entry_ms_seq); |
368 } else { |
356 } else { |
369 return predict_mixed_rs_scan_time_ms(card_num); |
357 return predict_mixed_rs_scan_time_ms(card_num); |
370 } |
358 } |
371 } |
359 } |
388 get_new_prediction(_cost_per_byte_ms_during_cm_seq); |
376 get_new_prediction(_cost_per_byte_ms_during_cm_seq); |
389 } |
377 } |
390 } |
378 } |
391 |
379 |
392 double predict_object_copy_time_ms(size_t bytes_to_copy) { |
380 double predict_object_copy_time_ms(size_t bytes_to_copy) { |
393 if (_in_marking_window && !_in_marking_window_im) { |
381 if (collector_state()->during_concurrent_mark()) { |
394 return predict_object_copy_time_ms_during_cm(bytes_to_copy); |
382 return predict_object_copy_time_ms_during_cm(bytes_to_copy); |
395 } else { |
383 } else { |
396 return (double) bytes_to_copy * |
384 return (double) bytes_to_copy * |
397 get_new_prediction(_cost_per_byte_ms_seq); |
385 get_new_prediction(_cost_per_byte_ms_seq); |
398 } |
386 } |
426 survivor_cset_region_length(); } |
414 survivor_cset_region_length(); } |
427 |
415 |
428 double predict_survivor_regions_evac_time(); |
416 double predict_survivor_regions_evac_time(); |
429 |
417 |
430 void cset_regions_freed() { |
418 void cset_regions_freed() { |
431 bool propagate = _last_gc_was_young && !_in_marking_window; |
419 bool propagate = collector_state()->should_propagate(); |
432 _short_lived_surv_rate_group->all_surviving_words_recorded(propagate); |
420 _short_lived_surv_rate_group->all_surviving_words_recorded(propagate); |
433 _survivor_surv_rate_group->all_surviving_words_recorded(propagate); |
421 _survivor_surv_rate_group->all_surviving_words_recorded(propagate); |
434 // also call it on any more surv rate groups |
422 // also call it on any more surv rate groups |
435 } |
423 } |
436 |
424 |
550 |
538 |
551 double recent_avg_pause_time_ratio() { |
539 double recent_avg_pause_time_ratio() { |
552 return _recent_avg_pause_time_ratio; |
540 return _recent_avg_pause_time_ratio; |
553 } |
541 } |
554 |
542 |
555 // At the end of a pause we check the heap occupancy and we decide |
|
556 // whether we will start a marking cycle during the next pause. If |
|
557 // we decide that we want to do that, we will set this parameter to |
|
558 // true. So, this parameter will stay true between the end of a |
|
559 // pause and the beginning of a subsequent pause (not necessarily |
|
560 // the next one, see the comments on the next field) when we decide |
|
561 // that we will indeed start a marking cycle and do the initial-mark |
|
562 // work. |
|
563 volatile bool _initiate_conc_mark_if_possible; |
|
564 |
|
565 // If initiate_conc_mark_if_possible() is set at the beginning of a |
|
566 // pause, it is a suggestion that the pause should start a marking |
|
567 // cycle by doing the initial-mark work. However, it is possible |
|
568 // that the concurrent marking thread is still finishing up the |
|
569 // previous marking cycle (e.g., clearing the next marking |
|
570 // bitmap). If that is the case we cannot start a new cycle and |
|
571 // we'll have to wait for the concurrent marking thread to finish |
|
572 // what it is doing. In this case we will postpone the marking cycle |
|
573 // initiation decision for the next pause. When we eventually decide |
|
574 // to start a cycle, we will set _during_initial_mark_pause which |
|
575 // will stay true until the end of the initial-mark pause and it's |
|
576 // the condition that indicates that a pause is doing the |
|
577 // initial-mark work. |
|
578 volatile bool _during_initial_mark_pause; |
|
579 |
|
580 bool _last_young_gc; |
|
581 |
|
582 // This set of variables tracks the collector efficiency, in order to |
543 // This set of variables tracks the collector efficiency, in order to |
583 // determine whether we should initiate a new marking. |
544 // determine whether we should initiate a new marking. |
584 double _cur_mark_stop_world_time_ms; |
545 double _cur_mark_stop_world_time_ms; |
585 double _mark_remark_start_sec; |
546 double _mark_remark_start_sec; |
586 double _mark_cleanup_start_sec; |
547 double _mark_cleanup_start_sec; |
645 |
606 |
646 virtual CollectorPolicy::Name kind() { |
607 virtual CollectorPolicy::Name kind() { |
647 return CollectorPolicy::G1CollectorPolicyKind; |
608 return CollectorPolicy::G1CollectorPolicyKind; |
648 } |
609 } |
649 |
610 |
|
611 G1CollectorState* collector_state(); |
|
612 |
650 G1GCPhaseTimes* phase_times() const { return _phase_times; } |
613 G1GCPhaseTimes* phase_times() const { return _phase_times; } |
651 |
614 |
652 // Check the current value of the young list RSet lengths and |
615 // Check the current value of the young list RSet lengths and |
653 // compare it against the last prediction. If the current value is |
616 // compare it against the last prediction. If the current value is |
654 // higher, recalculate the young list target length prediction. |
617 // higher, recalculate the young list target length prediction. |
783 void add_region_to_incremental_cset_rhs(HeapRegion* hr); |
746 void add_region_to_incremental_cset_rhs(HeapRegion* hr); |
784 |
747 |
785 #ifndef PRODUCT |
748 #ifndef PRODUCT |
786 void print_collection_set(HeapRegion* list_head, outputStream* st); |
749 void print_collection_set(HeapRegion* list_head, outputStream* st); |
787 #endif // !PRODUCT |
750 #endif // !PRODUCT |
788 |
|
789 bool initiate_conc_mark_if_possible() { return _initiate_conc_mark_if_possible; } |
|
790 void set_initiate_conc_mark_if_possible() { _initiate_conc_mark_if_possible = true; } |
|
791 void clear_initiate_conc_mark_if_possible() { _initiate_conc_mark_if_possible = false; } |
|
792 |
|
793 bool during_initial_mark_pause() { return _during_initial_mark_pause; } |
|
794 void set_during_initial_mark_pause() { _during_initial_mark_pause = true; } |
|
795 void clear_during_initial_mark_pause(){ _during_initial_mark_pause = false; } |
|
796 |
751 |
797 // This sets the initiate_conc_mark_if_possible() flag to start a |
752 // This sets the initiate_conc_mark_if_possible() flag to start a |
798 // new cycle, as long as we are not already in one. It's best if it |
753 // new cycle, as long as we are not already in one. It's best if it |
799 // is called during a safepoint when the test whether a cycle is in |
754 // is called during a safepoint when the test whether a cycle is in |
800 // progress or not is stable. |
755 // progress or not is stable. |
833 |
788 |
834 bool can_expand_young_list(); |
789 bool can_expand_young_list(); |
835 |
790 |
836 uint young_list_max_length() { |
791 uint young_list_max_length() { |
837 return _young_list_max_length; |
792 return _young_list_max_length; |
838 } |
|
839 |
|
840 bool gcs_are_young() { |
|
841 return _gcs_are_young; |
|
842 } |
|
843 void set_gcs_are_young(bool gcs_are_young) { |
|
844 _gcs_are_young = gcs_are_young; |
|
845 } |
793 } |
846 |
794 |
847 bool adaptive_young_list_length() { |
795 bool adaptive_young_list_length() { |
848 return _young_gen_sizer->adaptive_young_list_length(); |
796 return _young_gen_sizer->adaptive_young_list_length(); |
849 } |
797 } |