--- old/src/share/vm/gc/g1/g1CollectorPolicy.cpp 2016-03-16 15:08:14.726833325 +0100 +++ new/src/share/vm/gc/g1/g1CollectorPolicy.cpp 2016-03-16 15:08:14.626829193 +0100 @@ -25,13 +25,13 @@ #include "precompiled.hpp" #include "gc/g1/concurrentG1Refine.hpp" #include "gc/g1/concurrentMarkThread.inline.hpp" +#include "gc/g1/g1Analytics.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1CollectionSet.hpp" #include "gc/g1/g1CollectorPolicy.hpp" #include "gc/g1/g1ConcurrentMark.hpp" #include "gc/g1/g1IHOPControl.hpp" #include "gc/g1/g1GCPhaseTimes.hpp" -#include "gc/g1/g1Measurements.hpp" #include "gc/g1/g1YoungGenSizer.hpp" #include "gc/g1/heapRegion.inline.hpp" #include "gc/g1/heapRegionRemSet.hpp" @@ -44,7 +44,7 @@ G1CollectorPolicy::G1CollectorPolicy() : _predictor(G1ConfidencePercent / 100.0), - _measurements(new G1Measurements(&_predictor)), + _analytics(new G1Analytics(&_predictor)), _pause_time_target_ms((double) MaxGCPauseMillis), _rs_lengths_prediction(0), _max_survivor_regions(0), @@ -240,9 +240,9 @@ double accum_surv_rate = accum_yg_surv_rate_pred((int) young_length - 1); size_t bytes_to_copy = (size_t) (accum_surv_rate * (double) HeapRegion::GrainBytes); - double copy_time_ms = _measurements->predict_object_copy_time_ms(bytes_to_copy, + double copy_time_ms = _analytics->predict_object_copy_time_ms(bytes_to_copy, collector_state()->during_concurrent_mark()); - double young_other_time_ms = _measurements->predict_young_other_time_ms(young_length); + double young_other_time_ms = _analytics->predict_young_other_time_ms(young_length); double pause_time_ms = base_time_ms + copy_time_ms + young_other_time_ms; if (pause_time_ms > target_pause_time_ms) { // end condition 2: prediction is over the target pause time @@ -286,10 +286,10 @@ uint base_min_length) const { uint desired_min_length = 0; if (adaptive_young_list_length()) { - if (_measurements->num_alloc_rate_ms() > 3) { + if (_analytics->num_alloc_rate_ms() > 3) { double now_sec = os::elapsedTime(); double when_ms = _mmu_tracker->when_max_gc_sec(now_sec) * 1000.0; - double alloc_rate_ms = _measurements->predict_alloc_rate_ms(); + double alloc_rate_ms = _analytics->predict_alloc_rate_ms(); desired_min_length = (uint) ceil(alloc_rate_ms * when_ms); } else { // otherwise we don't have enough info to make the prediction @@ -308,7 +308,7 @@ } uint G1CollectorPolicy::update_young_list_max_and_target_length() { - return update_young_list_max_and_target_length(_measurements->predict_rs_lengths()); + return update_young_list_max_and_target_length(_analytics->predict_rs_lengths()); } uint G1CollectorPolicy::update_young_list_max_and_target_length(size_t rs_lengths) { @@ -413,9 +413,9 @@ double target_pause_time_ms = _mmu_tracker->max_gc_time() * 1000.0; double survivor_regions_evac_time = predict_survivor_regions_evac_time(); - size_t pending_cards = _measurements->predict_pending_cards(); - size_t adj_rs_lengths = rs_lengths + _measurements->predict_rs_length_diff(); - size_t scanned_cards = _measurements->predict_card_num(adj_rs_lengths, /* gcs_are_young */ true); + size_t pending_cards = _analytics->predict_pending_cards(); + size_t adj_rs_lengths = rs_lengths + _analytics->predict_rs_length_diff(); + size_t scanned_cards = _analytics->predict_card_num(adj_rs_lengths, /* gcs_are_young */ true); double base_time_ms = predict_base_elapsed_time_ms(pending_cards, scanned_cards) + survivor_regions_evac_time; @@ -515,7 +515,7 @@ } void G1CollectorPolicy::update_rs_lengths_prediction() { - update_rs_lengths_prediction(_measurements->predict_rs_lengths()); + update_rs_lengths_prediction(_analytics->predict_rs_lengths()); } void G1CollectorPolicy::update_rs_lengths_prediction(size_t prediction) { @@ -583,7 +583,7 @@ double full_gc_time_sec = end_sec - _full_collection_start_sec; double full_gc_time_ms = full_gc_time_sec * 1000.0; - _measurements->update_recent_gc_times(end_sec, full_gc_time_ms); + _analytics->update_recent_gc_times(end_sec, full_gc_time_ms); collector_state()->set_full_collection(false); @@ -651,8 +651,8 @@ void G1CollectorPolicy::record_concurrent_mark_remark_end() { double end_time_sec = os::elapsedTime(); double elapsed_time_ms = (end_time_sec - _mark_remark_start_sec)*1000.0; - _measurements->report_concurrent_mark_remark_times_ms(elapsed_time_ms); - _measurements->append_prev_collection_pause_end_ms(elapsed_time_ms); + _analytics->report_concurrent_mark_remark_times_ms(elapsed_time_ms); + _analytics->append_prev_collection_pause_end_ms(elapsed_time_ms); record_pause(Remark, _mark_remark_start_sec, end_time_sec); } @@ -751,7 +751,7 @@ maybe_start_marking(); } - double app_time_ms = (phase_times()->cur_collection_start_sec() * 1000.0 - _measurements->prev_collection_pause_end_ms()); + double app_time_ms = (phase_times()->cur_collection_start_sec() * 1000.0 - _analytics->prev_collection_pause_end_ms()); if (app_time_ms < MIN_TIMER_GRANULARITY) { // This usually happens due to the timer not having the required // granularity. Some Linuxes are the usual culprits. @@ -770,9 +770,12 @@ // place we can safely ignore them here. uint regions_allocated = _collection_set->eden_region_length(); double alloc_rate_ms = (double) regions_allocated / app_time_ms; - _measurements->report_alloc_rate_ms(alloc_rate_ms); + _analytics->report_alloc_rate_ms(alloc_rate_ms); - _measurements->update_recent_gc_times(end_time_sec, pause_time_ms); + double interval_ms = + (end_time_sec - _analytics->last_known_gc_end_time_sec()) * 1000.0; + _analytics->update_recent_gc_times(end_time_sec, pause_time_ms); + _analytics->compute_pause_time_ratio(interval_ms, pause_time_ms); } bool new_in_marking_window = collector_state()->in_marking_window(); @@ -818,20 +821,20 @@ double cost_per_card_ms = 0.0; if (_pending_cards > 0) { cost_per_card_ms = (average_time_ms(G1GCPhaseTimes::UpdateRS) - scan_hcc_time_ms) / (double) _pending_cards; - _measurements->report_cost_per_card_ms(cost_per_card_ms); + _analytics->report_cost_per_card_ms(cost_per_card_ms); } - _measurements->report_cost_scan_hcc(scan_hcc_time_ms); + _analytics->report_cost_scan_hcc(scan_hcc_time_ms); double cost_per_entry_ms = 0.0; if (cards_scanned > 10) { cost_per_entry_ms = average_time_ms(G1GCPhaseTimes::ScanRS) / (double) cards_scanned; - _measurements->report_cost_per_entry_ms(cost_per_entry_ms, collector_state()->last_gc_was_young()); + _analytics->report_cost_per_entry_ms(cost_per_entry_ms, collector_state()->last_gc_was_young()); } if (_max_rs_lengths > 0) { double cards_per_entry_ratio = (double) cards_scanned / (double) _max_rs_lengths; - _measurements->report_cards_per_entry_ratio(cards_per_entry_ratio, collector_state()->last_gc_was_young()); + _analytics->report_cards_per_entry_ratio(cards_per_entry_ratio, collector_state()->last_gc_was_young()); } // This is defensive. For a while _max_rs_lengths could get @@ -852,7 +855,7 @@ if (_max_rs_lengths > recorded_rs_lengths) { rs_length_diff = _max_rs_lengths - recorded_rs_lengths; } - _measurements->report_rs_length_diff((double) rs_length_diff); + _analytics->report_rs_length_diff((double) rs_length_diff); size_t freed_bytes = heap_used_bytes_before_gc - cur_used_bytes; size_t copied_bytes = _collection_set->bytes_used_before() - freed_bytes; @@ -860,23 +863,23 @@ if (copied_bytes > 0) { cost_per_byte_ms = average_time_ms(G1GCPhaseTimes::ObjCopy) / (double) copied_bytes; - _measurements->report_cost_per_byte_ms(cost_per_byte_ms, collector_state()->in_marking_window()); + _analytics->report_cost_per_byte_ms(cost_per_byte_ms, collector_state()->in_marking_window()); } if (_collection_set->young_region_length() > 0) { - _measurements->report_young_other_cost_per_region_ms(young_other_time_ms() / + _analytics->report_young_other_cost_per_region_ms(young_other_time_ms() / _collection_set->young_region_length()); } if (_collection_set->old_region_length() > 0) { - _measurements->report_non_young_other_cost_per_region_ms(non_young_other_time_ms() / + _analytics->report_non_young_other_cost_per_region_ms(non_young_other_time_ms() / _collection_set->old_region_length()); } - _measurements->report_constant_other_time_ms(constant_other_time_ms(pause_time_ms)); + _analytics->report_constant_other_time_ms(constant_other_time_ms(pause_time_ms)); - _measurements->report_pending_cards((double) _pending_cards); - _measurements->report_rs_lengths((double) _max_rs_lengths); + _analytics->report_pending_cards((double) _pending_cards); + _analytics->report_rs_lengths((double) _max_rs_lengths); } collector_state()->set_in_marking_window(new_in_marking_window); @@ -1034,14 +1037,14 @@ double G1CollectorPolicy::predict_base_elapsed_time_ms(size_t pending_cards, size_t scanned_cards) const { return - _measurements->predict_rs_update_time_ms(pending_cards) + - _measurements->predict_rs_scan_time_ms(scanned_cards, collector_state()->gcs_are_young()) + - _measurements->predict_constant_other_time_ms(); + _analytics->predict_rs_update_time_ms(pending_cards) + + _analytics->predict_rs_scan_time_ms(scanned_cards, collector_state()->gcs_are_young()) + + _analytics->predict_constant_other_time_ms(); } double G1CollectorPolicy::predict_base_elapsed_time_ms(size_t pending_cards) const { - size_t rs_length = _measurements->predict_rs_lengths() + _measurements->predict_rs_length_diff(); - size_t card_num = _measurements->predict_card_num(rs_length, collector_state()->gcs_are_young()); + size_t rs_length = _analytics->predict_rs_lengths() + _analytics->predict_rs_length_diff(); + size_t card_num = _analytics->predict_card_num(rs_length, collector_state()->gcs_are_young()); return predict_base_elapsed_time_ms(pending_cards, card_num); } @@ -1063,19 +1066,19 @@ size_t rs_length = hr->rem_set()->occupied(); // Predicting the number of cards is based on which type of GC // we're predicting for. - size_t card_num = _measurements->predict_card_num(rs_length, for_young_gc); + size_t card_num = _analytics->predict_card_num(rs_length, for_young_gc); size_t bytes_to_copy = predict_bytes_to_copy(hr); double region_elapsed_time_ms = - _measurements->predict_rs_scan_time_ms(card_num, collector_state()->gcs_are_young()) + - _measurements->predict_object_copy_time_ms(bytes_to_copy ,collector_state()->during_concurrent_mark()); + _analytics->predict_rs_scan_time_ms(card_num, collector_state()->gcs_are_young()) + + _analytics->predict_object_copy_time_ms(bytes_to_copy ,collector_state()->during_concurrent_mark()); // The prediction of the "other" time for this region is based // upon the region type and NOT the GC type. if (hr->is_young()) { - region_elapsed_time_ms += _measurements->predict_young_other_time_ms(1); + region_elapsed_time_ms += _analytics->predict_young_other_time_ms(1); } else { - region_elapsed_time_ms += _measurements->predict_non_young_other_time_ms(1); + region_elapsed_time_ms += _analytics->predict_non_young_other_time_ms(1); } return region_elapsed_time_ms; } @@ -1087,8 +1090,8 @@ } size_t G1CollectorPolicy::expansion_amount() { - double recent_gc_overhead = _measurements->recent_avg_pause_time_ratio() * 100.0; - double last_gc_overhead = _measurements->last_pause_time_ratio() * 100.0; + double recent_gc_overhead = _analytics->recent_avg_pause_time_ratio() * 100.0; + double last_gc_overhead = _analytics->last_pause_time_ratio() * 100.0; double threshold = _gc_overhead_perc; size_t expand_bytes = 0; @@ -1373,8 +1376,8 @@ double end_sec = os::elapsedTime(); double elapsed_time_ms = (end_sec - _mark_cleanup_start_sec) * 1000.0; - _measurements->report_concurrent_mark_cleanup_times_ms(elapsed_time_ms); - _measurements->append_prev_collection_pause_end_ms(elapsed_time_ms); + _analytics->report_concurrent_mark_cleanup_times_ms(elapsed_time_ms); + _analytics->append_prev_collection_pause_end_ms(elapsed_time_ms); record_pause(Cleanup, _mark_cleanup_start_sec, end_sec); }