8138740: Start initial mark right after mixed GC if needed
Summary: Instead of issuing a single young-only GC after the end of all mixed GCs, if needed immediately start an initial mark in that young-only GC.
Reviewed-by: drwhite, mgerdin
--- a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp Tue Nov 10 11:07:15 2015 +0100
+++ b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp Tue Nov 10 11:07:15 2015 +0100
@@ -1003,11 +1003,8 @@
last_pause_included_initial_mark = collector_state()->during_initial_mark_pause();
if (last_pause_included_initial_mark) {
record_concurrent_mark_init_end(0.0);
- } else if (need_to_start_conc_mark("end of GC")) {
- // Note: this might have already been set, if during the last
- // pause we decided to start a cycle but at the beginning of
- // this pause we decided to postpone it. That's OK.
- collector_state()->set_initiate_conc_mark_if_possible(true);
+ } else {
+ maybe_start_marking();
}
_mmu_tracker->add_pause(end_time_sec - pause_time_ms/1000.0, end_time_sec);
@@ -1079,6 +1076,8 @@
if (!next_gc_should_be_mixed("continue mixed GCs",
"do not continue mixed GCs")) {
collector_state()->set_gcs_are_young(true);
+
+ maybe_start_marking();
}
}
@@ -1932,6 +1931,15 @@
return (double) reclaimable_bytes * 100.0 / (double) capacity_bytes;
}
+void G1CollectorPolicy::maybe_start_marking() {
+ if (need_to_start_conc_mark("end of GC")) {
+ // Note: this might have already been set, if during the last
+ // pause we decided to start a cycle but at the beginning of
+ // this pause we decided to postpone it. That's OK.
+ collector_state()->set_initiate_conc_mark_if_possible(true);
+ }
+}
+
bool G1CollectorPolicy::next_gc_should_be_mixed(const char* true_action_str,
const char* false_action_str) const {
CollectionSetChooser* cset_chooser = _collectionSetChooser;
--- a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp Tue Nov 10 11:07:15 2015 +0100
+++ b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp Tue Nov 10 11:07:15 2015 +0100
@@ -534,6 +534,8 @@
// as a percentage of the current heap capacity.
double reclaimable_bytes_perc(size_t reclaimable_bytes) const;
+ // Sets up marking if proper conditions are met.
+ void maybe_start_marking();
public:
G1CollectorPolicy();