# HG changeset patch # User tschatzl # Date 1405929586 -7200 # Node ID 3bf2fc51186bd8353bb2bd7f837e5305750b3b72 # Parent 4baf9bb2376ce589fac7b69f0ff9f42dc89038f7 8048085: Aborting marking just before remark results in useless additional clearing of the next mark bitmap Summary: Skip clearing the next bitmap if we just recently aborted since the full GC already clears this bitmap. Reviewed-by: brutisso diff -r 4baf9bb2376c -r 3bf2fc51186b src/share/vm/gc_implementation/g1/concurrentMark.cpp --- a/src/share/vm/gc_implementation/g1/concurrentMark.cpp Mon Jul 21 09:59:37 2014 +0200 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.cpp Mon Jul 21 09:59:46 2014 +0200 @@ -890,6 +890,10 @@ guarantee(!g1h->mark_in_progress(), "invariant"); } +bool ConcurrentMark::nextMarkBitmapIsClear() { + return _nextMarkBitMap->getNextMarkedWordAddress(_heap_start, _heap_end) == _heap_end; +} + class NoteStartOfMarkHRClosure: public HeapRegionClosure { public: bool doHeapRegion(HeapRegion* r) { @@ -3358,7 +3362,8 @@ // abandon current marking iteration due to a Full GC void ConcurrentMark::abort() { - // Clear all marks to force marking thread to do nothing + // Clear all marks in the next bitmap for the next marking cycle. This will allow us to skip the next + // concurrent bitmap clearing. _nextMarkBitMap->clearAll(); // Clear the liveness counting data clear_all_count_data(); diff -r 4baf9bb2376c -r 3bf2fc51186b src/share/vm/gc_implementation/g1/concurrentMark.hpp --- a/src/share/vm/gc_implementation/g1/concurrentMark.hpp Mon Jul 21 09:59:37 2014 +0200 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.hpp Mon Jul 21 09:59:46 2014 +0200 @@ -736,6 +736,9 @@ // Clear the next marking bitmap (will be called concurrently). void clearNextBitmap(); + // Return whether the next mark bitmap has no marks set. + bool nextMarkBitmapIsClear(); + // These two do the work that needs to be done before and after the // initial root checkpoint. Since this checkpoint can be done at two // different points (i.e. an explicit pause or piggy-backed on a diff -r 4baf9bb2376c -r 3bf2fc51186b src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp --- a/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp Mon Jul 21 09:59:37 2014 +0200 +++ b/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp Mon Jul 21 09:59:46 2014 +0200 @@ -275,9 +275,13 @@ // We now want to allow clearing of the marking bitmap to be // suspended by a collection pause. - { + // We may have aborted just before the remark. Do not bother clearing the + // bitmap then, as it has been done during mark abort. + if (!cm()->has_aborted()) { SuspendibleThreadSetJoiner sts; _cm->clearNextBitmap(); + } else { + assert(!G1VerifyBitmaps || _cm->nextMarkBitmapIsClear(), "Next mark bitmap must be clear"); } }