40 #include "gc/g1/g1Policy.hpp"
41 #include "gc/g1/g1SurvivorRegions.hpp"
42 #include "gc/g1/g1YoungGenSizer.hpp"
43 #include "gc/g1/heapRegion.inline.hpp"
44 #include "gc/g1/heapRegionRemSet.hpp"
45 #include "gc/shared/concurrentGCBreakpoints.hpp"
46 #include "gc/shared/gcPolicyCounters.hpp"
47 #include "logging/log.hpp"
48 #include "runtime/arguments.hpp"
49 #include "runtime/java.hpp"
50 #include "runtime/mutexLocker.hpp"
51 #include "utilities/debug.hpp"
52 #include "utilities/growableArray.hpp"
53 #include "utilities/pair.hpp"
54
55 G1Policy::G1Policy(STWGCTimer* gc_timer) :
56 _predictor(G1ConfidencePercent / 100.0),
57 _analytics(new G1Analytics(&_predictor)),
58 _remset_tracker(),
59 _mmu_tracker(new G1MMUTrackerQueue(GCPauseIntervalMillis / 1000.0, MaxGCPauseMillis / 1000.0)),
60 _ihop_control(create_ihop_control(&_old_gen_alloc_tracker, &_predictor)),
61 _policy_counters(new GCPolicyCounters("GarbageFirst", 1, 2)),
62 _full_collection_start_sec(0.0),
63 _young_list_target_length(0),
64 _young_list_fixed_length(0),
65 _young_list_max_length(0),
66 _eden_surv_rate_group(new G1SurvRateGroup()),
67 _survivor_surv_rate_group(new G1SurvRateGroup()),
68 _reserve_factor((double) G1ReservePercent / 100.0),
69 _reserve_regions(0),
70 _young_gen_sizer(G1YoungGenSizer::create_gen_sizer()),
71 _free_regions_at_end_of_collection(0),
72 _rs_length(0),
73 _rs_length_prediction(0),
74 _pending_cards_at_gc_start(0),
75 _old_gen_alloc_tracker(),
76 _concurrent_start_to_mixed(),
77 _collection_set(NULL),
78 _g1h(NULL),
79 _phase_times_timer(gc_timer),
80 _phase_times(NULL),
81 _mark_remark_start_sec(0),
82 _mark_cleanup_start_sec(0),
83 _tenuring_threshold(MaxTenuringThreshold),
84 _max_survivor_regions(0),
85 _survivors_age_table(true)
86 {
87 }
88
89 G1Policy::~G1Policy() {
90 delete _ihop_control;
91 delete _young_gen_sizer;
92 }
93
94 G1Policy* G1Policy::create_policy(STWGCTimer* gc_timer_stw) {
95 if (G1Arguments::is_heterogeneous_heap()) {
827 log_debug(gc, ergo, refine)("Adjust concurrent refinement thresholds (scanning the HCC expected to take longer than Update RS time goal)."
828 "Logged Cards Scan time goal: %1.2fms Scan HCC time: %1.2fms",
829 scan_logged_cards_time_goal_ms, merge_hcc_time_ms);
830
831 scan_logged_cards_time_goal_ms = 0;
832 } else {
833 scan_logged_cards_time_goal_ms -= merge_hcc_time_ms;
834 }
835
836 double const logged_cards_time = logged_cards_processing_time();
837
838 log_debug(gc, ergo, refine)("Concurrent refinement times: Logged Cards Scan time goal: %1.2fms Logged Cards Scan time: %1.2fms HCC time: %1.2fms",
839 scan_logged_cards_time_goal_ms, logged_cards_time, merge_hcc_time_ms);
840
841 _g1h->concurrent_refine()->adjust(logged_cards_time,
842 phase_times()->sum_thread_work_items(G1GCPhaseTimes::MergeLB, G1GCPhaseTimes::MergeLBDirtyCards),
843 scan_logged_cards_time_goal_ms);
844 }
845
846 G1IHOPControl* G1Policy::create_ihop_control(const G1OldGenAllocationTracker* old_gen_alloc_tracker,
847 const G1Predictions* predictor){
848 if (G1UseAdaptiveIHOP) {
849 return new G1AdaptiveIHOPControl(InitiatingHeapOccupancyPercent,
850 old_gen_alloc_tracker,
851 predictor,
852 G1ReservePercent,
853 G1HeapWastePercent);
854 } else {
855 return new G1StaticIHOPControl(InitiatingHeapOccupancyPercent, old_gen_alloc_tracker);
856 }
857 }
858
859 void G1Policy::update_ihop_prediction(double mutator_time_s,
860 size_t young_gen_size,
861 bool this_gc_was_young_only) {
862 // Always try to update IHOP prediction. Even evacuation failures give information
863 // about e.g. whether to start IHOP earlier next time.
864
865 // Avoid using really small application times that might create samples with
866 // very high or very low values. They may be caused by e.g. back-to-back gcs.
867 double const min_valid_time = 1e-6;
|
40 #include "gc/g1/g1Policy.hpp"
41 #include "gc/g1/g1SurvivorRegions.hpp"
42 #include "gc/g1/g1YoungGenSizer.hpp"
43 #include "gc/g1/heapRegion.inline.hpp"
44 #include "gc/g1/heapRegionRemSet.hpp"
45 #include "gc/shared/concurrentGCBreakpoints.hpp"
46 #include "gc/shared/gcPolicyCounters.hpp"
47 #include "logging/log.hpp"
48 #include "runtime/arguments.hpp"
49 #include "runtime/java.hpp"
50 #include "runtime/mutexLocker.hpp"
51 #include "utilities/debug.hpp"
52 #include "utilities/growableArray.hpp"
53 #include "utilities/pair.hpp"
54
55 G1Policy::G1Policy(STWGCTimer* gc_timer) :
56 _predictor(G1ConfidencePercent / 100.0),
57 _analytics(new G1Analytics(&_predictor)),
58 _remset_tracker(),
59 _mmu_tracker(new G1MMUTrackerQueue(GCPauseIntervalMillis / 1000.0, MaxGCPauseMillis / 1000.0)),
60 _old_gen_alloc_tracker(),
61 _ihop_control(create_ihop_control(&_old_gen_alloc_tracker, &_predictor)),
62 _policy_counters(new GCPolicyCounters("GarbageFirst", 1, 2)),
63 _full_collection_start_sec(0.0),
64 _young_list_target_length(0),
65 _young_list_fixed_length(0),
66 _young_list_max_length(0),
67 _eden_surv_rate_group(new G1SurvRateGroup()),
68 _survivor_surv_rate_group(new G1SurvRateGroup()),
69 _reserve_factor((double) G1ReservePercent / 100.0),
70 _reserve_regions(0),
71 _young_gen_sizer(G1YoungGenSizer::create_gen_sizer()),
72 _free_regions_at_end_of_collection(0),
73 _rs_length(0),
74 _rs_length_prediction(0),
75 _pending_cards_at_gc_start(0),
76 _concurrent_start_to_mixed(),
77 _collection_set(NULL),
78 _g1h(NULL),
79 _phase_times_timer(gc_timer),
80 _phase_times(NULL),
81 _mark_remark_start_sec(0),
82 _mark_cleanup_start_sec(0),
83 _tenuring_threshold(MaxTenuringThreshold),
84 _max_survivor_regions(0),
85 _survivors_age_table(true)
86 {
87 }
88
89 G1Policy::~G1Policy() {
90 delete _ihop_control;
91 delete _young_gen_sizer;
92 }
93
94 G1Policy* G1Policy::create_policy(STWGCTimer* gc_timer_stw) {
95 if (G1Arguments::is_heterogeneous_heap()) {
827 log_debug(gc, ergo, refine)("Adjust concurrent refinement thresholds (scanning the HCC expected to take longer than Update RS time goal)."
828 "Logged Cards Scan time goal: %1.2fms Scan HCC time: %1.2fms",
829 scan_logged_cards_time_goal_ms, merge_hcc_time_ms);
830
831 scan_logged_cards_time_goal_ms = 0;
832 } else {
833 scan_logged_cards_time_goal_ms -= merge_hcc_time_ms;
834 }
835
836 double const logged_cards_time = logged_cards_processing_time();
837
838 log_debug(gc, ergo, refine)("Concurrent refinement times: Logged Cards Scan time goal: %1.2fms Logged Cards Scan time: %1.2fms HCC time: %1.2fms",
839 scan_logged_cards_time_goal_ms, logged_cards_time, merge_hcc_time_ms);
840
841 _g1h->concurrent_refine()->adjust(logged_cards_time,
842 phase_times()->sum_thread_work_items(G1GCPhaseTimes::MergeLB, G1GCPhaseTimes::MergeLBDirtyCards),
843 scan_logged_cards_time_goal_ms);
844 }
845
846 G1IHOPControl* G1Policy::create_ihop_control(const G1OldGenAllocationTracker* old_gen_alloc_tracker,
847 const G1Predictions* predictor) {
848 if (G1UseAdaptiveIHOP) {
849 return new G1AdaptiveIHOPControl(InitiatingHeapOccupancyPercent,
850 old_gen_alloc_tracker,
851 predictor,
852 G1ReservePercent,
853 G1HeapWastePercent);
854 } else {
855 return new G1StaticIHOPControl(InitiatingHeapOccupancyPercent, old_gen_alloc_tracker);
856 }
857 }
858
859 void G1Policy::update_ihop_prediction(double mutator_time_s,
860 size_t young_gen_size,
861 bool this_gc_was_young_only) {
862 // Always try to update IHOP prediction. Even evacuation failures give information
863 // about e.g. whether to start IHOP earlier next time.
864
865 // Avoid using really small application times that might create samples with
866 // very high or very low values. They may be caused by e.g. back-to-back gcs.
867 double const min_valid_time = 1e-6;
|