--- old/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2019-11-06 19:09:40.499602945 -0500 +++ new/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2019-11-06 19:09:40.231588572 -0500 @@ -1990,7 +1990,7 @@ } bool G1CollectedHeap::should_upgrade_to_full_gc(GCCause::Cause cause) { - if(policy()->force_upgrade_to_full()) { + if (policy()->force_upgrade_to_full()) { return true; } else if (should_do_concurrent_full_gc(_gc_cause)) { return false; @@ -2086,6 +2086,7 @@ try_collect(cause); } +// Return true if (x < y) with allowance for wraparound. static bool gc_counter_less_than(uint x, uint y) { return (x - y) > (UINT_MAX/2); } @@ -2094,13 +2095,13 @@ // Macro so msg printing is format-checked. #define LOG_COLLECT_CONCURRENTLY(cause, ...) \ do { \ - LogTarget(Debug, gc) LOG_COLLECT_CONCURRENTLY_lt; \ + LogTarget(Trace, gc) LOG_COLLECT_CONCURRENTLY_lt; \ if (LOG_COLLECT_CONCURRENTLY_lt.is_enabled()) { \ ResourceMark rm; /* For thread name. */ \ LogStream LOG_COLLECT_CONCURRENTLY_s(&LOG_COLLECT_CONCURRENTLY_lt); \ - LOG_COLLECT_CONCURRENTLY_s.print("Try Collect Concurrently (%s) for %s: ", \ - GCCause::to_string(cause), \ - Thread::current()->name()); \ + LOG_COLLECT_CONCURRENTLY_s.print("%s: Try Collect Concurrently (%s): ", \ + Thread::current()->name(), \ + GCCause::to_string(cause)); \ LOG_COLLECT_CONCURRENTLY_s.print(__VA_ARGS__); \ } \ } while (0) --- old/src/hotspot/share/gc/g1/g1VMOperations.cpp 2019-11-06 19:09:41.531658289 -0500 +++ new/src/hotspot/share/gc/g1/g1VMOperations.cpp 2019-11-06 19:09:41.283644989 -0500 @@ -72,8 +72,13 @@ // to notify the caller and return immediately. _cycle_already_in_progress = true; } else if (!g1h->do_collection_pause_at_safepoint(_target_pause_time_ms)) { + // Failure to perform the collection at all occurs because GCLocker is + // active, and we have the bad luck to be the collection request that + // makes a later _gc_locker collection needed. (Else we would have hit + // the GCLocker check in the prologue.) _transient_failure = true; } else if (g1h->should_upgrade_to_full_gc(_gc_cause)) { + // GC ran, but we're still in trouble and need a full GC. log_info(gc, ergo)("Attempting maximally compacting collection"); _gc_succeeded = g1h->do_full_collection(false, /* explicit gc */ true /* clear_all_soft_refs */); @@ -121,17 +126,13 @@ // An allocation had been requested. Do it, eventually trying a stronger // kind of GC. _result = g1h->satisfy_failed_allocation(_word_size, &_gc_succeeded); - } else { - bool should_upgrade_to_full = g1h->should_upgrade_to_full_gc(_gc_cause); - - if (should_upgrade_to_full) { - // There has been a request to perform a GC to free some space. We have no - // information on how much memory has been asked for. In case there are - // absolutely no regions left to allocate into, do a maximally compacting full GC. - log_info(gc, ergo)("Attempting maximally compacting collection"); - _gc_succeeded = g1h->do_full_collection(false, /* explicit gc */ - true /* clear_all_soft_refs */); - } + } else if (g1h->should_upgrade_to_full_gc(_gc_cause)) { + // There has been a request to perform a GC to free some space. We have no + // information on how much memory has been asked for. In case there are + // absolutely no regions left to allocate into, do a maximally compacting full GC. + log_info(gc, ergo)("Attempting maximally compacting collection"); + _gc_succeeded = g1h->do_full_collection(false, /* explicit gc */ + true /* clear_all_soft_refs */); } guarantee(_gc_succeeded, "Elevated collections during the safepoint must always succeed."); }