From 23a54f37018bb9345a60a6891e81c1910fb8c3c8 Mon Sep 17 00:00:00 2001 From: Albert Mingkun Yang Date: Tue, 13 Jun 2023 07:53:34 +0000 Subject: [PATCH] 8309538: G1: Move total collection increment from Cleanup to Remark Reviewed-by: tschatzl, iwalulya --- src/hotspot/share/gc/g1/g1ConcurrentMark.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp index 248a5043777..19c059656e4 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp @@ -1295,6 +1295,11 @@ void G1ConcurrentMark::remark() { ClassLoaderDataGraph::purge(/*at_safepoint*/true); } + // Potentially, some empty-regions have been reclaimed; make this a + // "collection" so that pending allocation can retry before attempting a + // GC pause. + _g1h->increment_total_collections(); + _g1h->resize_heap_if_necessary(); _g1h->uncommit_regions_if_necessary(); @@ -1462,10 +1467,6 @@ void G1ConcurrentMark::cleanup() { verify_during_pause(G1HeapVerifier::G1VerifyCleanup, VerifyLocation::CleanupAfter); - // We need to make this be a "collection" so any collection pause that - // races with it goes around and waits for Cleanup to finish. - _g1h->increment_total_collections(); - // Local statistics double recent_cleanup_time = (os::elapsedTime() - start); _total_cleanup_time += recent_cleanup_time;