--- old/src/hotspot/share/gc/g1/g1Policy.cpp 2019-01-23 10:43:56.281701820 +0100 +++ new/src/hotspot/share/gc/g1/g1Policy.cpp 2019-01-23 10:43:55.788686316 +0100 @@ -23,6 +23,7 @@ */ #include "precompiled.hpp" +#include "gc/g1/collectionSetChooser.hpp" #include "gc/g1/g1Analytics.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1CollectionSet.hpp" @@ -438,7 +439,7 @@ // Release the future to-space so that it is available for compaction into. collector_state()->set_in_young_only_phase(false); collector_state()->set_in_full_gc(true); - cset_chooser()->clear(); + _collection_set->clear_candidates(); } void G1Policy::record_full_collection_end() { @@ -546,10 +547,6 @@ return other_time_ms(pause_time_ms) - phase_times()->total_free_cset_time_ms(); } -CollectionSetChooser* G1Policy::cset_chooser() const { - return _collection_set->cset_chooser(); -} - bool G1Policy::about_to_start_mixed_phase() const { return _g1h->concurrent_mark()->cm_thread()->during_cycle() || collector_state()->in_young_gc_before_mixed(); } @@ -586,6 +583,7 @@ assert(cur_used_bytes == _g1h->recalculate_used(), "It should!"); bool this_pause_included_initial_mark = false; bool this_pause_was_young_only = collector_state()->in_young_only_phase(); + bool this_pause_was_last_before_mixed = collector_state()->in_young_gc_before_mixed(); bool update_stats = !_g1h->evacuation_failed(); @@ -773,8 +771,6 @@ _g1h->concurrent_refine()->adjust(average_time_ms(G1GCPhaseTimes::UpdateRS), phase_times()->sum_thread_work_items(G1GCPhaseTimes::UpdateRS), update_rs_time_goal_ms); - - cset_chooser()->verify(); } G1IHOPControl* G1Policy::create_ihop_control(const G1Predictions* predictor){ @@ -1032,7 +1028,8 @@ } void G1Policy::record_concurrent_mark_cleanup_end() { - cset_chooser()->rebuild(_g1h->workers(), _g1h->num_regions()); + G1CollectionSetCandidates* candidates = CollectionSetChooser::build(_g1h->workers(), _g1h->num_regions()); + _collection_set->set_candidates(candidates); bool mixed_gc_pending = next_gc_should_be_mixed("request mixed gcs", "request young-only gcs"); if (!mixed_gc_pending) { @@ -1063,10 +1060,10 @@ void G1Policy::clear_collection_set_candidates() { // Clear remembered sets of remaining candidate regions and the actual candidate - // list. + // set. G1ClearCollectionSetCandidateRemSets cl; - cset_chooser()->iterate(&cl); - cset_chooser()->clear(); + _collection_set->candidates()->iterate(&cl); + _collection_set->clear_candidates(); } void G1Policy::maybe_start_marking() { @@ -1132,22 +1129,24 @@ bool G1Policy::next_gc_should_be_mixed(const char* true_action_str, const char* false_action_str) const { - if (cset_chooser()->is_empty()) { + G1CollectionSetCandidates* candidates = _collection_set->candidates(); + + if (candidates->is_empty()) { log_debug(gc, ergo)("%s (candidate old regions not available)", false_action_str); return false; } // Is the amount of uncollected reclaimable space above G1HeapWastePercent? - size_t reclaimable_bytes = cset_chooser()->remaining_reclaimable_bytes(); + size_t reclaimable_bytes = candidates->remaining_reclaimable_bytes(); double reclaimable_percent = reclaimable_bytes_percent(reclaimable_bytes); double threshold = (double) G1HeapWastePercent; if (reclaimable_percent <= threshold) { log_debug(gc, ergo)("%s (reclaimable percentage not over threshold). candidate old regions: %u reclaimable: " SIZE_FORMAT " (%1.2f) threshold: " UINTX_FORMAT, - false_action_str, cset_chooser()->remaining_regions(), reclaimable_bytes, reclaimable_percent, G1HeapWastePercent); + false_action_str, candidates->num_remaining(), reclaimable_bytes, reclaimable_percent, G1HeapWastePercent); return false; } log_debug(gc, ergo)("%s (candidate old regions available). candidate old regions: %u reclaimable: " SIZE_FORMAT " (%1.2f) threshold: " UINTX_FORMAT, - true_action_str, cset_chooser()->remaining_regions(), reclaimable_bytes, reclaimable_percent, G1HeapWastePercent); + true_action_str, candidates->num_remaining(), reclaimable_bytes, reclaimable_percent, G1HeapWastePercent); return true; } @@ -1159,10 +1158,10 @@ // maximum desired number of mixed GCs. // // The calculation is based on the number of marked regions we added - // to the CSet chooser in the first place, not how many remain, so + // to the CSet candidates in the first place, not how many remain, so // that the result is the same during all mixed GCs that follow a cycle. - const size_t region_num = (size_t) cset_chooser()->length(); + const size_t region_num = _collection_set->candidates()->num_regions(); const size_t gc_num = (size_t) MAX2(G1MixedGCCountTarget, (uintx) 1); size_t result = region_num / gc_num; // emulate ceiling